Create an Encrypted Disk
Let's create an encrypted disk partition on Linux with dm-crypt. Let's say we 
have an empty, unused partition on "/dev/sda2".

We will write some random data to the beginning of the partition to destroy 
whatever data is there:
# dd if=/dev/urandom of=/dev/sda2 bs=1M count=1

Now we will make this device available through encryption and choose our 
passphrase:
# cryptsetup --verbose --verify-passphrase create \
crloop /dev/sda2

We now format a filesystem on our encrypted block device with mkfs, and mount 
it:
# mkfs.ext3 -m 1 \
-O dir_index,filetype,has_journal,sparse_super \
/dev/mapper/crloop
# mount /dev/mapper/crloop /mnt

Now that the encrypted block device is initialized, we can mount it with:
# cryptsetup create crloop /dev/sda2
# mount /dev/mapper/crloop /mnt

And to unmount:
# umount /mnt
# cryptsetup remove crloop

Reply via email to