How to properly add second LUKS LVM partition to root volume

asked 2017-05-10 01:38:35 -0500

calm gravatar image

I have dual boot laptop with Windows and Fedora 25. 128 GB SSD is small and now I want to get rid of 20 GB Windows recovery partition and add that space to be used in Fedora root partition. Fedora is installed encrypted with default LVM on LUKS. So what I want now to do is take that recovery partition to be part of the existing LVM root volume and be encrypted the same way as the original installation. To enable that,

# write LUKS headers to the new partition
cryptsetup luksFormat /dev/sda6
# Get UUID from LUKS partition to be added to /etc/crypttab
cryptsetup luksUUID /dev/sda6
edit /etc/crypttab to contain new LUKS information
# Create new initramfs to make changes boot prone and boot
dracut --force
# Add new LUKS partition to volumegroup
vgextend fedora /dev/mapper/luks-7f3458b5-abfb-4f83-a7ba-eece5fa161e8
# Enlarge root volume to use added pv
lvextend -l 100%FREE /dev/mapper/fedora-root
# Enlarge root fs to use the new space in the volume
resize2fs /dev/mapper/fedora-root
# Create new initramfs to make changes boot prone (this is the step that is missing something)
dracut --force

At this point everything works fine. Root has the new space in use and everything is fine. But when the machine is rebooted, the new LUKS partition is still not available to be part of the LVM at boot stage and there are Buffer I/O errors from missing disk. If machine manages to boot up anyway, then LUKS partition is visible and part of the LVM as it should be. So, what is the thing I'm missing from this procedure?

I haven't yet broken my laptop installation but just played with virtual machine with the same setup. It seems that the thing needed is to add grub.cfg rd.luks.uuid=luks-new-uuid to kernel parameters to get the new partition available at boot time, but I guess there should be some automated way get this included so that it remains over kernel updates and such?

Disk setup:

# lsblk
NAME                                       MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                                          8:0    0 119,2G  0 disk
├─sda4                                       8:4    0  57,6G  0 part
├─sda2                                       8:2    0   900M  0 part
├─sda7                                       8:7    0   500M  0 part  /boot
├─sda5                                       8:5    0     8G  0 part
├─sda3                                       8:3    0   128M  0 part
├─sda1                                       8:1    0   100M  0 part  /boot/efi
├─sda8                                       8:8    0    32G  0 part
│ └─luks-bef322fd-c63b-4e5a-bada-f5e6fe925122
│   253:0    0    32G  0 crypt
│   ├─fedora-swap                          253:1    0   7,8G  0 lvm   [SWAP]
│   └─fedora-root                          253:2    0  44,3G  0 lvm   /
└─sda6                                       8:6    0    20G  0 part
    253:3    0    20G  0 crypt
    └─fedora-root                          253:2    0  44,3G  0 lvm   /
edit retag flag offensive close merge delete


No clue what's wrong here, just a thought: small SSD, need more space? Get rid of your 8G swap and create a swapfile(s) (of the size you need)

florian gravatar imageflorian ( 2017-05-10 08:41:24 -0500 )edit

Yes, that is actually ridiculously big. Just the default from the installer. I doubt it's never been used at all..

calm gravatar imagecalm ( 2017-05-10 23:43:13 -0500 )edit

Actually, I ran a in very similar this week, except that I was not adding the LUKS volume to the root partition.

janvlug gravatar imagejanvlug ( 2018-08-29 12:59:06 -0500 )edit