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, steps 1-5)(Wiki, steps 6-):
- 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
- Create all your logical volumes on the volume group (the following are examples; create your logical volumes according to your own needs):
- # lvcreate -L 14G -n swap MyVolGroup
- # lvcreate -L 86G -n root MyVolGroup
- # lvcreate -l 100%FREE -n assets MyVolGroup
- If a logical volume will be formatted with Ext4, leave at least 256 MiB free space in the volume group to allow using e2scrub(8). After creating the last volume with '-l 100%FREE', this can be accomplished by reducing its size with # lvreduce -L -256M MyVolGroup/assets
- Format your file systems on each logical volume. For example, using Ext4 for the root and home volumes:
- # mkswap /dev/MyVolGroup/swap
- # mkfs.ext4 /dev/MyVolGroup/root
- # mkfs.ext4 /dev/MyVolGroup/assets
- Format EFI system partition (boot partition may remain unformatted) -> # mkfs.fat -F 32 /dev/sdXY
- For UEFI systems, create a mountpoint for the EFI system partition at /efi for compatibility with 'grub-install' and mount it -> # mount --mkdir /dev/sda2 /mnt/efi
- Installation
- Select the mirrors
- Install essential packages
- Configure the system
- Fstab
- Chroot
- Time
- Localisation
- Network configuration
- 32-bit support
- Initramfs(Wiki)
- Configure GRUB(Wiki)
- Root password
- Reboot
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.
For more information, see the official Arch Wiki installation guide section on selecting the mirrors. This step may be skipped or postponed as required or desired.
Use the pacstrap(8) script to install the base package, Linux kernel and firmware for common hardware -> # pacstrap -K /mnt base linux linux-firmware base-devel lvm2 amd-ucode nano fastfetch
Generate an fstab file -> # genfstab -U /mnt >> /mnt/etc/fstab
Check the resulting /mnt/etc/fstab file, and edit it in case of errors
Change root into the new system -> # arch-chroot /mnt
Set the time zone -> # ln -sf /usr/share/zoneinfo/Region/City /etc/localtime
Run hwclock(8) to generate /etc/adjtime -> # hwclock --systohc
To prevent clock drift and ensure accurate time, set up time synchronization, e.g. with systemd-timesyncd -> follow article to set up
Edit /etc/locale.gen and uncomment needed UTF-8 locales.
Generate the locales by running -> # locale-gen
Create the locale.conf(5) file, and set the LANG variable accordingly -> echo LANG=en_GB.UTF-8 > /etc/locale.conf && export LANG=en_GB.UTF-8
Create the hostname file -> # echo yourhostname > /etc/hostname
Install dhcpcd -> pacman -S dhcpcd
Check available network cards -> # ip link
Enable dhcpcd on active network card -> # systemctl enable dhcpcd@enp0s1
Install networkmanager -> pacman -S networkmanager
Enable networkmanager -> systemctl enable NetworkManager.service
Edit pacman configuration -> # nano /etc/pacman.conf
Press CTRL+W and type 'multilib' -> remove '#' sign before '[multilib]' and 'Include'
Press CTRL+X to exit -> Enter 'y' to confirm changes -> Press Enter to confirm file name
Fetch repositories -> pacman -Sy
Set a root password -> # passwd
Exit the chroot environment -> # exit
Unmount all partitions -> # umount -R /mnt
Shut down machine -> poweroff
Remove installation device
Power on the device
???
Congratulations, minimal Arch installed!
Considerations
Encrypted Boot partition (using GRUB) + LVM on LUKS
Include step to set color and parallel downloads in /etc/pacman.conf