N. P. O'Donnell, 2021
Before you do anything, ensure you have cryptsetup
installed:
sudo apt-get install -y cryptsetup
Make sure you choose the correct disk:
lsblk
#!/usr/bin/env bash
DEVICE=sdx
NAME=storage
sudo cryptsetup -y -v luksFormat /dev/$DEVICE
sudo cryptsetup luksOpen /dev/$DEVICE $NAME
sudo cryptsetup config /dev/$DEVICE --label $NAME
sudo dd if=/dev/urandom of=/dev/mapper/$NAME bs=8M status=progress
sudo mkfs.ext4 /dev/mapper/$NAME
sudo e2label /dev/mapper/$NAME $NAME
Unlock / Map:
sudo cryptsetup luksOpen /dev/$DEVICE $NAME
Enter passphrase when prompted.
Mount:
sudo mkdir -p /mnt/$NAME
sudo mount /dev/mapper/$NAME /mnt/$NAME
sudo chmod 777 /mnt/$NAME
Unmount:
cd
sudo umount /mnt/$NAME