Linux: GRUB2 cannot recognize LVM logical volume with mixed GPT and MBR

This article will describe the solution against the problem that GRUB2 cannot recognize LVM logical volume with multiple partition type LVM physical volumes.

1 GRUB2 cannot recognize LVM logical volume with mixed GPT and MBR

For example, if there is a LVM logical volume with GPT LVM physical volume, appending MBR LVM physical volume to the LVM logical volume will make GRUB2 cannot recognize the LVM logical volume.

error: disk 'lvmid/<snip>' not found.
Entering rescue mode...
grub rescue>

0001_grub2-gpt-mbr-lvm.png

2 Cause

This is because GPT module is built-in to GRUB2 and MBR module is not built-in. There is a case that MBR module is built-in and GPT is not built-in too.

The grub-install will look up LVM physical volume and install needed module. The grub-install will call grub-mkimage and grub-bios-setup internally.

$ sudo grub2-install -v /dev/vda
<snip>
grub2-install: info: grub-mkimage <snip>
--compression 'auto'  'ext2' 'part_gpt' 'lvm' 'biosdisk'
.
<snip>
grub2-install: info: grub-bios-setup <snip> '/dev/vda'.
<snip>

The grub-install is run automatically when Linux is installed and when GRUB2 is updated.

  • There is only GPT LVM physical volume when Linux is installed, the grub-install will install only GPT module.
  • After Linux is installed, you add MBR LVM physical volume to LVM logical volume.
  • After reboot, GRUB cannot recognize LVM logical volume because part_msdos is not built-in.

3 Solution

Specifying module to be built-in by default when running grub-install is the best way. But at least Debian cannot specify module.

There are three solutions. I think that (3) is easy.

  • (1) Make the same partition type LVM physical volume with the first LVM physical volume. But the partition type of first LVM physical volume depends on environment.
  • (2) Run grub-mkimage/grub-bios-setup and install GPT and MBR modules after Linux is installed. But you need to run grub-mkimage/grub-bios-setup for each GRUB2 update till GPT LVM physical volume and MBR LVM physical volume are added. And UUID of LVM depends on environment.
  • (3) Run grub-install when LVM physical volume is added.