Create Encrypted Partition
December 25, 2009
Posted by on
I use encrypted partitions on all my external hard disks. This is how I did it:
- Install the cryptsetup package.
# aptitude install cryptsetup
- Create a partition on the empty external hard disk. Assume the device name is /dev/sdb
# cfdisk /dev/sdb
- Setup the encryption on the partition created. The device name for my newly created partition is /dev/sdb1. During the setup, you’ll be prompted to give a password to decrypt the partition.
# cryptsetup luksFormat /dev/sdb1
# cryptsetup luksOpen /dev/sdb1 tempName
- Create an extended-3 filesystem.
# mkfs.ext3 /dev/mapper/tempName
- Give it a volume name. Mine is called “EXT-80GB”
# tune2fs -L EXT-80GB /dev/mapper/tempName
- Close the encrypted partition.
# cryptsetup luksClose tempName
- Encryption setup is now completed. Unplug and plug in the external hard disk, pmount will detect it. You’ll be prompted to key in your password to decrypt the partition.