Name Drive
- Install
- Find partition name
- Encrypt target partition
cryptsetup --verbose --verify-passphrase luks
- Format /dev/<target partition>
- Open the encrypted partition using the partition path and setting a mapper path cryptsetup
luksOpen /dev/<target partition> <target mount point>
- This will open the partition, and map it to /dev/mapper/<target mount point> Once it has been opened, and mapped, it can then be manipulated through its path in the mapper.
- For a newly encrypted drive Create a file system as normal
mkfs.ext4 /dev/mapper/<target mount point>
- Get rid of reserved space, which isn't needed as the OS isn't running on the partition
tune2fs -m 0 /dev/mapper/<target mount point>
- Mount using the mapper path pointing to a previously created custom mount point
mount /dev/mapper/<target mount point> /custom/mount/point
- Unmount the partition as normal
umount /custom/mount/point
- Close the encrypted partition using the name pointed to when opening
cryptsetup luksClose <target mount point>
- Use a keyfile to allow scripts to mount encrypted partition
mkdir /etc/cryptsetup-keys.d
touch /etc/cryptsetup-key.d/<new keyfile>
- Enter a new passphrase into the key file
printf "A simple passphrase that can be used both interactively, and by a script, because it is stored in new keyfile" > /etc/cryptsetup-key.d/<new keyfile>
chmod 400 /etc/cryptsetup-key.d/<new keyfile>
- Let cryptsetup know about the new keyfile. If it doesn't know about the new keyfile, it will complain "No key available with this passphrase."
cryptsetup luksAddKey /dev/<target partition>