Installation steps for running Arch Linux with / on BTRFS using UEFI and systemd-boot. All steps are run as root.
The system volumes will be layed out in a flat structure using two disks in RAID 0.
/ # @
/home # @home
/var/log # @log
/var/cache/pacman/pkg # @pkgThe usual ceremony for preparing the disks is detailed below.
sgdisk --zap-all /dev/vda
wipefs -a /dev/vda
sgdisk --zap-all /dev/vdb
wipefs -a /dev/vdbThis doesn't always work though. If this is the case, add -f then retry mkfs.btrfs command when creating the root filesystem later on.
sgdisk -n1:0:+550M -t1:ef00 /dev/vda
sgdisk -n1:0:+550M -t1:ef00 /dev/vdbsgdisk -n2:0:+8G -t2:8200 /dev/vda
sgdisk -n2:0:+8G -t2:8200 /dev/vdbsgdisk -n3:0:+400G -t3:8300 /dev/vda
sgdisk -n3:0:+400G -t3:8300 /dev/vdbI'm using only ~85% of the free space available on the drives; to use it all, replace +400G with 0.
mkfs.fat -F 32 -n BOOT1 /dev/vda1
mkfs.fat -F 32 -n BOOT2 /dev/vdb1
mkswap -L SWAP1 /dev/vda2
mkswap -L SWAP2 /dev/vdb2
swapon /dev/disk/by-label/SWAP1 /dev/disk/by-label/SWAP2mkfs.btrfs -L ROOT -m raid1 -d raid0 /dev/vda3 /dev/vdb3
mount /dev/disk/by-label/ROOT /mnt
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@log
btrfs subvolume create /mnt/@pkg
umount /mnt
mount -o compress=zstd,subvol=@ /dev/disk/by-label/ROOT /mnt
mkdir -p /mnt/{boot,etc,home,var/{cache/pacman/pkg,log}}
mount -o compress=zstd,subvol=@home /dev/disk/by-label/ROOT /mnt/home
mount -o compress=zstd,subvol=@log /dev/disk/by-label/ROOT /mnt/var/log
mount -o compress=zstd,subvol=@pkg /dev/disk/by-label/ROOT /mnt/var/cache/pacman/pkg
mount /dev/disk/by-label/BOOT1 /mnt/bootgenfstab -U /mnt > /mnt/etc/fstabpacstrap /mnt base base-devel linux linux-firmware btrfs-progsarch-chroot /mntEdit /etc/fstab and change both fmask and dmask to 0077 for /boot partition.
ln -sf /usr/share/zoneinfo/Europe/Bucharest /etc/localtime
hwclock --systohc
timedatectl set-ntp truesed -i 's/#\(en_US\.UTF-8\)/\1/' /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.confecho -e "KEYMAP=us\n#FONT=latarcyrheb-sun32\nFONT=ter-v32n" > /etc/vconsole.conf
hostnamectl set-hostname al-btrfs
# echo -e "127.0.0.1 localhost\n::1 localhost" >> /etc/hostspasswdpacman -Syu amd-ucode networkmanager sudo openssh man-db terminus-fontIf Intel, replace amd-ucode with intel-ucode.
Configure initial ramdisk in /etc/mkinitcpio.conf by adding btrfs at the end:
HOOKS=(base udev autodetect microcode modconf kms keyboard keymap consolefont block filesystems fsck btrfs)Regenerate initramfs:
mkinitcpio -p linuxbootctl --path=/boot installmkdir /etc/pacman.d/hooks
cat << "EOF" > /etc/pacman.d/hooks/100-systemd-boot.hook
[Trigger]
Type = Package
Operation = Upgrade
Target = systemd
[Action]
Description = update systemd-boot
When = PostTransaction
Exec = /usr/bin/bootctl update
EOFecho -e "default arch\ntimeout 3\nconsole-mode 1" > /boot/loader/loader.conf
cat << "EOF" > /boot/loader/entries/arch.conf
title Arch Linux
linux /vmlinuz-linux
initrd /amd-ucode.img
initrd /initramfs-linux.img
options root=/dev/disk/by-label/ROOT rootflags=subvol=@ rw
EOFsystemctl enable NetworkManager.service sshd.serviceexit
umount -R /mnt
reboot