Contents

Archlinux minimal Install with btrfs


Arch Linux Installation Guide

Introduction

If you don’t know about Arch Linux, and willing to learn, then check this post,

In this guide I’ll be installing Arch Linux with BTRFS. And in a separate article I’ll show you the way to a minimal KDE plasma desktop along with some extended possibilities. If you’re reading this I can assume you are already familiar with archwiki - a great place to learn about Arch Linux!

Tip
This post will be long and may be hard to navigate without TOC (Table of Contents). So please use table of contents. On desktop it’s placed on the right side and mobile device users can access it from the very top of the post.

Why Arch?

If you don’t have much idea about different distros, maybe you can read this article. Also you’ll find a lot of guys in YouTube for this purpose (to explain you why you need arch). If you’ve much free time to tinker with your system and you are in need of a full time job with no salary, welcome to the arena! I’ll highly recommend you to try Arch Linux.

F.A.Q.'s

From ArchWiki

Why BTRFS?

You might be familiar with computer storage formats like ntfs, fat32 or exfat. Btrfs (B-tree Filesystem, nicknamed Butter FS) is a modern filesystem built around the copy-on-write principle.

Snapshots

As Arch Linux is a rolling model, often called bleeding edge, system will be updated a lot and a lot of things can break or repair on each update.

With btrfs you can take snapshots within seconds and it’ll use less resource due to it’s copy-on-write principle. And what’s more you can also recover to a previous snap within a few seconds (just a simple restart),

Boot from snapshots

And the most interesting thing is that you can add your btrfs snapshot entry to GRUB bootloader. You can use pacman hook to trigger snapshot backup before any system update and an another script to add those backup as GRUB entry.

So if something goes wrong, you can go to previous condition right from your bootloader! I’ll show the way to achieve this on the next part (post installation).

Compression

BTRFS can compress your data as you write to save storage and it’ll be helpful on the long road. Also there are some cons. Read more here.

Tip

If you want to learn more about BTRFS then maybe a search through the web or, our favourite arch wiki is here,

Prerequisite

To install Arch Linux, indeed the best way to learn is Arch Wiki. But, the official guide will be little tough to understand to follow especially if you want to install on a btrfs file system or maybe a different kernel. This is why I won’t be explaining everything in details and my guide is specifically for intermediate users.

Danger

If your intention is blindly copy paste commands from this guide or Arch wiki without understanding anything, things may not work the way you want. So I highly recommend you to install any other distro. You can try,

  • Manjaro Linux - for complete newbies to learn things around and recommended for stability.
  • EndeavourOS - it’s more like graphical arch installer and highly recommended!

And keep these things in mind,

  1. Avoid blindly following online tutorials and instructions.
  2. Avoid installing unnecessary packages.
  3. Avoid assuming that commands will work without understanding what they do.
  4. Avoid partitioning without understanding the implications.
  5. Avoid using the root user for regular activities.
  6. Avoid using AUR packages without understanding the risks.
  7. Avoid using unsupported or experimental software.
  8. Avoid using the default kernel if it doesn’t provide the features you need.
  9. Avoid assuming that the installation will be successful without testing.
  10. Avoid reinstalling the system without backing up your data first.

Pre-Installation

ISO

You can grab it from official download page. To achieve better download speed you can try a local mirror. Scroll down a bit in the download page.

Example

For example, my country is Bangladesh and I’ve a mirror available. I can achieve better broadband speed from this mirror!

It’s always recommended to select the latest version. File name is like,

  • archlinux-2022.12.01-x86_64.iso
And,

If you want, you can also try third party builds of ArchLinux. Check the following link,

Installation medium

You can use a USB flash drive or, an optical disc or a network with PXE for installation. Now USB drives are more better choice and I’ll recommend you to try ventoy available for almost every desktop platform. Take a backup of your drives data first and then launch ventoy. You can install ventoy on a drive, and later just copy the ISO to your drive. Specialty of ventoy is that you can put multiple ISO to make a multi-boot bootable USB and what’s more, you can also store data (anything) on that USB.

[OPTIONAL] You can also verify your ISO. Try this guide for that purpose,

Booting into live ISO

First, go to bios/ uefi setting. Different motherboard has different keybindings. You can search through web to learn more. Finally you have to point your first boot to the bootable USB or disk.

Extended guide in Arch Wiki,

Preparation

