Attention, toutes les manipulations indiquées ici sont risquées pour vos données! Avant de faire les manipulations suivantes, pensez à faire des sauvegardes.
# apt-get install cryptsetup
# modprobe aes # modprobe dm_crypt # modprobe dm_mod
Cas d'utilisation : on crypte une partition non sensible (ni /, /home, swap, etc)
Ici notre partition à crypter sera /dev/sda6. Elle est en ext3 et on désire la monter dans /mnt/stock.
# cryptsetup luksFormat /dev/sda6 WARNING! ======== This will overwrite data on /dev/sda6 irrevocably. Are you sure? (Type uppercase yes): YES Enter LUKS passphrase: Verify passphrase: Command failed: Failed to setup dm-crypt key mapping. Check kernel for support for the aes-cbc-essiv:sha256 cipher spec and verify that /dev/sda6 contains at least 133 sectors darkstar:/home/fritz# modprobe aes darkstar:/home/fritz# modprobe dm_crypt darkstar:/home/fritz# modprobe dm_mod darkstar:/home/fritz# cryptsetup luksFormat /dev/sda6 WARNING! ======== This will overwrite data on /dev/sda6 irrevocably. Are you sure? (Type uppercase yes): YES Enter LUKS passphrase: Verify passphrase: Command successful.
# cryptsetup luksOpen /dev/sda6 stock Enter LUKS passphrase: key slot 0 unlocked. Command successful.
La partition est maintenant présente dans /dev/mapper/stock :
# ls -l /dev/mapper/ total 0 crw-rw---- 1 root root 10, 60 jan 10 10:32 control brw-rw---- 1 root disk 254, 0 jan 10 10:36 stock
LUKS permet d'avoir 8 clés pour la partition. Nous allons en créer une seconde par sécurité :
# cryptsetup luksAddKey /dev/sda6 Enter any LUKS passphrase: key slot 0 unlocked. Enter new passphrase for key slot: Verify passphrase: Command successful.
Afin de vérifier (entre autres) le nombre de slots utilisés, on peut afficher les informations de la partition cryptée :
# cryptsetup luksDump /dev/sda6
LUKS header information for /dev/sda6
Version: 1
Cipher name: aes
Cipher mode: cbc-essiv:sha256
Hash spec: sha1
Payload offset: 1032
MK bits: 128
MK digest: 7b cf 6f 6a 64 96 0b b1 a2 ec 08 fc 0d 7f f7 bf c6 e5 3a 12
MK salt: 34 65 93 10 b6 8c dd 82 d8 1a 86 3b 36 2d a6 bf
57 cc 2a d4 91 9c f3 28 c7 a7 c9 10 99 96 af a0
MK iterations: 10
UUID: 33069df1-680d-4c28-b5ad-8bc9f14331cc
Key Slot 0: ENABLED
Iterations: 343972
Salt: ff c1 6a 44 46 33 b2 ef 13 93 0c 17 c5 32 fe a2
8e 24 06 29 a6 41 d9 67 64 54 2e be 87 c4 da 7c
Key material offset: 8
AF stripes: 4000
Key Slot 1: ENABLED
Iterations: 350728
Salt: bc 0f ef 9d 24 3b 44 af 27 c6 3d 27 de 91 6b 55
92 72 d3 04 3d 4b c6 4d c9 d9 1a 0c 05 86 05 17
Key material offset: 136
AF stripes: 4000
Key Slot 2: DISABLED
Key Slot 3: DISABLED
Key Slot 4: DISABLED
Key Slot 5: DISABLED
Key Slot 6: DISABLED
Key Slot 7: DISABLED
# cryptsetup luksClose stock
Ici on va formatter notre partition en ext3 :
# mkfs.ext3 /dev/mapper/stock
# mount -t ext3 /dev/mapper/stock /mnt/stock/
Editer le fichier /etc/crypttab ainsi :
# <target name> <source device> <key file> <options> stock /dev/sda6 none luks,checkargs=ext2
Editer /etc/fstab :
/dev/mapper/stock /mnt/stock ext3 defaults 0 2
Au prochain démarrage, un mot de passe sera demandé pour monter la partition cryptée.