uniq_

encrypted partion on debian 8

Encrypting partitions is fun, but also a bit unintuitive.

# install dependencies
sudo apt-get install cryptsetup

# setup luks on desired partition
sudo cryptsetup -y -v luksFormat /dev/sdb1

# init mapper device (and persist this setting)
sudo cryptsetup luksOpen /dev/sdb1 sdb1_crypt
sudo sh -c 'echo "sdb1_crypt /dev/sdb1 none luks" >> /etc/crypttab'

# format block device
sudo mkfs.ext4 /dev/mapper/sdb1_crypt

# add device to fstab
sudo mkdir /mountpoint
sudo sh -c 'echo "/dev/mapper/sdb1_crypt /mountpoint ext4 defaults 0 1" >> /etc/fstab'

# mount
sudo mount /mountpoint

sources:

written by uniq on 2016-04-22