Sunday, May 22, 2016

[Tutorial] How to resize (bigger) an LVM volume with an encrypted partition used by a VM

Here the version if your crypt device is sitting in a partition as in:

 xvdb                         202:16  0 550G 0 disk   
 --xvdb1                       202:17  0 550G 0 part   
 --luks-1d3d064f-7e4e-4653-99c1-0ef41f213819 (dm-0) 253:0  0 550G 0 crypt   

On Host
#extend to the FINAL size, if you want to add use +, see lvextend man
lvextend -L200G /dev/VGStorage/lvm-test-storage
On VM
umount /opt
cryptsetup luksHeaderBackup /dev/xvdb1 --header-backup-file /root/luksheader
cryptsetup luksClose luks-2892b120-247f-4e7f-834b-816cfb8baf68
fdisk -u /dev/xvdb
d
n
p
1
First Sector: 2048
Last Sector default
w
cat /proc/partitions, confirm number of blocks in partition as given by fdisk
cryptsetup luksOpen /dev/xvdb1 luks-2892b120-247f-4e7f-834b-816cfb8baf68
cryptsetup resize luks-2892b120-247f-4e7f-834b-816cfb8baf68
e2fsck -f /dev/mapper/luks-2892b120-247f-4e7f-834b-816cfb8baf68
resize2fs /dev/mapper/luks-2892b120-247f-4e7f-834b-816cfb8baf68

No comments:

Post a Comment