Ubuntu – Grub won’t boot after converting MBR partition table to GPT

bootdual-bootgrub2partitioning

I have a problem on booting my Ubuntu 16.04.2 LTS after converting my hard drive from MBR to GPT. As I found it on other websites, I used gdisk to convert the hard drive from MBR to GPT. After doing so and restarted my PC, it turned out that the GRUB OS Menu do not display on boot, instead, the screen just showed me a black screen with a blinking cursor. When I tried to convert the GPT back to MBR partition table, the command seemed to be successful but the GRUB is still not working

Additional Info: I am dual-booting Ubuntu 16.04 and Windows 10

Command used to convert MBT to GPT:

sudo gdisk /dev/sda
Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y

Anyone who knows how to fix the problem? Am I doing something wrong?

Best Answer

Short answer:

grub i386-pc needs a "BIOS boot partition" (i.e. type ef02 in gdisk). So you need to create one after the conversion, before running grub-install again.

Explanation:

It's only natural that grub will not work when youn convert your MBR/msdos partition table to GUID partition table.

The reason is, grub makes use of the "post-MBR gap", that is, the gap between the MBR and the first partition, for embedding a portion of its boot code (a.k.a. core.img). When you convert the partition table to GPT, part of the gap is overwritten with the main GPT, for it lies on LBA 1-33 (where the MBR lies on LBA 0).

Moreover, BIOS grub (a.k.a. grub i386-pc) on GPT no longer make use of the post-MBR, or post-GPT gap for core.img embedding. Instead it needs a "BIOS boot partition" (i.e. type ef02 in gdisk). So you need to create one after the conversion, before running grub-install again.

Also, note that a backup GPT lies at the last 33 logical blocks of the disk. If the last/only partition extended till the last block of the disk, you would need to shrink the filesystem on it to make sure that the filesystem no longer covered the last 33 blocks of the partition/disk, so that the blocks could be safely overwritten with the backup GPT. If you didn't do that before the conversion, there could be some damages done to the filesystem.