As for preparation, we’ll make sure we have an active internet connection and set our keyboard’s layout and time zone [optional]. I’ll install minimal KDE plasma desktop and I can manage my time zone and keyboard’s layout later using GUI. If you’re using a different layout than English, you may want to check,

Internet

If you’re using Ethernet cable, internet connection should work out of the box. As for WiFi users, connect using iwctl. And for mobile broadband users, try with the mmcli utility.

Troubleshooting
For wireless and WWAN, make sure the card is not blocked with rfkill

Now, test you connection with ping,

1
ping 1.1.1.1

Tip: Ctrl + c to stop a process

Summary,

utility achievement
iwctl WiFi
mmcli mobile broadband
ping check/ verify network

Remote Installation (SSH)

If you want to let your friend install Arch on your PC, he can easily do it securely if both if your’re under the same local network,

Start SSH

1
systemctl start sshd.service

Set a password for root,

1
passwd

Find the IP Address

1
ip address

From your other computer, connect via SSH (You’ll be prompted for the root password you just set)

1
ssh root@<IP-OF-THE-FIRST-PC>

Remote Installation (Internet)

But if your friend is on the other part of the planet or not on the same network, you can use internet protocol for this.

First, sync your packages and install tmate,

1
pacman -Sy tmate

And, run, tmate and give your friend the access key!

If you get any error, first sync with, pacman -Sy

and then install archlinux-keyring with, pacman -S archlinux-keyring

later you can update archinstall, pacman -S tmate

ArchInstall

Since 2021-04-01, Arch has a guided installer again. See archinstall for details. You can easily install Arch with the help of this script and avoid the rest of this post but if you want to extend your possibilities and configure everything with your own hand then I’ll recommend the manual way.

For easily install, first get the latest package,

1
pacman -Sy archinstall

Then run,

1
archinstall

If you get any error, first sync with, pacman -Sy

and then install archlinux-keyring with, pacman -S archlinux-keyring

later you can update archinstall, pacman -S archinstall

Tip
If you’re going for archinstall, then I would highly recommend you to install EndeavourOS. And if you want to install arch to show up, then while installing endeavouros select the online method and from the package choice list deselect endevouros corresponding packages and cofigs! Then it’ll install pure arch! Besides you’ll find arch GUI installers in the sourceforge.

Partitioning

You can list you drives along with partitions using lsblk or fdisk -l. You may find something like, sda, sdb, etc. Here sda and sdb are two different drive/ disk. You’ll also notice their partitions (if they exist). If you need to change a partition table or create or remove or resize partitions there are several tools. I’ll recommend to use cfdisk. And to check disks and partitions size, try df -H.

Summary,

command achievement
lsblk list drives along with existing partitions
fdisk -l same as above with more information
df -H list partitions size
cfdisk manage partitions
parted third party to manage partitions (Gparted CLI)

Layouts

It’s recommended to get a basic concepts of disk partitions at first. Try the following post for understanding,

Checking UEFI/ BIOS

To verify the boot mode, list the efivars directory:

1
ls /sys/firmware/efi/efivars

If the command shows the directory without error, then the system is booted in UEFI mode. If the directory does not exist, the system may be booted in BIOS (or CSM) mode. If the system did not boot in the mode you desired, refer to your motherboard’s manual.

BIOS with MBR

Check this link for an example layout,

UEFI

Most of the modern system supports UEFI (even BIOS can have it! Please check your BIOS first) and so I’ll continue my guide in UEFI only. You can go with the layout from Arch Wiki,

Our layout

Instead of creating a rigid, separate ext4 partition for /home and a dedicated swap partition, we will use a clean 2-partition scheme with a unified Btrfs storage pool. With Btrfs, subvolumes (such as @ for root and @home for user directories) dynamically share the same free space across the pool. There’s no need to guess ahead of time how many gigabytes / or /home will need—both grow and shrink dynamically as files are created and removed!

For swap, we will set up a flexible Btrfs swapfile in the post-installation part (part 2) rather than locking up storage in a fixed partition.

We standardize our EFI system partition mount point to /boot (FAT32, at least 512 MiB–1 GiB).

Layout, (let our disk be sda)

Mount Point Partition Suggested Size Partition Type Filesystem
/boot sda1 512 MiB – 1 GiB EFI system partition FAT32
Btrfs Pool sda2 Remaining space Linux filesystem Btrfs
Data / Windows sda3 Optional NTFS / ExFAT NTFS

