xbsd.nl

Resize an encrypted LVM logical volume

13 Mar 2012

Recently I had the challenge to resize an (dm-crypt, cryptsetup) encrypted LVM Logical Volume on Linux. While resizing a 'plain' Logical Volumes can't get any easier, resizing an encrypted volumes involves a couple of more actions. Also, in contrast to un-encrypted Logical Volumes, the resizing of an encrypted volume can't be done online - at certain moments an unmount is required. These are the steps that worked out successfully for me; YMMV :) First step - Determine the volume to be resized:
[root]# mount
(..)
/dev/mapper/crypt_srv on /srv type ext4 (rw)
Stop related services, unmount the mount point and run a filesystem check:
[root]# umount /srv
[root]# fsck.ext4 /dev/mapper/crypt_srv
Close the volume in dm-crypt:
[root]# cryptsetup luksClose /dev/mapper/crypt_srv
Perform the extend:
[root]# lvextend -l +1024 /dev/mapper/vg00-lv_srv
Re-open the volume in dm-crypt and make dm-crypt aware of the new blocks:
[root]# cryptsetup luksOpen /dev/mapper/vg00-lv_srv crypt_srv
[root]# cryptsetup --verbose resize crypt_srv
Check if it is possible to mount the volume, unmount again and perform a filesystem check:
[root]# mount /dev/mapper/crypt_srv /srv/
[root]# umount /srv
[root]# e2fsck -f /dev/mapper/crypt_srv
Now resize the filesystem itself (can also be done online), and mount the resized filesystem:
[root]# resize2fs /dev/mapper/crypt_srv
[root]# mount /dev/mapper/crypt_srv /srv
That's all there is to it! Drop a comment to let me know how it worked out for you!

blog comments powered by Disqus