View previous topic :: View next topic |
Author |
Message |
blixel Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/12013893754205cb9d91bb9.jpg)
Joined: 19 Jul 2004 Posts: 403 Location: Central, Florida
|
Posted: Wed Aug 31, 2005 8:07 pm Post subject: Creating a bootable image [SOLVED] |
|
|
Does anyone know how to create a bootable disk image that can be written to Compact Flash? I have a 128MB CF card. I've put together a small Linux system that will fit on the card. I *do not* want to just copy the files over to the card and run grub-install.
This is what I've done so far:
( My Viking 128MB C/H/S = 17/237/62 )
( 17 x 237 x 62 = 249798 )
( 62 x 512 = 31744 (start of /dev/hda1 partition, the first 31744 sectors are MBR space) )
# create a 128MB file full of zeros
dd if=/dev/zero of=/miniLinux-image.bin count=249798
# link the 128MB image file to /dev/loop0
losetup /dev/loop0 /miniLinux-image.bin
# bring up the fdisk utility so we can partition the image file
fdisk -u -C17 -S62 -H237 /dev/loop0
# create 1 partition with all the space of the CF card, save and exit
# Note the number of blocks the partition has (124868)
# unlink the image file from /dev/loop0
losetup -d /dev/loop0
# relink the image file to /dev/loop0, but offset it
# so we only have access to the primary partition space and not the MBR space
losetup -o31744 /dev/loop0 /miniLinux-image.bin
# format the image file as ext2 using a block size of 1024.
# 124868 is the number of blocks the partition has
mke2fs -b1024 /dev/loop0 124868
# Now mount the /dev/loop0 device (which is linked to the binary image file) to /mnt
mount /dev/loop0 /mnt
# Extract our already prepared miniLinux system to the mounted location
cd /mnt
(cd /miniLinux/usr/miniLinux; tar cPf - .) | (cd /mnt; tar xf -)
# Unmount the device
cd /
umount /mnt
# unlink the image file from /dev/loop0
losetup -d /dev/loop0
At this point, I can dd the image to my CF card but the CF card isn't bootable. In order to make it bootable, I have to use grub-install. I don't know if I can really explain why this is such a problem, but trust me, it is. (If you've ever delt with embedded computing, then you should understand why. Some systems have the memory physicaly integrated onto the system. There is no way to remove the compact flash and stick it in a memory reader. So everything has to be done in one step.)
I want the image file I create to be a complete product. I don't want to have to dd the image AND run grub-install to make it bootable. I want people to just be able to dd the image to their own card and be done.
I understand that I'm missing the step that makes the card bootable. I understand that by following my steps above, there's no point where anything would make the card bootable. But I don't know what that step is. I've tried several different ideas with grub, but nothing seems to work.
Does anyone have any experience with something like this? Know of a website that has a guide I can look at?
Last edited by blixel on Thu Sep 01, 2005 12:40 am; edited 1 time in total |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
widan Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/142533236243680bda6f27b.jpg)
Joined: 07 Jun 2005 Posts: 1512 Location: Paris, France
|
Posted: Wed Aug 31, 2005 11:56 pm Post subject: |
|
|
Maybe this page (it's for creating virtual machine disk images, but it should be close enough to what you want to do). |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
blixel Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/12013893754205cb9d91bb9.jpg)
Joined: 19 Jul 2004 Posts: 403 Location: Central, Florida
|
Posted: Thu Sep 01, 2005 12:39 am Post subject: |
|
|
widan wrote: | Maybe this page (it's for creating virtual machine disk images, but it should be close enough to what you want to do). |
Perfect! That was exactly what I was looking for!
Since posting the original message, I learned how to use LILO to do what I wanted. But I haven't been much of a LILO fan since about 1999. So thank you very much for pointing me to that link! I went through the article and was able to find the pieces I was missing. I just tried it out and it works beautifully. It also fixes a weird error/warning message I was getting when using LILO.
You've made my day bro. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|