Wednesday, December 10, 2014

How to build a grub2 core.img that can boot from a gpt partition

Problem: Current core.img in /boot/grub/i386-pc/ can't boot from gpt partition, trying to results in "grub rescue>" prompt

Solution: Build a grub2 core.img that can boot from gpt partition.

Prerequisites:

1- Find and download grub-pc binary for your distribution,  for ubuntu (14.04) it is "grub-pc-bin_2.02~beta2-9_amd64.deb".
2- Extract i386-pc folder from downloaded archive (I extracted the folder to Desktop)

3- Now build the core img:

 grub-mkimage -d ~/Desktop/i386-pc -o core.img --format i386-pc biosdisk part_gpt ext2

4- put generated core.img to /boot/grub/i386-pc

5- Chainload core img from grub4dos (eg.: kernel (hd0,1)/boot/grub/i386-pc/core.img)

To build a fat core.img which isn't necessary (once grub2 reads the partition /boot/grub/ is on rest of the modules could be loaded from there):

"grub-mkimage -d ~/Desktop/i386-pc -o core.img --format i386-pc biosdisk iso9660 multiboot normal ls cat help part_msdos part_gpt ext2 fat fshelp configfile"

configfile module provides source command which can load another grub.cfg from disk part_gpt, ls, cat, help is pretty self explanatory (I think), rest of the modules could be omitted (again, I think)

No comments:

Post a Comment