Resizing a LUKS encrypted volume

LUKS doesn’t actually store the size of the device — it simply discovers it when the volume is opened. It therefore only comes into play if the volume is not closed and reopened during the process (e.g. doing an online grow). In this case the size of the open volume needs to be rediscovered.

To shrink your volume, use the following process:

  1. Unmount the filesystem with umount
  2. Resize the filesystem with resize2fs
  3. Close the LUKS volume with cryptsetup luksClose
  4. Resize the LV with lvreduce or lvresize
  5. Open the LUKS volume with cryptsetup luksOpen
  6. Mount the filesystem with mount

You could also omit the luksClose and luksOpen steps, and use cryptsetup resize after resizing the LV. Also remember that LUKS uses some extra space to store metadata, so the LV needs to be slightly bigger than the filesystem. I usually resize the filesystem significantly smaller, and then grow it again after resizing the LV.

If you were growing the filesystem and wanted to do it online, you would use the following process:

  1. Resize the LV with lvextend or lvresize
  2. Update the size of the open LUKS volume with cryptsetup resize
  3. Grow the filesystem with resize2fs

Leave a Comment