Extend a LUKS encrypted partition to fill disk

OK! The definitive answer finally. My steps to expand a LUKS encrypted volume...

  1. cryptsetup luksOpen /dev/sda2 crypt-volume to open the encrypted volume.
  2. parted /dev/sda to extend the partition. resizepart NUMBER END.
  3. vgchange -a n fedora_chocbar. Stop using the VG so you can do the next step.
  4. cryptsetup luksClose crypt-volume. Close the encrypted volume for the next steps.
  5. cryptsetup luksOpen /dev/sda2 crypt-volume. Open it again.
  6. cryptsetup resize crypt-volume. Will automatically resize the LUKS volume to the available space.
  7. vgchange -a y fedora_chocbar. Activate the VG.
  8. pvresize /dev/mapper/crypt-volume. Resize the PV.
  9. lvresize -l+100%FREE /dev/fedora_chocbar/home. Resize the LV for /home to 100% of the free space.
  10. e2fsck -f /dev/mapper/fedora_chocbar-home. Throw some fsck magic at the resized fs.
  11. 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, execute

    sudo 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)!