open mind: Create an encrypted disk with Ubuntu
Sunday, November 18, 2007
Create an encrypted disk with Ubuntu
Are you working in a secret project? Writing a book that can't be read until finished? In this post I will explain a simple way to create a encrypted disk using Ubuntu, where you can keep a backup of your private files. I've tested all the steps using a small USB flash drive, but use them at your own risk.

First you need to install the cryptsetup package:

sudo apt-get install cryptsetup

Now is time to plug your flash drive. To know the device associated with your drive, you can use the mount command (in my case, /dev/sdc1). You will see something like this:

/dev/sdc1 on /media/disk type vfat (rw,nosuid,nodev,shortname=mixed,uid=1000,utf8,umask=077)

So, in my case is the /dev/sdc1. Now is time to format the partition and create a password, using the luksformat command, choosing the file system. I will use ext3. So, type the following:
sudo luksformat -t ext3 /dev/sdc1

You will see a message like this:

WARNING!
========

This will overwrite data on /dev/sdc1 irrevocably.
Are you sure? (Type uppercase yes):

Type YES. At this point you will lost every data in that partition. Now you will have to insert a password, that will be used do unlock your device.

Enter LUKS passphrase:
Verify passphrase:

Please enter your passphrase again to verify it

Enter LUKS passphrase:

Now you will have to way until the partition until the format operation and the file system is created. After that, you can remove the device and insert then again. A window like this will appear:


Type the password and press Connect. The encrypted partition will be mounted.

If you have used the ext3 file system (like in my case), you will have create a directory in you flash drive using the superuser, and change the permissions. Use the mount command again, to see where the partition have been mounted:

/dev/mapper/luks_crypto_xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx on /media/disk type ext3 (rw,noexec,nosuid,nodev)

In this case, the partition have been mount on /media/disk, so just make something like this:

cd /media/disk
sudo mkdir osmeusficheiros

sudo chmod 777 osmeusficheiros/

Now you can start using your new encrypted disk to save your important stuff. Don't forget that there's no perfect backup device, and one day or another your device may fail, so keep more than one copy of your data. For more information, visit the LUKS website.




by Hugo, at GMT | comments: 0
© 1998-2007 Hugo Pereira | Terms of Usage | linhas.org