Skip to content

Instantly share code, notes, and snippets.

@theodric
Last active April 5, 2024 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theodric/9e10908c393d8905bf1f96906d535f74 to your computer and use it in GitHub Desktop.
Save theodric/9e10908c393d8905bf1f96906d535f74 to your computer and use it in GitHub Desktop.
Resize encrypted LVM
IN SHORT:
0. increase size of outermost container (grow qcow2, dd disk to larger disk, etc.)
1. increase size of partition containing the encrypted volume set (cfdisk, fdisk, etc.)
2. unlock encrypted volume
3. grow LVM "physical volume"
4. grow LVM "logical volume"
5. check filesystem
6. grow filesystem
7. tidy up and test.
Steps on Debian:
[if qemu image, first on host system:]
qemu-img resize diskimage.qcow2 +50G
[then, within liveCD environment]
cfdisk /dev/sda - and grow the partition to fill the larger device
apt update && apt install -y lvm2 cryptsetup
modprobe dm-crypt
cryptsetup luksOpen /dev/sda3 aribtraryname
pvdisplay -m [note your device in the list - must be 'Allocatable: yes' - if not, see next line]
pvchange -x y /dev/mapper/arbitraryname
pvdisplay -m
pvresize /dev/mapper/arbitraryname
vgscan --mknodes
vgchange -ay
lvdisplay [note the names assigned to your volumes]
lvextend -l +100%FREE /dev/somethingelse/volumename
e2fsck -f /dev/somethingelse/volumename
resize2fs /dev/somethingelse/volumename
vgchange -an
cryptsetup luksClose arbitraryname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment