LVM volume is inactive after reboot of CentOS

I did it! I did it! I fixed it properly (I think).

Here's the story:

After some time the server turned out to be faulty and had to be scrapped. I kept disks and got everything else new. Then I reinstalled CentOS again on the SSD and then I attached the HDDs. LVM worked nicely, the disks were recognized, the configuration kept. But the same problem came up again - after a reboot, the volume was inactive.

However this time I chanced to notice something else - the bootloader passes the following parameters to the kernel:

crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet

Hmm, wait a minute, those look FAMILIAR!

Quick google query, and there we are:

rd.lvm.lv=

only activate the logical volumes with the given name. rd.lvm.lv can be specified multiple times on the kernel command line.

Well now. THAT explains it!

So, the resolution was (gathered from several more google queries):

  1. Modify /etc/defaults/grub to include the additional volume in the parameters: crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rd.lvm.lv=vg_home/lv_home rhgb quiet
  2. Reconfigure grub with grub2-mkconfig -o /boot/grub2/grub.cfg
  3. Reconfigure initramfs with mkinitrd -f -v /boot/initramfs-3.10.0-327.18.2.el7.x86_64.img 3.10.0-327.18.2.el7.x86_64. Note: your values may vary. Use uname -r to get that kernel version. Or just read up on mkinitrd. (Frankly, I don't know why this step is needed, but apparently it is - I tried without it and it didn't work)
  4. And finally, reinstall grub: grub2-install /dev/sda
  5. Reboot, naturally.

TA-DA! The volume is active on reboot. Add it to fstab and enjoy! :)


Minor update (for RHEL 7 on EFI (non-BIOS) machine):

I've got to success using these steps:

  1. Modify /etc/defaults/grub to include the additional volume in the parameters: rd.lvm.lv=rhel/home (in addition to rhel/root and rhel/swap)
  2. Reconfigure grub with

    grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
    

    (note: another path!)

  3. Reconfigure initramfs with

    mkinitrd -f -v /boot/initramfs-$(uname -r).img $(uname -r)
    
  4. Skip reinstall grub: grub2-install /dev/sda (because I have an empty dir /usr/lib/grub/)
  5. Reboot, naturally.

Tags:

Rhel

Centos

Lvm