Created
June 25, 2018 23:03
-
-
Save mimizone/c00e4aab0dad657db6558d0172c85e1c to your computer and use it in GitHub Desktop.
encrypted partition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install cryptsetup | |
lsblk | |
# create a partition manually with fdisk on /dev/sdb | |
sudo fdisk /dev/sdb | |
sudo cryptsetup --verbose --verify-passphrase luksFormat /dev/sdb1 | |
sudo cryptsetup luksDump /dev/sdb1 | |
sudo cryptsetup luksOpen /dev/sdb1 sdb1 | |
# format and mount the partition | |
sudo mkfs.ext4 /dev/mapper/sdb1 | |
sudo mkdir /mnt/data | |
sudo mount /dev/mapper/sdb1 /mnt/data | |
# make the partition mounted at boot | |
sudo dd if=/dev/urandom of=/root/key.sbd1 bs=1024 count=4 | |
sudo chmod 400 /root/key.sbd1 | |
sudo cryptsetup luksAddKey --key-slot 1 /dev/sdb1 /root/key.sdb1 | |
#type the same key as before when prompted | |
sudo cryptsetup luksDump /dev/sdb1 | |
#get uuid of block device | |
sudo cryptsetup luksUUID /dev/sdb1 | |
sudo vi /etc/crypttab | |
# add a line line the following | |
# <encrypted block device> /dev/disk/by-uuid/<UUID of block device> <location of key file> luks | |
# example : sdb1 /dev/disk/by-uuid/5acc17e0-80be-40ba-beae-626e47b57379 /root/key.sdb1 luks | |
# edit fstab | |
sudo vi /etc/fstab | |
# add a line such as | |
# /dev/mapper/sdb1 /mnt/data ext4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment