Extend a LUKS encrypted partition to fill disk
OK! The definitive answer finally. My steps to expand a LUKS encrypted volume...
cryptsetup luksOpen /dev/sda2 crypt-volume
to open the encrypted volume.parted /dev/sda
to extend the partition.resizepart NUMBER END
.vgchange -a n fedora_chocbar
. Stop using the VG so you can do the next step.cryptsetup luksClose crypt-volume
. Close the encrypted volume for the next steps.cryptsetup luksOpen /dev/sda2 crypt-volume
. Open it again.cryptsetup resize crypt-volume
. Will automatically resize the LUKS volume to the available space.vgchange -a y fedora_chocbar
. Activate the VG.pvresize /dev/mapper/crypt-volume
. Resize the PV.lvresize -l+100%FREE /dev/fedora_chocbar/home
. Resize the LV for /home to 100% of the free space.e2fsck -f /dev/mapper/fedora_chocbar-home
. Throw some fsck magic at the resized fs.resize2fs /dev/mapper/fedora_chocbar-home
. Resize the filesystem in /home (automatically uses 100% free space)
I hope someone else finds this useful. I now have 300+GB for my test VMs on my laptop!
For those that come to the answer to find out how to simply resize a LUKS partition to the size of the resized container, the commands are as follows:
with LUKS encrypted volume opened and the opened volume mapped as
opened-volume
, executesudo cryptsetup resize /dev/mapper/opened-volume
then resize the file system. If it is Ext4, you can resize a mounted file system
sudo resize2fs /dev/mapper/opened-volume
I did both commands with a mounted file system with no interruption; it was possible to resize the container without unmounting it first because the encrypted volume was on a LVM logical volume (using lvresize
)!