Encrypted External Drive

First, let’s grab the packages.

apt-get install cryptsetup

Then, let’s enable the modules.

modprobe dm-crypt
modprobe aes

Next, let’s use badblocks to identify bad sectors and overwrite the disk with random data at the same time (this took about 10 hours on my 640GB drive).

badblocks -c 10240 -s -w -t random -v /dev/sdg

When that’s done, you’ll want to add a filesystem to the drive

fdisk /dev/sdg

Next, let’s LUKS encrypt the drive.

cryptsetup --hash sha512 --key-size 256 --cipher aes-cbc-essiv:sha256 luksFormat /dev/sdg1

You’ll need to answer YES to the question in all caps to create the encrypted partition. Then, you’ll want to mount the volume.

cryptsetup luksOpen /dev/sdg1 securebackup

This will open the volume at /dev/mapper/securebackup. Next, we need to put a filesystem on the encrypted partition.

mkfs.ext4 -m 1 -O dir_index,filetype /dev/mapper/securebackup

Once that’s done, you are ready to mount the encrypted partition to write to it.

mkdir -p /media/securebackup
mount /dev/mapper/securebackup /media/securebackup/

When you are done working on your encrypted volume, you’ll want to unmount it, and then close the LUKS encrypted volume like this.

umount /media/securebackup/
cryptsetup luksClose /dev/mapper/securebackup

And, there are the simple steps to an encrypted backup disk.


I love learning new things and trying out the latest technology.

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.