Page 1 of 1
Installing GRUB to an hd image
Posted: Tue Jun 09, 2009 2:11 pm
by alethiophile
I can't figure out how to install GRUB to an HD image so I can test it on an emulator. I create a bootable image as it says to in the GRUB wiki page and in the Grub docs, create the new os image, make a filesystem on it (I have tried both FAT16 and ext2), and boot with Qemu. When I try to install it, it gives me an error similar to 'cannot mount selected partition'. Also, when I try the find command on files I know are in the image, it returns 'cannot find file'. Does anyone know how to do this?
Re: Installing GRUB to an hd image
Posted: Tue Jun 09, 2009 4:38 pm
by JamesM
Hi,
The workflow pretty much goes like this:
1) Create the (blank) HDD image using 'dd' or similar.
2) Mount it as loopback and run fdisk to set up the partition table. Create your partitions here.
3) Unmount. Remount as loopback with a byte offset to the start of the first partition.
4) Run mke2fs/mkdosfs on the loopback device to create the FS.
5) Copy the grub stage1/stage2 to /boot.
6) Create a menu.lst.
7) Copy your OS across and unmount.
See
Loopback Device.
James
Re: Installing GRUB to an hd image
Posted: Tue Jun 09, 2009 4:54 pm
by alethiophile
Thanks. I hadn't been making a partition table, just using the whole disk.