How to Encrypt External Drives with LUKS

This tutorial assumes you sort of know what you’re doing and how to identify the device you wish to encrypt. For simplicity sake we’ll assume in this tutorial you’re encrypting /dev/sdb1 using the handle sdb1_enc and mounting to /mnt/enc.

Install packages

sudo apt install -y cryptsetup

Create a LUKS partition

sudo cryptsetup luksFormat /dev/sdb1

Open the encrypted drive

sudo cryptsetup luksOpen /dev/sdb1 sdb1_enc

Create an ext4 filesystem

sudo mkfs.ext4 /dev/mapper/sdb1_enc -L sdb1_enc

Mount the encrypted drive

sudo mount /dev/mapper/sdb1_enc /mnt/enc

Unmount everything if you wish

sudo umount /mnt/enc && sudo cryptsetup luksClose sdb1_enc