Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Creating a bootable image [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
blixel
Guru
Guru


Joined: 19 Jul 2004
Posts: 403
Location: Central, Florida

PostPosted: Wed Aug 31, 2005 8:07 pm    Post subject: Creating a bootable image [SOLVED] Reply with quote

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
View user's profile Send private message
widan
Veteran
Veteran


Joined: 07 Jun 2005
Posts: 1512
Location: Paris, France

PostPosted: Wed Aug 31, 2005 11:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
blixel
Guru
Guru


Joined: 19 Jul 2004
Posts: 403
Location: Central, Florida

PostPosted: Thu Sep 01, 2005 12:39 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
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