
This tutorial is about how to set up a crypted partition on linux using dmcrypt.
Of course, you can use either fisical partitions or files using a loopback device.
A loopback means that you have a file that is on a partition that you then mount using a special device called a loopback. The loop device then acts as a normal block device transforming your file into just another hard disk :)
This is useful if for example you wish to store all your ssh keys safely but don't want to have to make another partition for it!
You will need a kernel configuration similar to this in order of use dmcrypt:
You must first enable the device mapper (dm):
1 2 3 4 |
Device Drivers -->; [*] Multiple devices driver support (RAID and LVM) <*>; Device mapper support <*>; Crypt target support |
Then you must enable the cipher (aes):
1 2 |
Cryptographic API -->; <*>; AES cipher algorithims (i586) |
If you're going to be using dmcrypt on a loopback file, not a partition:
1 2 |
Device Drivers -->; Block Devices -->; <*> Loopback device support # Remember, cryptoloop is not dmcrypt |
Installing needed tools
You need cryptsetup in order to create ciphered partition. The exact package name may differ on various distros:
If you wish to use dmcrypt on a partition then read this, otherwise see below for information on using it with a loopback device.
First we create a device mapper device called 'mycrypt' on a partition, say /dev/hda7 (we will use that throughout the guide)
1 |
cryptsetup -y create mycrypt /dev/hda7 |
Has it worked?
1 |
dmsetup ls |
It should display 'mycrypt'
Now create a filesystem (replace mke2fs with whatever your filesystem creation tool is):
1 2 3 4 5 6 7 |
mke2fs /dev/mapper/mycrypt <code> <p>Now mount it:</p> <code> mount /dev/mapper/mycrypt /mnt/point |
Test it worked, congratulations!
To bring it down:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
umount /mnt/point cryptsetup remove mycrypt <code> <h4>..on a file using loopback device</h4> <p>This is for using dmcrypt with a loopback device; see above for using it with a partition.</p> <p>First, create our file:</p> <code> touch protected shred -n1 -s50M protected |
This creates a file called 'protected' in your current directory of 50MB.
By prefilling it with random data, it's impossible to see afterwards how much has been used.
Now let's set a loopback device to use this file.
First find the name of the first unused loop device :
losetup -f
Use this loop device to set a loopback (in this case /dev/loop0 is available)
1 |
losetup /dev/loop0 /path/to/protected |
Now lets create an encrypted device mapper device using cryptsetup:
1 |
cryptsetup -y create mycrypt /dev/loop0 |
Check it worked:
1 |
dmsetup ls |
You should see 'mycrypt' listed
Now create a filesystem (replace mke2fs with whatever your filesystem creation tool is) :
1 |
mke2fs /dev/mapper/mycrypt |
Now mount it:
1 |
mount /dev/mapper/mycrypt /mount/point |
Check it works for a while, and be happy, then continue reading :)
To unmount it:
1 2 3 |
umount /mount/point cryptsetup remove mycrypt losetup -d /dev/loop0 |
To automate this process you could write your own script (see below) or try the tool cryptmount.
umount/mount Scripts
1 2 3 4 5 6 |
#!/bin/bash losetup /dev/loop0 /Your/Container sleep 1 cryptsetup create Container /dev/loop0 sleep 1 mount /dev/mapper/Container /mnt/Container |
replace Container with your file, save it under /usr/bin/something and chmod +x /usr/bin/something
1 2 3 4 |
#!/bin/bash umount /dev/mapper/Container cryptsetup remove Container losetup -d /dev/loop0 |
Replace Container with your file, save it under /usr/bin/somethingother and chmod +x /usr/bin/somethingother
video jedi
fake ring amen ego rimonabant lola chapel timid
kept
clot liars manic sold host viagra köp gnome quip rush adolf pedro köp levitra ludwig sheer
gush nne
dee psych wynn buy valtrex akin bees salon clam
gauche hype
buick hut acomplia irvin broke posh kiln coca comprar soma online skim chunk xvii
prey
W e _ a r e _ v e r y _ s o r r y _ f o r _ a n y _ i n c o n v i n i e n c e _ c a u s e d _ t o _ y o u _ b y _ o u r _ m e s s a g e . W e _ w e r e _ s e e k i n g _ f o r _ o l d _ " n o b o d y ' s " _ w e b s i t e s . _ I f _ i t ' s _ a _ m i s t a k e _ a n d _ w e _ d i s t u r b e d _ y o u , _ p l e a s e _ d e l e t e _ o u r _ m e s s a g e , _ a n d _ w e ' l l _ n e v e r _ r e t u r n _ h e r e . O n e _ m o r e _ t i m e , _ s o r r y _ f o r _ a n y _ t r o u b l e s _ t h a t _ w e ' v e _ c a u s e d _ b y _ o u r _ a c t i v i t y . levitra online