We have an extra partition, right? We’ll think about it later! So whatever we do won’t affect this one. Think of it as a data partition.

F.A.Q.'s

Why a unified Btrfs pool instead of separate partitions?

  • Btrfs subvolumes act like self-contained filesystems inside a single partition. Since @ and @home share remaining disk space dynamically, you never run into situations where your root partition runs out of space while your /home partition sits mostly empty.

Why no swap partition?

  • Dedicated swap partitions waste disk space if you don’t need them constantly. Modern Btrfs supports swapfiles cleanly, or you can use zram-generator (RAM compression). We will create and configure a swapfile in the post-installation guide.

Formatting partitions

For the EFI partition (/boot), format it as FAT32 (make sure you don’t accidentally reformat an existing EFI partition if you are dual-booting with Windows!):

1
mkfs.fat -F 32 /dev/sda1

For our main Btrfs storage pool partition:

1
mkfs.btrfs /dev/sda2
Tip

After formatting, you can label your partitions for easily identifying them later. For example:

1
2
fatlabel /dev/sda1 EFI
btrfs filesystem label /dev/sda2 ARCH

Mounting partitions & Btrfs Subvolumes

Btrfs Subvolume Layout

We create subvolumes to organize our data, enable instant snapshots, and cleanly separate dynamic or cache directories from system rollbacks.

We standardize on the official 5-subvolume layout used by archinstall:

  • @ -> / (Root filesystem)
  • @home -> /home (User personal files & configs)
  • @pkg -> /var/cache/pacman/pkg (Pacman package download cache)
  • @log -> /var/log (System and journal logs)
  • @snapshots -> /.snapshots (Btrfs root snapshot store)
Do NOT isolate /var or /var/lib/pacman!
Never create a generic @var subvolume or separate /var/lib/pacman into its own subvolume! The package database in /var/lib/pacman must stay inside the root @ subvolume. If /var/lib/pacman is isolated, rolling back your root filesystem snapshot will cause the installed binaries on / and the pacman package database to become desynchronized, leading to broken dependencies and system corruption.

Creating Subvolumes

Let’s mount the Btrfs partition to /mnt temporarily:

1
mount /dev/sda2 /mnt

Now create the 5 subvolumes:

1
2
3
4
5
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@pkg
btrfs subvolume create /mnt/@log
btrfs subvolume create /mnt/@snapshots

You can view all the subvolumes you created using:

1
btrfs subvolume list /mnt

Unmount /mnt:

1
umount /mnt

Mounting Subvolumes & Partitions

Now we remount the root subvolume (@) with safe, modern mount options:

1
2
# Mount root
mount -o noatime,compress=zstd,subvol=@ /dev/sda2 /mnt

Create the directory mount points:

1
2
3
4
# Create mount points
mkdir -p /mnt/{boot,home,.snapshots}
mkdir -p /mnt/var/log
mkdir -p /mnt/var/cache/pacman/pkg

Mount the remaining subvolumes and EFI partition:

1
2
3
4
5
6
7
8
# Mount remaining subvolumes
mount -o noatime,compress=zstd,subvol=@home /dev/sda2 /mnt/home
mount -o noatime,compress=zstd,subvol=@pkg /dev/sda2 /mnt/var/cache/pacman/pkg
mount -o noatime,compress=zstd,subvol=@log /dev/sda2 /mnt/var/log
mount -o noatime,compress=zstd,subvol=@snapshots /dev/sda2 /mnt/.snapshots

# Mount EFI partition
mount /dev/sda1 /mnt/boot
Btrfs mount options explained:
Option Meaning
noatime Disables access time updates on files when read. Greatly improves I/O performance and SSD life.
compress Enables transparent compression (zstd). Saves significant disk space and improves read speeds.
subvol Specifies which Btrfs subvolume to mount at the target mount point.

Selecting mirror

By default in the live boot, arch will generate mirrors in your mirrorlist file. You can achieve better download speeds by sorting fast local mirrors using reflector.

Reflector

With reflector you can easily update your mirrorlist:

1
reflector --latest 10 --sort rate --save /etc/pacman.d/mirrorlist

Manually

You can also use a text editor to edit /etc/pacman.d/mirrorlist directly:

1
nano /etc/pacman.d/mirrorlist

archlinux-keyring

To prevent invalid or corrupted package signature errors during installation, ensure the keyring is up to date:

1
pacman -Sy archlinux-keyring

Essential packages

