The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
# ExamplesDEVICE=/dev/sda
NAME=arr1
# Setup encryption
cryptsetup--typeluks2-vluksFormat"${DEVICE}"# Open encrypted drive to /dev/mapper/$NAME
cryptsetupopen"${DEVICE}""${NAME}"# Create a partition
mkfs.btrfs/dev/mapper/${NAME}# Create a mountpoint and mount
mkdir-p/media/${NAME}
mount-tbtrfs/dev/mapper/${NAME}/media/${NAME}# Fill the drive to overwrite any existing raw data (optional)
ddif=/dev/zeroof=/media/$NAME/filestatus=progress
Mounting
# Open the encrypted drive
cryptsetupopen"${DEVICE}""${NAME}"# Mount your partition
mount-tbtrfs/dev/mapper/${NAME}"${MOUNT_LOCATION}"
Unmounting
# Unmount your partition
umount"${MOUNT_LOCATION}"# Close the decrypted drive
cryptsetupclose${NAME}
luks defaults to luks1 on cryptsetup < 2.1.0, luks2 on cryptsetup >= 2.1.0
luks1 is the old version of LUKS.
luks2 is the current version released in Dec 2017. Older versions of Grub (before 2.06 or June 2020) do not support booting from LUKS2.
plain is dm-crypt plain mode. Avoid this unless you know what you're doing.
loopaes Avoid this as well.
tcrypt Use this for mounting older truecrypt volumes.
--iter-time dynamically determines the number of iterations used to hash your password. The number of iterations is determined when creating the luks key. E.g. 5000 means hash for 5 seconds worth of iterations on your particular CPU. You can see the number of iterations for each key with cryptsetup luksDump <device>.
# Tests are approximate using memory only (no storage IO).
PBKDF2-sha1 3057072 iterations per second for 256-bit key
PBKDF2-sha256 6452775 iterations per second for 256-bit key
PBKDF2-sha512 2432890 iterations per second for 256-bit key
PBKDF2-ripemd160 1289761 iterations per second for 256-bit key
PBKDF2-whirlpool 1148495 iterations per second for 256-bit key
argon2i 13 iterations, 1048576 memory, 4 parallel threads (CPUs) for 256-bit key (requested 2000 ms time)
argon2id 13 iterations, 1048576 memory, 4 parallel threads (CPUs) for 256-bit key (requested 2000 ms time)
# Algorithm | Key | Encryption | Decryption
aes-cbc 128b 1976.6 MiB/s 7781.1 MiB/s
serpent-cbc 128b 136.8 MiB/s 993.0 MiB/s
twofish-cbc 128b 291.3 MiB/s 646.8 MiB/s
aes-cbc 256b 1507.6 MiB/s 6406.3 MiB/s
serpent-cbc 256b 138.2 MiB/s 984.0 MiB/s
twofish-cbc 256b 295.3 MiB/s 647.1 MiB/s
aes-xts 256b 6021.9 MiB/s 5909.9 MiB/s
serpent-xts 256b 855.7 MiB/s 887.4 MiB/s
twofish-xts 256b 597.8 MiB/s 608.0 MiB/s
aes-xts 512b 5521.2 MiB/s 5505.7 MiB/s
serpent-xts 512b 870.2 MiB/s 897.9 MiB/s
twofish-xts 512b 602.9 MiB/s 607.1 MiB/s
Adiantum
If you're running a device which does not support hardware accelerated AES instructions (e.g. Raspberry Pi), you may be interested in Adiantum[1].
Adiantum is an encryption mode by Google which uses ChaCha12 for block encryption.
It is included in Linux kernel v5.0.