Example 1: Create LUKS 2 container on block device /dev/sdX.
sudo cryptsetup --type luks2 luksFormat /dev/sdX
Example 2: Add an additional passphrase to key slot 5.
sudo cryptsetup luksAddKey --key-slot 5 /dev/sdX
Example 3: Create LUKS header backup and save it to file.
sudo cryptsetup luksHeaderBackup /dev/sdX --header-backup-
file /var/tmp/NameOfBackupFile
Example 4: Open LUKS contaner on /dev/sdX and map it to
sdX_crypt.
sudo cryptsetup open /dev/sdX sdX_crypt
WARNING: The command in example 5 will erase all key slots.
Your cannot use your luks container afterwards anymore
unless you have a backup to restore.
Example 5: Erase all key slots on /dev/sdX.
sudo cryptsetup erase /dev/sdX
Example 6: Restore LUKS header from backup file.
sudo cryptsetup luksHeaderRestore /dev/sdX --header-
backup-file /var/tmp/NameOfBackupFile