Creating a LUKS container on an LVM volume


Install the necessary packages

apt install cryptsetup

Create a volume group and a logical volume

vgcreate vg /dev/sdb
lvcreate --extents 100%FREE vg --name lv

Initialize a container

cryptsetup --verbose --verify-passphrase luksFormat --type luks2 /dev/vg/lv

Open the container

cryptsetup open /dev/vg/lv data

Create a filesystem in the container

mkfs -t xfs /dev/mapper/data

Mount the filesystem

mount /dev/mapper/data /mnt

Create a header backup

cryptsetup luksHeaderBackup /dev/vg/lv --header-backup-file /root/header.luks

Leave a Reply