Installing GRUB2 in an image file
Posted: Sat Sep 05, 2009 3:45 pm
I have an image file, hdd.img, created as follows:
How do I install GRUB2 on hdd.img. In the past, I have install GRUB Legacy on a similar file, simply by running:
and then entering
I have tried playing around with grub-install without any success. Can anyone please give me some pointers on how to install GRUB2.
Thanks,
gamiel
Code: Select all
$ dd if=/dev/zero of=hdd.img bs=512 count=16065
$ losetup /dev/loop/0 hdd.img
# create a single pirmary parition with fdisk
$ fdisk /dev/loop/0
$ losetup -o <offset in file to the partition> /dev/loop/1 /dev/loop/0
$ mke2fs /dev/loop/1
Code: Select all
$ grub --device-map=/dev/null
Code: Select all
device (hd0) hdd.img
root (hd0,0)
setup (hd0)
Thanks,
gamiel