Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
scratch [2019/03/03 20:17] – [LUKS] admin | scratch [2019/03/09 15:07] – [LUKS] admin | ||
---|---|---|---|
Line 167: | Line 167: | ||
====== LUKS ====== | ====== LUKS ====== | ||
- | | + | https://wiki.archlinux.org/index.php/dm-crypt/Device_encryption |
- | | + | |
- | https:// | + | |
- | https:// | + | |
| | ||
- | # Find the right partition | + | |
+ | ########## Preparation ########## | ||
+ | # - Boot a Linux from a USB stick or CD / DVD | ||
+ | # - Open a terminal | ||
+ | |||
+ | |||
+ | ################################# | ||
+ | ### Find the right partitions ### | ||
lsblk -o name, | lsblk -o name, | ||
| | ||
- | nvme0n1 | + | |
- | ├─nvme0n1p1 vfat | + | |
- | ├─nvme0n1p2 ext4 | + | |
- | └─nvme0n1p3 swap 39,1G | + | |
| | ||
- | # Set boot and root partition names, change | + | # Set boot and root partition names according |
BOOTPART=/ | BOOTPART=/ | ||
ROOTPART=/ | ROOTPART=/ | ||
| | ||
+ | | ||
+ | ############################### | ||
+ | ########### Encrypt ########### | ||
# Shrink root filesystem (NOT the partition) | # Shrink root filesystem (NOT the partition) | ||
- | | + | |
- | | + | |
+ | |||
+ | =============================================================================== | ||
+ | # A) Using luksipc | ||
+ | |||
+ | # | ||
+ | # Copy luksipc-master.zip to your home dir. If you have internet connection, | ||
+ | # you can directly download it (wget), else copy it manually. | ||
+ | # | ||
| | ||
- | | + | |
- | | + | |
+ | # | ||
+ | # wget https:// | ||
+ | # or copy manually: | ||
+ | cp luksipc-master.zip ~ | ||
+ | cd ~ | ||
| | ||
- | # Encrypt | + | # If you have no unzip, uncompress it with the GUI |
- | | + | |
- | unzip master.zip | + | |
cd luksipc-master | cd luksipc-master | ||
make | make | ||
sudo ./luksipc -d $ROOTPART | sudo ./luksipc -d $ROOTPART | ||
| | ||
- | # Add keyphrase | + | # Add keyphrase |
sudo cryptsetup luksAddKey $ROOTPART --key-file=/ | sudo cryptsetup luksAddKey $ROOTPART --key-file=/ | ||
# Let’s check this worked (slot 0 and 1 are populated) | # Let’s check this worked (slot 0 and 1 are populated) | ||
- | cryptsetup luksDump $ROOTPART | + | |
# Let’s scrub the initial keyslot so the initial keyfile becomes useless | # Let’s scrub the initial keyslot so the initial keyfile becomes useless | ||
- | cryptsetup luksKillSlot $ROOTPART 0 | + | |
- | # And check again (slot 1 is empty) | + | # And check again (slot 1 is empty now) |
- | cryptsetup luksDump $ROOTPART | + | |
+ | |||
+ | =============================================================================== | ||
+ | # B) or using cryptsetup-reencrypt: | ||
+ | sudo cryptsetup-reencrypt --type=luks2 --new --reduce-device-size 8M $ROOTPART | ||
+ | |||
+ | =============================================================================== | ||
+ | | ||
# resize the filesystem to its original size | # resize the filesystem to its original size | ||
sudo cryptsetup luksOpen $ROOTPART newcryptofs | sudo cryptsetup luksOpen $ROOTPART newcryptofs | ||
- | resize2fs / | + | |
| | ||
| | ||
- | # Make the system boot from the encrypted filesystem | + | |
+ | ### Make the system boot from the encrypted filesystem | ||
+ | | ||
sudo mount / | sudo mount / | ||
sudo mount $BOOTPART /mnt/boot | sudo mount $BOOTPART /mnt/boot | ||
- | | ||
| | ||
# Edit / | # Edit / | ||
Line 220: | Line 247: | ||
# change MODULES=() to | # change MODULES=() to | ||
MODULES=(nvidia_uvm nvidia_drm) | MODULES=(nvidia_uvm nvidia_drm) | ||
- | # set HOOKS to | + | # set HOOKS to |
HOOKS=(base systemd autodetect keyboard keymap sd-vconsole modconf block sd-encrypt filesystems fsck) | HOOKS=(base systemd autodetect keyboard keymap sd-vconsole modconf block sd-encrypt filesystems fsck) | ||
| | ||
| | ||
- | | + | # Set the content of the file / |
- | | + | echo -e " |
- | echo -e " | + | # and / |
- | echo -e "title Arch Linux\nlinux / | + | echo -e "title Arch Linux\nlinux / |
- | | + | |
+ | | ||
+ | | ||
+ | echo -e "title Arch Linux Fallback\nlinux / | ||
+ | / | ||
+ | root=/ | ||
+ | |||
+ | # You might want to delete all entries in / | ||
+ | # arch.conf and arch-fallback.conf as they won't boot anymore anyway. | ||
+ | ls / | ||
+ | | ||
| | ||
sudo chroot /mnt | sudo chroot /mnt | ||
Line 239: | Line 276: | ||
| | ||
# reboot | # reboot | ||
+ | sudo reboot | ||
+ | |||
+ | |||
+ | =============================================================================== | ||
+ | # change luks1 to luks2 (or vice versa) | ||
+ | sudo cryptsetup convert --type=luks2 $ROOTPART | ||
+ | | ||
+ | =============================================================================== | ||
+ | |||
+ | |