Skip to content

Luks cheatsheet

Basic usage

Create a LUKS volume

cryptsetup --verify-passphrase luksFormat /dev/sdx

Open a LUKS volume

cryptsetup luksOpen /dev/sdx backup

Mount

mount /dev/mapper/backup /backup

Unmount

umount /backup
cryptsetup luksClose backup

Create encrypted file container

Create file (4 GB)

dd if=/dev/urandom of=container.img bs=1M count=4096

Create a LUKS volume

cryptsetup --verify-passphrase luksFormat container.img

Open a LUKS volume

cryptsetup luksOpen ./container.img container

Verify, that LUKS volume was opened

ls /dev/mapper/

Create a filesystem

mkfs.ext4 /dev/mapper/container

Mount a filesystem

sudo mount /dev/mapper/container /mnt