Use the pacstrap(8) script with -K (to initialize an empty pacman keyring in the target system) to install the base system, kernel, development tools, Btrfs utilities, and networking:

1
pacstrap -K /mnt base base-devel linux-zen linux-firmware btrfs-progs nano networkmanager

Note on Kernels: We are installing linux-zen for optimized desktop performance. If you prefer the standard upstream kernel or the long-term stable kernel, simply replace linux-zen with linux or linux-lts.

Tip

If you are using the linux-zen kernel, you can optionally install linux-zen-headers for building kernel modules (such as DKMS drivers, VirtualBox, or NVIDIA):

1
pacstrap /mnt linux-zen-headers

System configuration

fstab

Generate the fstab file using UUIDs so Arch knows where to mount your Btrfs subvolumes and EFI partition on boot:

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

entering chroot

Now change root into your new system!

1
arch-chroot /mnt

chroot

This section covers essential configuration inside your new system.

root password

To set the root password:

1
passwd

We’ll need this password to log in on first boot, so make sure to remember it!

network

Enable NetworkManager so network services start automatically on boot:

1
systemctl enable NetworkManager.service

host-name

Set your system hostname:

1
nano /etc/hostname

Enter your desired machine name (e.g. archlinux) and save.

hosts

Configure /etc/hosts:

1
nano /etc/hosts

Append the standard local loopback entries:

1
2
3
127.0.0.1        localhost
::1              localhost
127.0.1.1        myhostname

Replace myhostname with the actual hostname you configured above.

Microcode

Install processor microcode updates:

  • For AMD CPUs:
    1
    
    pacman -S amd-ucode
    
  • For Intel CPUs:
    1
    
    pacman -S intel-ucode
    

Bootloader

Install GRUB and EFI boot manager utilities:

1
pacman -S grub efibootmgr

Install GRUB to the /boot EFI directory:

1
grub-install --target=x86_64-efi --bootloader-id=GRUB --efi-directory=/boot

Then generate the GRUB configuration file:

1
grub-mkconfig -o /boot/grub/grub.cfg

Localization

Edit /etc/locale.gen:

1
nano /etc/locale.gen

Un-comment your locale (for instance, remove the # before en_US.UTF-8 UTF-8). Save and exit (Ctrl+O, Enter, Ctrl+X in nano).

Generate the locales:

1
locale-gen

Set the system locale in /etc/locale.conf:

1
echo "LANG=en_US.UTF-8" > /etc/locale.conf

Additional steps

Timezone & Hardware Clock

Set your local timezone and synchronize the hardware clock to prevent clock desynchronization on first boot:

1
2
ln -sf /usr/share/zoneinfo/Asia/Dhaka /etc/localtime
hwclock --systohc

Substitute Asia/Dhaka with your region/city (see available zones in /usr/share/zoneinfo/).

You can also check the ArchWiki for further initramfs or console customization:

Wrapping up

Reboot

Leave the chroot environment:

1
exit

Unmount all partitions and reboot into your new Arch Linux system:

1
2
umount -R /mnt
reboot

What to expect on first boot

After rebooting, select Arch Linux in the GRUB menu. You’ll arrive at a terminal login prompt:

  1. Log in as root using the password you set during installation.
  2. For connecting to Wi-Fi via terminal, use the interactive NetworkManager TUI tool:
    1
    
    nmtui
    
    Select Activate a connection, choose your Wi-Fi SSID, enter the password, and you’re online!

Stuck in GRUB? If you ever find yourself in the grub-rescue shell, see below.

Grub rescue?

If you ever encounter the grub rescue shell (e.g. if grub-mkconfig was missed):

1. ls

List all available partitions and devices:

1
grub rescue> ls

2. set

Inspect current Grub environment variables:

1
grub rescue> set

3. set prefix

Set the prefix pointing to your GRUB directory (since /boot is mounted on partition 1):

1
grub rescue> set prefix=(hd0,gpt1)/grub

4. set root

Set the root partition to the boot partition:

1
grub rescue> set root=(hd0,gpt1)

5. insmod

Load the normal boot module:

1
grub rescue> insmod normal

6. normal

Launch the standard menu:

1
grub rescue> normal

7. boot

Boot the system:

1
grub rescue> boot

References

What’s next?

Now you can install your choice of desktop environment or window manager! Follow along in the next post for setting up minimal KDE Plasma and automated Btrfs snapshot boot support: