Encrypted Arch Installation Guide
What this guide assumes:
- You should have basic familiarity with the process of installing Arch manually (i.e. no install script); this is no hard requirement, but since this guide presents a fairly advanced setup process certain "common" or "basic" commands will not be explained in great detail, if at all. Always know and understand what you are doing.
- You plan to use a single drive for the Arch Linux installation
- The drive you are about to use contains data that will be deleted
- You double-checked that the drive is safe to wipe before you wipe
- You are fine with using GRUB as the bootloader
- You are fine with entering a password on bootup (to decrypt encrypted drives)
- You understand that there is virtually no chance to access your files on an encrypted drive if you forget or lose your password
- You understand that no device or file system encryption can be 100% fool-proof considering there are a myriad of factors at play (e.g. the threat level you are trying to protect yourself against, the safety practices you follow when handling encrypted data once it is decrypted, etc.)
This guide's goal:
- Set up encrypted Boot, Swap, and other paritions using dm-crypt
- Install Arch Linux
What I've done so far:
- Optional: Establish a remote connection to the target machine via SSH(Wiki):
- On the target machine:
- Follow the steps from Installation guide#Pre-installation up to and including connecting to the internet (setting the keyboard layout and font can be skipped)
- Set a root password: # passwd
- On the machine you want to use SSH from:
- Assuming both machines are on the same local network: $ ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@archiso.local
- Otherwise: $ ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@ip.address.of.target
- Drive Preparation (Single drive solution)
- Destroy GPT (General Partitioning Layout):
- Indentify drive to be wiped with # lsblk
- # gdisk /dev/sdX
- Enter 'x' for 'Expert'
- Enter 'z' for 'Zap'
- 'Blank out MBR?' -> Enter 'y'
- Wipe device(Wiki):
- Create a temporary encrypted container on the device to be encrypted: # cryptsetup open --type plain --key-file /dev/urandom --sector-size 4096 /dev/block-device to_be_wiped
- Verify that it exists: # lsblk
- Wipe the container with zeros: # dd if=/dev/zero of=/dev/mapper/to_be_wiped status=progress bs=1M
- Close the temporary container: # cryptsetup close to_be_wiped
- Preparing the partition layout(Wiki):
- # cgdisk /dev/sdX -> The warning / error message is to be expected since we previously destroyed the drives's GPT. 'Press any key to continue' -> '*'
- BIOS boot partition:
- 'New' -> Enter
- 'Default sector' -> Enter
- 'Size' -> 1024 KiB
- 'Hexcode or GUID' -> 'EF02'
- 'Enter new partition name' -> boot
- EFI system partition:
- 'New' -> Enter
- 'Default sector' -> Enter
- 'Size' -> 1024 MiB
- 'Hexcode or GUID' -> 'EF00'
- 'Enter new partition name' -> efi
- LUKS partition (for Swap and other OS-related partitions):
- 'New' -> Enter
- 'Default sector' -> Enter
- 'Size' -> X MiB
- 'Hexcode or GUID' -> '8309'
- 'Enter new partition name' -> linux
- 'Write' -> Enter
- 'Are you sure?' -> yes
- 'Quit' -> Enter
- LUKS encrypted container (on LUKS partition):
- # cryptsetup luksFormat --pbkdf pbkdf2 /dev/sdXY
- 'This will overwrite data on /dev/sdXY irrevocably. Are you sure?' -> YES
- 'Enter passphrase for /dev/sdX:' -> SuperSecretPassphrase
- 'Verify passphrase:' -> SuperSecretPassphrase
- Verify current layout -> # gdisk -l /dev/sdX
- Open the container -> # cryptsetup open /dev/sdXY cryptlinux
- Preparing the logical volumes(Wiki):
- Create a physical volume on top of the opened LUKS container -> # pvcreate /dev/mapper/cryptlinux
- Create a volume group (in this example named MyVolGroup, but it can be whatever you want) and add the previously created physical volume to it -> # vgcreate MyVolGroup /dev/mapper/cryptlinux
It might be desirable to perform operations on the target machine via SSH from an already set up device in order to easily access this guide or other helpful documentation. The following steps assume physical access to the target machine.
Considerations
Encrypted Boot partition (using GRUB) + LVM on LUKS