1

I've tried installing Elementary OS with a custom partition scheme, using both LVM and Luks, but after the installation I can't log into the system: the kernel boots but cannot mount the encrypted root partition. It fails with:

WARNING: Failed to connect to lvmetad. Falling back to device scanning.
Volume group "elementary-vg" not found
Cannot process volume group elementary-vg

This is the way I performed the custom partition scheme. I booted Elementary OS from an USB pen, launched gparted and created the following partitions:

/dev/sda1   efi         fat32     512MB (boot, esp)
/dev/sda2   boot        ext4      732MB
/dev/sda3   not mapped          10240MB 
/dev/sda4   luks        remaining space

Then with a command line:

# cryptsetup luksFormat --hash=sha256 --key-size=512 --cipher=aes-xts-plain64 --verify-passphrase /dev/sda4
# cryptsetup luksOpen /dev/sda4 elementary
# pvcreate /dev/mapper/elementary
# vgcreate elementary-vg /dev/mapper/elementary
# lvcreate -n root -L 32G elementary-vg
# lvcreate -n swap_1 -L 12G elementary-vg
# lvcreate -n users -l +100%FREE elementary-vg
# vgscan

Then I launched the installer and used the "Something else" option for the disk. I mapped the existing partitions as follows:

/dev/sda1                            efi
/dev/sda2                            ext4    /boot           format
/dev/mapper/elementary-vg--root      ext4    /               format
/dev/mapper/elementary-vg--swap      swap    
/dev/mapper/elementary-vg--users     ext4    /media/users    format

The installation correctly completes, as I said, but it fails at the next reboot.

I even logged in with the USB key, ran the usual stuff for chrooting into the installation and performed and apt update; apt dist-upgrade. It went fine, updated the initramfs and grub, but didn't fix the problem.

The Luks setup seems fine, in fact if I enter the grub command line I can manually mount the encrypted root:

grub> insmod luks
grub> cryptomount hd0,gpt4
grub> insmod lvm
grub> ls

and I can see the logical volumes.

Please suggest what I should do to fix the existing installation. Thanks.

0

Ok, it seems I've found the solution, but I'd like to see some confirmation because all this stuff seems complex and I see that has been changed multiple times with recent updates of Linux.

I understood that a file /etc/crypttab must exist and enumerate the devices to be unlocked at boot. Giving a custom partition scheme, the Elementary installer didn't create it.

So I booted again from the USB key and chrooted into the system. For the convenience of other users with similar problems I'm providing the steps:

# cryptsetup open /dev/sda4 elementary
# vgscan
# vgchange -ay
# lvscan
# mkdir /mnt/system
# mount /dev/mapper/elementary--vg-root /mnt/system/
# mount /dev/sda2 /mnt/system/boot/                        
# mount -o bind /dev/ /mnt/system/dev/
# mount -o bind /proc/ /mnt/system/proc/
# mount -o bind /sys/ /mnt/system/sys/
# chroot /mnt/system

Then I got the luks UUID of the device:

# cryptsetup luksDump /dev/sda4 | grep UUID

and then created /etc/crypttab with:

elementary  UUID=<uuid> none    luks

At last I ran:

# initramfs -u -k all

and at this point the system booted fine, asking for the password and mounting the encrypted device at boot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.