User Tools

Site Tools


Sidebar

Computer Science

Germany

Others

Links

computer_science:software:linux:commands:crypt_a_hard_drive_using_cryptsetup

Crypt a hard drive using Cryptsetup

Log as root and install cryptsetup

thomas@pavillon-t546fr:~$ sudo -s
root@pavillon-t546fr:~# apt-get install cryptsetup

Load the needed Kernel modules using modprobe

root@pavillon-t546fr:~# modprobe dm_crypt
root@pavillon-t546fr:~# modprobe dm_mod

Then load the aes module:

root@pavillon-t546fr:~# modprobe aes_generic

Important: if you are running a Plug-computer like TonidoPlug or SheevaPlug, load the module mv_cesa. To see the available crypto modules, run the command

cat /proc/crypto | less

Create the crypted partition

root@pavillon-t546fr:~# cryptsetup luksFormat -c aes -h sha256 /dev/sda

WARNING!
========
This will overwrite data on /dev/sda irrevocably.

Are you sure? (Type uppercase yes): YES
Enter LUKS passphrase: 
Verify passphrase: 

Open the crypted partition and format it in ext4.

root@pavillon-t546fr:~# cryptsetup luksOpen /dev/sda cloud
Enter passphrase for /dev/sda: 
root@pavillon-t546fr:~# mkfs
mkfs          mkfs.ext2     mkfs.ext4dev  mkfs.ntfs     
mkfs.bfs      mkfs.ext3     mkfs.minix    mkfs.vfat     
mkfs.cramfs   mkfs.ext4     mkfs.msdos    
root@pavillon-t546fr:~# mkfs.ext4 /dev/mapper/cloud 
mke2fs 1.42.8 (20-Jun-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
61054976 inodes, 244190134 blocks
12209506 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
7453 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
	102400000, 214990848

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 
computer_science/software/linux/commands/crypt_a_hard_drive_using_cryptsetup.txt · Last modified: 2015/03/12 10:38 by thomas