2

Is it possible to boot from a system where /boot is located within an lvm2 raid1 partition. I've tried a variety of configurations, but I have yet to discover how to do it.

I am using two 2TB disks. Each disk contains a GPT partition table with a 1MB bios_grub partition and a 2TB partition. The large 2TB partition on each disk is allocated as a physical volume to lvm2.

I am using Ubuntu 14.04 LTS as my OS. Initially I configured Ubuntu with two 5GB logical volumes. The first one for / and the second for /home. The Ubuntu setup did not have options to configure these logical volumes with a segment type of raid1. So, I just installed it with what it defaulted to, which was linear. This worked fine and the system booted without any issues.

I then rebooted into a live CD environment, and converted the two partitions into raid1 with the following commands.

lvconvert --type raid1 -m1 /dev/vg_storage/os_root lvconvert --type raid1 -m1 /dev/vg_storage/os_home 

These operations completed without any errors. I then monitored the progress of lvm2 mirroring both of these logical volumes until copy% was 100%

root@ubuntu:~# lvs LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert os_home vg_storage rwi-a-r-- 4.66g 100.00 os_root vg_storage rwi-a-r-- 4.66g 100.00 

Now the system fails to boot. I get the following error immediately after BIOS attempts to boot from the first of the two disks. And I am left with a grub rescue prompt.

error: disk 'lvmid/L1VIor-PKIM-mtCO-TUQ2-iWe2-ndnY-df2wOu/yCDXMZ-2q4X-jbJJ-qZhI-sHNL-hrjw-Q5bg6v' not found. Entering rescue mode... grub rescue> 

I'm thinking there is a grub2 module that isn't being loaded. One that supports the raid1 functionality of lvm2. Either that or such support does not yet exist within grub2.

1 Answer 1

2

Four years go by and...

yes, boot from mirrored LVM volume (lvconvert -m1 /dev/vg0/root) works for us in Debian 9 (stretch). GRUB lvm.mod module understands mirrored LVM volumes out of box, GRUB successfully reads /boot/grub/grub.cfg which resides on the mirrored root volume, presents the boot menu, loads the kernel and initrd. Then the kernel gets stuck, unable to mount LVM root:

device-mapper: table: 254:5: raid: Failed to run raid array device-mapper: reload ioctl on (254:5) failed: Invalid argument 

This is solved by adding the following modules to /etc/initramfs-tools/modules (order matters), and running update-initramfs:

xor async_tx raid6_pq async_xor async_pq async_memcpy async_raid6_recov md_mod raid1 raid456 dm_raid dm_log dm_region_hash dm_mirror lvm 

(probably one can leave out raid6_pq, async_raid6_recov, raid456 -- I cannot verify right now).

Now the mirrored LVM root should mount OK. The final step is to make both physical disks bootable, so should any one of them fail, the other will still boot the system:

pvdisplay -m | egrep 'PV Name|_rimage_' # find out which physical disks root lv resides on grub-install /dev/firstdisk grub-install /dev/seconddisk 
6
  • I have Linux 4.15 and tried that and it did not work any better. According to the lvm2 people, the dependencies on lvm are now correct. From one comment in bugs.debian.org/cgi-bin/bugreport.cgi?bug=804629 it looks like an old partition newly converted to raid1 will not work, you have to keep it as mirror. Unfortunate. Commented Jan 20, 2020 at 21:45
  • Our setup works with kernel version 4.19.0-0.bpo.1-amd64, grub 2.02~beta3-5+deb9u1, lvm 2.02.168-2. What are the versions on your system? What error messages do you get? Commented Jan 22, 2020 at 6:16
  • I've the latest Ubuntu 18.04 (4.15.0-72-generic #81-Ubuntu). I've seen some posts saying that 4.9 and newer work like a charm. But that would be when you install everything from scratch. I kept my existing LVM, only reformatted root (/) so that I could keep /home. The error is initrd fails to recognize / when setup as raid1. I actually had to reinstall the OS with mirror to make it work (just converting back to mirror didn't work—I also tried to reinstall the OS twice on the raid1 partition and it did not work, update-grub failed.) Commented Jan 22, 2020 at 17:38
  • If you quoted the exact error message you get, it might help to understand the problem. Do I get it right that your /boot/grub is on raid1? Commented Jan 24, 2020 at 13:22
  • Yes, as a result of my upgrade the /boot folder is on raid1. Before I had a separate partition, but it was really small so I decided not to use it. I won't try again I already spent enough time on it. But grub is capable to load the initrd. That when initrd is having a hard time mounting the raid1 partition. It gave me a prompt in the initrd shell and I could even use ls to see files. From there, I just couldn't access / (which I can access from grub). Commented Jan 24, 2020 at 17:31

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.