Debian – Does GRUB2 support /boot on LVM on MD-raid

debiangrub2lvmmdadm

What are the known supported (and unsupported) features for the GRUB2 lvm module in Debian 9? E.g. does it support the current metadata format "lvm2"?

Is there some extra command or configuration required to access LVM logical volumes from GRUB, even after loading the GRUB lvm module?

GRUB appears to support MD-raid, but what about when LVM is running on top of MD-raid, does it affect the above questions somehow? Is grub2-mkconfig expected to support /boot on MD+LVM?

Context

I need to migrate files from one existing disk into the RAID, so I'm not using the installer to set things up. This is for Debian Stretch. The general idea is

  1. copy your existing system to a degraded RAID on the new disk
  2. boot the RAID system
  3. very carefully double-check and then have the RAID swallow the old disk.

I'm aware this isn't necessarily the most sensible of ideas.

I'm looking at booting from LVM on MD-raid. I won't bother faffing with /boot as a separate MD-raid partition, if I don't need to. It looked like this is what the Debian installer was being used to do in https://wiki.debian.org/DebianInstaller/SoftwareRaidRoot

I created an LV on top of MD-raid, and copied the root filesystem to it. But unlike the pure MD-raid setup described on the RAID wiki, grub-mkconfig did not find the new Linux instance.

I booted to the GRUB prompt of the original Linux instance, to see what it could do. I can load the part_gpt, mdraid1x, and lvm modules. There is no lvm2 module. This successfully found devices for my GPT partitions, and the MD device (md/linux) I had created. But it did not find any of the LVM devices I had created, which should have looked like (lvm/vg_linux/lv_root).

The probe command does not work at all on either (hd1,gpt1) or (md/linux); it just says error: unknown filesystem. So it's not capable of identifying the MD-raid, let alone the LVM stuff, even though GRUB is already accessing the MD-raid.

Best Answer

GRUB2 on Debian 9 is definitely able to read from a normal ("linear") LVM2 volume on MD raid1 (metadata v1.2). However I found this only seems to work if you do insmod lvm before insmod mdraid1x.

If I load them in the opposite order, it changes the order of the devices shown by the GRUB ls command (!), but it does not add the lvm devices to the list.

Standard automatic configuration

To get grub-mkconfig (which is the backend for Debian's update-grub) to detect the second Linux instance as suggested on the RAID wiki page, it sufficed to install the os-prober package. (I expect the Debian installer would have installed this package automatically, if it had seen a second OS when it originally installed the boot loader. Particularly if there was a Windows install).

Interestingly, the generated config loaded lvm after mdraid1x. However it also loaded diskfilter before mdraid1x. It also used the hidden lvmid/... path instead of (lvm/...). For the sake of our sanity, let us ignore the latter difference, and imagine that the early diskfilter load is probably what lets this config work :).

I'm not sure where you're expected to learn either of these methods :-/.

Related Question