Skip to content

Instantly share code, notes, and snippets.

@adrianbiro
Last active September 16, 2022 07:31
Show Gist options
  • Save adrianbiro/5b3c10551eba0cd1a79c89180ca41937 to your computer and use it in GitHub Desktop.
Save adrianbiro/5b3c10551eba0cd1a79c89180ca41937 to your computer and use it in GitHub Desktop.
Extend LVM LUKS

Extend LVM LUKS

link

LVM

$ lsblk
$ wipefs -a /dev/sdb
  # quick wipe target device
$ pvcreate /dev/sdb
$ pvs
$ vgs
$ vgextend ubuntu-vg /dev/sdb
$ vgs
$ lvs
$ lvcreate -n secret -L 10G ubuntu-vg
$ lvs

LUKS init

$ cryptsetup luksFormat /dev/ubuntu-vg/secret
  # take a time
$ cryptsetup luksOpen /dev/ubuntu-vg/secret secret
  # heslo
$ mkfs.ext4 /dev/mapper/secret
$ mkdir /secret # on / not /mnt/
$ mount /dev/mapper/secret /secret/
$ mount | grep secret

resize LUKS

$ df -h /secret/
$ blkid -t TYPE=crypto_LUKS -o device
  # to list LUKS devices
$ cryptsetup status secret
$ umount /secret
$ cryptsetup luksClose secret
$ lvextend -L +10G /dev/ubuntu-vg/secret
$ lvs
$ cryptsetup luksOpen /dev/ubuntu-vg/secret secret
  # heslo
$ cryptsetup status secret

test

$ e2fsck -f /dev/mapper/secret
$ resize2fs -p /dev/mapper/secret
$ mount /dev/mapper/secret /secret/
$ df -h /secret/

Backup

fsarchiver or just rsync -rauvlPL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment