Cryptsetup LUKS

using cryptsetup to create a LUKS encrypted volume

Enter the values for the following fields:


# be root
df -h

apt install cryptsetup

# create a LUKS encrypted volume
cryptsetup -v --type luks2 --label $luks_label luksFormat $disk_path

# open the encrypted volume
cryptsetup luksOpen $disk_path $cryptsetup_name
ls -la /dev/mapper/$cryptsetup_name
cryptsetup -v status $cryptsetup_name

# create a filesystem
dd if=/dev/zero of=/dev/mapper/$cryptsetup_name bs=1M status=progress
mkfs.ext4 -L $ext4_label /dev/mapper/$cryptsetup_name

# test mounting
mount /dev/mapper/$cryptsetup_name $mount_point

# unmount and close
umount $mount_point
cryptsetup luksClose $cryptsetup_name