Encrypt your drive with cryptsetup in linux

I prefer to encrypt all my external hard drives and usb sticks. One way to do this is with cryptsetup. Below I added instructions how to encrypt your drive. Suppose you have a partition on your drive at /dev/sdb1.

  1. Install cryptosetup, in ubuntu run sudo apt install cryptsetup.
  2. Encrypt the partition:
    sudo cryptsetup -v --verify-passphrase luksFormat /dev/sdb1
  3. Open then encrypted partition:
    sudo cryptsetup luksOpen /dev/sdb1 crypted-partition

    The partition can be found in /dev/mapper/encrypted-partition.

  4. Create your favorite filesystem on the the encrypted partition. I install the ext4 filesystem.
    sudo mkfs.ext4 -L label-name /dev/mapper/encrypted-partition
  5. Close the encrypted partition:
    sudo cryptsetup luksClose /dev/mapper/encrypted-partition

Done!

Leave a Reply

Your email address will not be published. Required fields are marked *