| 1 | = Filesystem encryption = |
| 2 | Install software: |
| 3 | {{{ |
| 4 | emerge device-mapper |
| 5 | emerge cryptsetup-luks |
| 6 | }}} |
| 7 | create the key: |
| 8 | {{{ |
| 9 | tr -cd [:graph:] </dev/urandom |head -c128 > /root/myhm_sdb1_key |
| 10 | }}} |
| 11 | |
| 12 | Setup the partition |
| 13 | {{{ |
| 14 | cryptsetup -v --cipher aes-cbc-essiv:sha256 --key-size 256 luksFormat /dev/sdb1 /root/myhm_sdb1_key |
| 15 | }}} |
| 16 | Answer YES[[BR]] |
| 17 | Opening the partition: |
| 18 | {{{ |
| 19 | cryptsetup --key-file /root/myhm_sdb1_key luksOpen /dev/sdb1 crypt-sdb1 |
| 20 | }}} |
| 21 | Create the filesystem: |
| 22 | {{{ |
| 23 | /sbin/mkfs.ext3 -j /dev/mapper/crypt-sdb1 |
| 24 | }}} |
| 25 | Mount the filesystem: |
| 26 | {{{ |
| 27 | mkdir /mnt/sdb1 |
| 28 | mount /dev/mapper/sdb1 /mnt/sdb1 |
| 29 | }}} |
| 30 | |
| 31 | Adding the filesytem to /etc/conf.d/cryptfs add the following: |
| 32 | {{{ |
| 33 | target=crypt-sdb1 |
| 34 | source='/dev/sdb1' |
| 35 | key='/root/myhm_sdb1_key' |
| 36 | }}} |
| 37 | Adding the filesytem to /etc/fstab, add the following: |
| 38 | {{{ |
| 39 | /dev/mapper/crypt-sdb1 /mnt/sdb1 auto noauto,noatime 0 0 |
| 40 | }}} |
| 41 | |
| 42 | Optional: [[BR]] |
| 43 | Encrypt the Keys using gpg: |
| 44 | {{{ |
| 45 | cat <KEYFILE> | gpg --symmetric -a >./<KEYFILE>.gpg |
| 46 | }}} |
| 47 | Decrypt the Keys using gpg: |
| 48 | {{{ |
| 49 | gpg --quiet --decrypt <KEYFILE>.gpg |
| 50 | }}} |
| 51 | |
| 52 | [wiki:KeySshfs Key on sshfs][[BR]] |
| 53 | |
| 54 | Additional Information:[[BR]] |
| 55 | Copy data using cpio (using the -xdev option to stay in local filesystem): |
| 56 | {{{ |
| 57 | cd <SOURCE-DIR> && find ./ -xdev -print0 | cpio -pa0V <TARGET-DIR> |
| 58 | }}} |
| 59 | Copy data using tar (using the l option to stay in local filesystem): |
| 60 | {{{ |
| 61 | (cd <SOURCE-DIR> >> /dev/null; tar clf - .)|(cd <TARGET-DIR> >> /dev/null; tar xvf -) |
| 62 | }}} |
| 63 | Copy data using rsync (using the x option to stay in local filesystem): |
| 64 | {{{ |
| 65 | rsync -avH --progress -x <SOURCE-DIR> <TARGET-DIR> |
| 66 | }}} |
| 67 | |
| 68 | |