Pages

Thursday, October 5, 2017

Encrypted Storage Disk On Ubuntu

I decided to install a USB disk with encryption. There were many tutorials about encrypted partitions. I thought it is neater to simply encrypt the whole disk.

I used an old USB3 HDD which I had laying around. It was actually rather simple. My USB drive appeared as /dev/sdd It is possible to zerofill the drive before doing this. However I did not have sensitive data in the drive previously so I am not worried about people recovering random stuff from there . So I saved some time by skipping that step. You have to run the commands below as root user or use sudo

# apt-get install cryptsetup

The commands below will create an encrypted filesystem using the whole /dev/sdd disk. You won't be able to create partitions in it. But you can use that one encrypted filesystem inside it.

# cryptsetup -v luksFormat /dev/sdd
# cryptsetup luksOpen /dev/sdd usbdrive
# mkfs -t ext4 /dev/mapper/usbdrive

After mounting it to /mnt we can access it like any other disk.

# mount /dev/mapper/usbdrive /mnt

Here is how you close/lock it again. You should umount it first

# umount /mnt
# cryptsetup luksClose usbdrive

No comments:

Post a Comment