root-on-LVM2 with Gentoo

For various reasons I had to reinstall my home desktop, this time using Gentoo Linux.

My desktop systems usually have their root-fs on an LVM2 volume. Alas, such a setup is not covered in the Gentoo Installation Guide. Here are the details:

Setting up root-on-LVM2 with Gentoo

Fact: root-on-LVM2 needs an initramfs to work.

Therefore:

  • emerge lvm2 in your chroot before doing any kernel work.
  • Setup LVM2 as usual (create type 8e PV partitions, pvcreate them, vgcreate, lvcreate, mkfs)
  • Use genkernel --lvm to build your kernel.
  • Specify root=/dev/mapper/VGNAME-LVNAME and dolvm on the kernel command line.

You may need to set these things in your kernel config, too:

  • Disable asynchronous SCSI device scanning
  • Build SCSI/SATA device drivers into your kernel
  • Build device mapper as a module

(These last things are what I did, without testing other options.)

If the initramfs complains about not finding your root-LV, check that there is an /etc/lvm/lvm.conf inside the initramfs. Else, pvscan/vgscan will scan no devices for PVs/VGs.