Simple File System Encryption

It's soooo easy to "misplace" your removable drive, so encrypting it is a good way to help protect your data should it be lost :)

In this example, I will be using a USB2 2Gb flash drive.

The first port of call is to ensure you have the DEVICE_MAPPER driver compiled into the kernel.  If you're using a binary distro, this almost certainly is already present.

Device Drivers ->
Multiple devices driver support (RAID and LVM) ->
Device mapper support
Crypt target support

Also ensure you have compiled the required encryption...

Cryptographic API -> (both options below are the default encryption used)
AES cipher algorithms (x86_64)  <---- only available on 64bit OS
AES cipher algorithms (AES-NI)

Now insert your drive then run the following commands:

cryptsetup -y luksFormat /dev/sdX# (whatever your node is)
cryptsetup luksOpen /dev/sdX# <name>  <-- this opens the encrypted device ready for mounting.  The new device will now exist under /dev/mapper/<name>
mke2fs -j -L <name> /dev/mapper/<name>  <-- formats the partition
cryptsetup luksClose /dev/mapper/<name>  <-- unmounts the encryption

You can now unmount the drive and test it by re-inserting it.  Your GUI should prompt you for the passphrase if all has worked ok.

If you need to mount from the cli do the following:

cryptsetup luksOpen /dev/sdX# <name>
mount /dev/mapper/<name> /mnt/usb/

To unmount from the cli do the following:

cryptsetup luksClose /dev/mapper/<name>
umount /dev/mapper/<name>

That's it... simple :)