Skip to content

Resizing a LUKS/dm-crypt partition on top of LVM

While there exist a few howtos to resize logical volumes on top of dm-crypt devices, I was looking for information on how to enlarge a dm-crypt device, which is backed by a LVM volume. And I found it, in short:
# umount /dev/mapper/backup
# lvextend -L +10G vg02/backup
  Extending logical volume backup to 40.00 GB
  Logical volume backup successfully resized
# cryptsetup status backup
/dev/mapper/backup is active:
  cipher:  aes-cbc-essiv:sha256
  keysize: 192 bits
  device:  /dev/mapper/vg02-backup
  offset:  1544 sectors
  size:    62913016 sectors
  mode:    read/write
# cryptsetup resize /dev/mapper/backup
# cryptsetup status backup
/dev/mapper/backup is active:
  cipher:  aes-cbc-essiv:sha256
  keysize: 192 bits
  device:  /dev/mapper/vg02-backup
  offset:  1544 sectors
  size:    83884536 sectors
  mode:    read/write

# resize2fs -p /dev/mapper/backup
resize2fs 1.40.8 (13-Mar-2008)
Resizing the filesystem on /dev/mapper/backup to 10485567 (4k) blocks.
Begin pass 1 (max = 80)
Extending the inode table     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/mapper/backup is now 10485567 blocks long.

# fsck.ext3 -Dfv /dev/mapper/backup
[...]
# mount /dev/mapper/backup /mnt/backup/
# df -h /mnt/backup/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/backup     40G   29G  9.7G  75% /mnt/backup

# dpkg -s cryptsetup | grep ^Version
Version: 2:1.0.5-2ubuntu12