I followed the Wiki article for producing a disk image (https://wiki.osdev.org/GRUB_2#Disk_image_instructions), but I am having some trouble getting bochs to load the img file; it gets an IDE time out.
I looked at the hex makeup of the img file, and the MBR code is empty after installing grub; the partition entry exists from fdisk operations and it is bootable with value 0x80, but no actual bootloader code -- bytes 0-446 are all zeroed. This seems, uh, problematic -- I assume this is the root of this issue, but I didn't know if maybe that gets filled in at some point by some process I'm not aware of. Am I just missing a step? I should note that grub-install successfully installs a bunch of stuff under /boot/grub and /boot/efi.
bochsrc disk entry (from bximage)
Code: Select all
ata0-master: type=disk, mode=flat, path=myos_disk.img
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
For completeness, here are the exact steps I took:
Create disk image:
Code: Select all
$ dd if=/dev/zero of=myos_disk.img bs=512 count=131072
Code: Select all
$ fdisk myos_disk.img
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-131071, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-131071, default 131071):
Created a new partition 1 of type 'Linux' and of size 63 MiB.
Command (m for help): a
Selected partition 1
The bootable flag on partition 1 is enabled now.
Command (m for help): w
The partition table has been altered. Syncing disks.
Code: Select all
$ sudo losetup /dev/loop0 myos_disk.img
$ sudo losetup /dev/loop1 myos_disk.img -o 1048576
Code: Select all
$ sudo mkdosfs -F32 -f 2 /dev/loop1
Code: Select all
$ sudo mount /dev/loop1 /mnt
Code: Select all
$ sudo grub-install --root-directory=/mnt --no-floppy --modules="normal part_msdos ext2 multiboot" /dev/loop0
Installing for x86_64-efi platform.
Installation finished. No error reported.
$ sync
Code: Select all
$ sudo cp isodir/boot/myos.bin /mnt/boot/myos.bin
$ sudo cp isodir/boot/grub/grub.cfg /mnt/boot/grub/grub.cfg
Code: Select all
$ sudo umount /mnt
$ losetup -d /dev/loop0; losetup -d /dev/loop1
Code: Select all
bochs -q
Thanks in advance for any help or suggestions. I have been looking through the forums/wiki grub docs but have not been able to really find anything