26 May 2011

Encrypted partition in Ubuntu/Debian/Linux

Setup and encrypted partition in Linux(Debian/Ubuntu and variant) is quite easy.

Please follow the  below steps.

I have physical partition sda1 available.

Step 1: Install cryptsetup
,----
| sudo apt-get install cryptsetup
`----

Step 2: Set up encryption on the partition
,----
| sudo cryptsetup luksFormat /dev/sda1
|
| WARNING!
| ========
| This will overwrite data on /dev/sda1 irrevocably.
| Are you sure?
| (Type uppercase yes): YES
| Enter LUKS passphrase:
| Verify passphrase:
| Command successful
`----

Step 3: Open the mount the device
,----
| sudo cryptsetup luksOpen /dev/sda1 crypt_disk
| Enter LUKS passphrase:
| Command successful.
`----

Step 4: Create the file system( I am creating ext4)
,----
| mkfs.ext4 /dev/mapper/crypt_disk
`----

Step 5: Add entry to /etc/crypttab
,----
| crypt_disk /dev/sda1 luks
`----

Step 6: Create mount point for automate the process in future
 and add entry to /etc/fstab
,----
| mkdir /mnt/crypt
| /dev/mapper/crypt_disk /mnt/crypt ext4 defaults 0 2
`----

No comments: