I'm trying to get grub1 working with GPT. Currently on a virtual machine, as a test step before migrating a real one.
I've created a partition for /boot
, and a different one where I'd like to embed grub stage1.5. This is what gdisk displays for the GPT partition table:
Number Start (sector) End (sector) Size Code Name
1 2048 104447 50.0 MiB 8300 boot
2 104448 206847 50.0 MiB EF00 EFI
3 206848 16984063 8.0 GiB 8E00
4 1024 2047 512.0 KiB EF02 GRUB1
Don't bother with the EFI partition, it's not used in this scenario. It's just that I intend to later upgrade the system to UEFI (I know, saying goodbye to grub1), and want to create the partition earlier.
Now, as grub1 does not understand GPT, I've created a hybrid MBR, consiting of 1st and 4th partitions. This is what gdisk says about the hybrid MBR:
Number Boot Start Sector End Sector Status Code
1 1 1023 primary 0xEE
2 * 2048 104447 primary 0x83
3 1024 2047 primary 0xEF
4 104448 20971519 primary 0xEE
My intention is to put stage1.5 on the small partition below 1MB and have real boot partition (with stage2, grub configuration and kernel image) at the boot
partition (GPT 1/MBR 2). However I cannot get grub to install the stage.
When running grub
the command find /grub/menu.lst
shows me (hd0,0)
, so it looks like it's using the running kernels partition layout, where the embed partition would be (hd0,3)
. However giving root (hd0,3)
gives me
Filesystem type unknown, partition type 0x83
The filesystem type is not a surprise, as the partition is empty, but I've set the the partition type and it's not visible.
When I try to embed the stage1.5 in the partition (using embed (hd0,0)/grub/e2fs_stage1_5 (hd0,3)
I get an error:
Error 17: Cannot mount selected partition
I've tried creating reiserfs3 on that partition (as reiserfs3 has 16KB of space for embedding bootloader), but the error is identical. However the FS I've created is a nonstandard one, with journal on a separate device, as 512KB is not enough to create a normal one.
I've checked that (hd0,3) is the correct drive, as writing something to the first sector of the partition and running cat (hd0,3)+1
in grub shell gives me expected output.
Any other options on how to get this running? I'm thinking of manually embedding stage1.5 into the selected partition (cat /boot/grub/e2fs_stage1_5 > /dev/sda4
), modifying it properly (I guess it's only the blocklist in first sector and stage2 location in 2nd sector), and going from there, but I'd like to make it work correctly.
The version I'm using is sys-boot/grub-0.97-r18 from Gentoo.