Skip to content

Instantly share code, notes, and snippets.

@p7cq
Last active October 4, 2025 17:44
Show Gist options
  • Select an option

  • Save p7cq/70e858c2d3853482928149281413c388 to your computer and use it in GitHub Desktop.

Select an option

Save p7cq/70e858c2d3853482928149281413c388 to your computer and use it in GitHub Desktop.
Install Arch Linux with Root on Btrfs

Arch Linux Root on Btrfs

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  # @pkg

Installation

Configure disks

The usual ceremony for preparing the disks is detailed below.

Wipe

sgdisk --zap-all /dev/vda
wipefs -a /dev/vda

sgdisk --zap-all /dev/vdb
wipefs -a /dev/vdb

This doesn't always work though. If this is the case, add -f then retry mkfs.btrfs command when creating the root filesystem later on.

Create partitions

Boot

sgdisk -n1:0:+550M -t1:ef00 /dev/vda
sgdisk -n1:0:+550M -t1:ef00 /dev/vdb

Swap

sgdisk -n2:0:+8G -t2:8200 /dev/vda
sgdisk -n2:0:+8G -t2:8200 /dev/vdb

BTRFS

sgdisk -n3:0:+400G -t3:8300 /dev/vda
sgdisk -n3:0:+400G -t3:8300 /dev/vdb

I'm using only ~85% of the free space available on the drives; to use it all, replace +400G with 0.

Format partitions

Boot and Swap

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/SWAP2

Root filesystem

mkfs.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/boot

Generate fstab

genfstab -U /mnt > /mnt/etc/fstab

Install base system

pacstrap /mnt base base-devel linux linux-firmware btrfs-progs

Configure system

Switch to new root

arch-chroot /mnt

Edit /etc/fstab and change both fmask and dmask to 0077 for /boot partition.

Timezone

ln -sf /usr/share/zoneinfo/Europe/Bucharest /etc/localtime
hwclock --systohc
timedatectl set-ntp true

Locale

sed -i 's/#\(en_US\.UTF-8\)/\1/' /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf

Configure key map and host name

echo -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/hosts

Set root password

passwd

Install required packages

pacman -Syu amd-ucode networkmanager sudo openssh man-db terminus-font

If Intel, replace amd-ucode with intel-ucode.

Configure initcpio

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 linux

Bootloader

Install

bootctl --path=/boot install

Create a pacman hook to auto-update bootloader

mkdir /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
EOF

Create a default entry

echo -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
EOF

Enable systemd services

systemctl enable NetworkManager.service sshd.service

Exit and reboot

exit
umount -R /mnt
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment