I have a 1Gb HDD image (created using bximage for Bochs), onto which I wish to install Grub 2.
I understand that a Grub installation consists of 3 parts:
- The boot.img image, which occupies the first sector
- The core.img image, which occupies space following the first sector up until the start of the next track
- And the /boot/grub/ directory, in which the grub.cfg and other modules are located.
First I use a boot.img image that from within my own Linux /boot/grub/ directory.
Following this, I generate my core.img image using the following command:
sudo grub-mkimage -v --format=i386-pc -o core.img -p\(hd0,msdos1\)/boot/grub ls ext2 part_msdos
And to install them onto the final disk image, I use the following commands:
sudo dd if=boot.img of=/dev/loop0 bs=446 count=1the 446 blocksize is used so as to not overwrite The partition data that resides within the MBR
sudo dd if=core.img of=/dev/loop0 bs=512 seek=1and here,
seek=1is so as to not overwrite the MBR that was just written.
The disk, starting from sector 2048 until the last, is formatted with an ext2 partition, and contains a boot/grub/ directory containing a grub.cfg (with a single bogus menuentry which doesn't load anything), and modules in the /boot/grub/i386-pc/ directory.
Bochs successfully boots this installation of grub all the way to the grub> prompt. As This Ubuntu guide points out, this behaviour indicates that grub.cfg was not found.
ls, I am faced with an interesting problem - I apparently have no devices connected at all!
To further elaborate on the nature of the problem, I observed that when booting a
grub-mkrescue image from a slave drive, invoking
ls displayed its own rescue drive, and the previously 'non-existant' primary disk drive, along with the ext2 partition. I verified that /boot/grub.cfg could indeed be accessed.
From this observation I would assume that my own core.img is missing some fundamental module or functionality. But which, and how would I amend this?
I also conducted this exercise on a physical machine using a USB stick, and the exact same thing happened, so I can confirm that the problem is not with Bochs.