Arch (btrfs + luks + systemd-boot) installation
THIS IS NOT A GUIDE. IT’S JUST A PERSONAL CHEATSHEET.
YOU SHOULD FOLLOW THE ARCH WIKI.
Check EFI mode
# ls /sys/firmware/efi/efivars
General
Configure time:
timedatectl set-ntp true
Partitioning
We assume that we install Arch on /dev/nvme0n1
.
# gdisk /dev/nvme0n1
Create a new partition table:
Command (? for help): o
Create an EFI partition (choose size 550M and hex code EF00):
Command (? for help): n
Create a root partition (adopt the default values):
Command (? for help): n
Write the new partitions to disk:
Command (? for help): w
Encryption
Create an encrypted container for the root file system (you need to define a passphrase):
# cryptsetup luksFormat /dev/nvme0n1p2
Open the container (“luks” is just a placeholder, you can use a name of your choice, but remember to adopt the subsequent steps of the guide accordingly):
# cryptsetup open /dev/nvme0n1p2 luks
File system creation
Format the EFI partition with FAT32 and give it the label EFI - you can choose any other label name:
# mkfs.vfat -F32 -n EFI /dev/nvme0n1p1
Format the root partition with Btrfs and give it the label ROOT - you can choose any other label name. If you didn’t open the LUKS container under the name “luks” you must adjust the command accordingly:
# mkfs.btrfs -L ROOT /dev/mapper/luks
Create and mount subvolumes
Create subvolumes for root, home, the package cache, snapshots and the entire Btrfs file system:
# mount /dev/mapper/luks /mnt
# btrfs sub create /mnt/@
# btrfs sub create /mnt/@home
# btrfs sub create /mnt/@pkg
# btrfs sub create /mnt/@snapshots
# btrfs sub create /mnt/@btrfs
# umount /mnt
Mount the subvolumes:
# mount -o noatime,nodiratime,compress=zstd,space_cache,ssd,subvol=@ /dev/mapper/luks /mnt
# mkdir -p /mnt/{boot,home,var/cache/pacman/pkg,.snapshots,btrfs}
# mount -o noatime,nodiratime,compress=zstd,space_cache,ssd,subvol=@home /dev/mapper/luks /mnt/home
# mount -o noatime,nodiratime,compress=zstd,space_cache,ssd,subvol=@pkg /dev/mapper/luks /mnt/var/cache/pacman/pkg
# mount -o noatime,nodiratime,compress=zstd,space_cache,ssd,subvol=@snapshots /dev/mapper/luks /mnt/.snapshots
# mount -o noatime,nodiratime,compress=zstd,space_cache,ssd,subvolid=5 /dev/mapper/luks /mnt/btrfs
Mount the EFI partition:
# mkdir /mnt/boot
# mount /dev/nvme0n1p1 /mnt/boot
Base System and /etc/fstab
Install Arch Linux with (adjust this list to your needs):
base base-devel btrfs-progs linux linux-firmware dhcpcd nano neovim iwd networkmanager amd-ucode
Generate /etc/fstab
:
# genfstab -U /mnt >> /mnt/etc/fstab
System Configuration
chroot
into the new system:
# arch-chroot /mnt/
Set host name:
# echo <YOUR-HOSTNAME> > /etc/hostname
Set locale:
# echo LANG=en_US.UTF-8 > /etc/locale.conf
Uncomment the following row of /etc/locale.gen
:
#en_US.UTF-8 UTF-8
Generate locale:
# locale-gen
Set time zone:
# ln -sf /usr/share/zoneinfo/Europe/Rome /etc/localtime
Set hardware clock from system clock:
hwclock --systohc
Define hosts in /etc/hosts
:
127.0.0.1 localhost
::1 localhost
127.0.0.1 <YOUR-HOSTNAME>.localdomain <YOUR-HOSTNAME>
Set root password:
# passwd
Initramfs
Configure the creation of initramfs by editing /etc/mkinitcpio.conf
. Change the line HOOKS=… to:
HOOKS="base keyboard udev autodetect modconf block keymap encrypt btrfs filesystems"
Recreate initramfs:
# mkinitcpio -p linux
Boot Manager
Install systemd-boot:
# bootctl --path=/boot install
Create file /boot/loader/entries/arch.conf
and fill it with:
title Arch Linux
linux /vmlinuz-linux
initrd /amd-ucode.img
initrd /initramfs-linux.img
options cryptdevice=UUID=<UUID-OF-ROOT-PARTITION>:luks:allow-discards root=/dev/mapper/luks rootflags=subvol=@ rd.luks.options=discard rw
The UUID of the root partition can be determined via:
# blkid -s UUID -o value /dev/nvme0n1p2
Edit file /boot/loader/loader.conf
and fill it with:
default arch.conf
Final Steps
Exit chroot
, unmount partitions and reboot:
# exit
# umount -R /mnt
# reboot