All HowTo's Cybersecurity Linux Redhat, Fedora and CentOS Linux Ubuntu, Mint & Debian Linux

Expand a LUKS Encrypted Volume

This article demonstrates how to extent a LUKS encrypted volume. We’re using Ubuntu 22.04 and the volume is non-root. Although you could probably do the same on the root volume (partition). This is risky and you should not do this without a backup and understanding the likelihood of failure. This article is my notes only.

The disk is “/dev/sdb”. The partition is “/dev/sdb1”. The LUKS volume when decrypted is “/dev/mapper/secure”. We’re not using LVM.

Make sure the kernel knows about the larger disk (assuming you’ve in a VMWare or similar environment):

echo 1>/sys/class/block/sdb/device/rescan

Delete and recreate the partition. This should result in the partition being the maximum size. When asked if you want to re-label the partition, say “no”. You want to keep it as a LUKS partition.

fdisk /dev/sdb

Now resize the LUKS volume. This only works when the LUKS volume is in an “open” state:

cryptsetup resize /dev/mapper/secure

Now extend the filesystem. We’re using EXT4. If you’re using XFS, use “xfs_growfs”:

resize2fs /dev/mapper/secure

Confirm the new disk space is available:

df -h

Now you’re done. The LUKS volume should be the maximum size.

Leave a Reply

Your email address will not be published. Required fields are marked *