How to install Arch Linux with BTRFS

In this post I’m going to cover how to install arch Linux with BTRFS.  Additionally, I’m going to go beyond the basic installation of Arch and I’m going to cover getting a fully functional Arch installation with KDE Plasma as well.  This setup is my basic setup for most computers that I install Arch on.  If you aren’t sure if Linux is right for you, you can check out my last article as well, which might help you decide.

How to install Arch Linux with BTRFS (overview)

  1. Create and boot the Arch Installation CD
  2. Prepare the disk
  3. Format as BTRFS and Mount
  4. Create and Mount BTRFS Subvolumes
  5. Install Arch Linux base system
  6. Configure the Arch system
  7. Install Graphical System
  8. Install a Bootloader

Table of Contents

Create and Boot the Arch Linux install disk

Download the Arch Linux ISO.

Head over to https://archlinux.org/download/ and download the ISO either using the torrent/magnet link, or scroll down to find that ‘direct download‘ that seems like it’s the closest to your physical location.

Download Arch Linux
Arch Linux Downloads Page

Flash the ISO to a USB drive.

Use software like Rufus or Etcher to flash the ISO file to a USB drive.  This guide will be covering a BIOS install, so make sure that you use the appropriate settings in your software.  Additionally, if you are using Rufus make sure that you flash the ISO in ‘dd mode‘.

Rufus
Rufus
Etcher
Etcher

Boot from the USB on the computer.

Insert the freshly flashed USB drive into the computer that you plan on installing Arch with BTRFS on.  Power on the computer, and use the appropriate key to open the boot menu and choose the USB drive.  This varies for each motherboard but it is usually one of the higher function keys like F11 or F12.

Alternatively you can set the USB is the first boot device in your BIOS.

Boot Menu
Boot Menu

After booting off of the USB, you should be presented with the boot menu of the USB drive and it should look like this.

Arch Boot Menu
Arch Linux Boot Menu

If it looks different (all black and white without a logo) you have booted using UEFI.  This guide will not be covering an EFI install.  The installation process is mostly the same, however the partitioning and bootloader sections will be slightly different.  If you are at least a little bit comfortable with installing Arch, you may still be able to figure it out.  Otherwise, go back to the first step and re-flash using the appropriate settings to boot into BIOS mode instead.

Prepare the Disk.

Now that we have booted into the Arch live environment, we can now get the disk ready to set up BTRFS and install Arch.

Find the name of your install disk.

Use the lsblk command to find out the disks that are available on the system.  They will often be called sd<letter> if it’s a SATA disk, or nvme<number> if it’s an NVMe disk.

				
					lsblk
				
			
lsblk output
lsblk output

You can see in my command output that the disk I’m looking for is sda, yours my be different.  If it is, replace any future references to sda or /dev/sda in this guide with whatever your disk is called.

Create the root partition.

Use cfdisk to create the one and only partition we will make on this disk.  The partition will be of type 8300 (Linux) and it will be the entire size of the disk.  We will later use BTRFS to create the segmented partitions that you may be familiar with.

WARNING: You will be wiping all data on the chosen hard drive.  It’s important that you make backups of any data, and be sure that you are aware and prepared to lose everything.

				
					cfdisk /dev/sda
				
			

When cfdisk opens, choose the dos option.

cfdisk choose dos
Choose the DOS option

Once cfdisk is open, there should only be one line with label “Free Space”, otherwise select each line using the up and down arrows, and choose delete with the left and right arrow keys until your screen looks like this.

cfdisk Free Space
Free Space only

Choose new by using the left and right arrow keys and hit enter.  Hit enter two more times to create a new partition.  It will automatically be given the appropriate partition type.

Use the arrow keys to go over and choose write.  After hitting enter on write you will need to type the word yes to confirm that you will be destroying all data on the selected drive.

Afterwards use the arrow keys to move over to the quit option and hit enter.

Format the partition.

Now that the partition is created, we need to format it as BTRFS.  We will use the command mkfs.btrfs.

				
					mkfs.btrfs -L "Arch" /dev/sda1
				
			
Format as BTRFS
Format the partition as BTRFS

Mount the BTRFS partition.

Now we need to create a directory, and mount the newly formatted partition.

				
					mkdir /mnt/btrfs-root
mount -o defaults,relatime,discard,ssd,nodev,nosuid /dev/sda1 /mnt/btrfs
				
			
Mount the partition
Mount the partition

Create and mount the BTRFS subvolumes.

Subvolumes of BTRFS are probably the main reason people want to learn how to install Arch Linux with BTRFS.  Subvolumes work similar to physical partitions of the disk but have the advantage that they don’t need to have a defined size, and can also be created and modified on the fly.  We will also be setting up BTRFS for using snapshots in the future which is another primary reason for BTRFS.  

Create the BTRFS subvolumes.

We need to create two directories under the mounted BTRFS partition.   One will be _current which will contain all of our current running files, and a _snapshot directory that will house any snapshots that we take in the future.

				
					mkdir -p /mnt/btrfs-root/__snapshot
mkdir -p /mnt/btrfs-root/__current
				
			

After we make the directories, we’ll create the root and home subvolumes.

				
					btrfs subvolume create /mnt/btrfs-root/__current/root
btrfs subvolume create /mnt/btrfs-root/__current/home
				
			
Create BTRFS Subvolumes
Create the BTRFS subvolumes

Mount the BTRFS subvolumes.

The last thing we need to do before we can actually start installing Arch Linux is to mount the new subvolumes.

				
					mkdir -p /mnt/btrfs-current
mount -o defaults,relatime,discard,ssd,nodev,subvol=__current/root /dev/sda1 /mnt/btrfs-current
mkdir -p /mnt/btrfs-current/home
mount -o defaults,relatime,discard,ssd,nodev,nosuid,subvol=__current/home /dev/sda1 /mnt/btrfs-current/home
				
			
Mount subvolumes
Mount the subvolumes.

Install Arch Linux

The disk is all prepared, and now we can move forward to installing and configuring Arch.

Install the base Arch System.

The Arch live CD makes it easy to install arch with BTRFS because pacstrap actually installs the entire base system in one single command.

				
					pacstrap /mnt/btrfs-current base base-devel
				
			
Pacstrap
Pacstrap installing the base system

chroot into the new installation.

Now that pacstrap has installed the base system, we can chroot into it and start configuring our system.  We use arch-chroot to get into the system.

				
					arch-chroot /mnt/btrfs-current /bin/bash
				
			
arch-chroot into new system
arch-chroot into the new system

Install btrfs software.

Now that we’re chrooted into the new system, we’re gonna need to install the btrfs-progs, mkinitcpioand linux packages.  These packages contain all of the software we need to interact with our btrfs filesystem as well as generate a new inital ramdisk to load in btrfs.

				
					pacman -S btrfs-progs mkinitcpio linux
				
			
Install btrfs-progs
Install btrfs-progs

Configure the Arch system

At this point, you’ve already learned how to install Arch Linux with btrfs, but in all reality this isn’t a usable system yet.  As a matter of fact it won’t even boot, so we have to do some configuration first.

Set the system locale.

Now we need to set up the systems locale.  Use vim or whichever editor you prefer (try nano if you’re new) and edit the /etc/locale.gen file.

Note: If your editor of choice isn’t installed, install it with pacman -S <editor> (ex. pacman -S nano)

Uncomment your locale
Uncomment your locale

That chooses the locale we want, and then we will generate the locale by using locale-gen.  Afterwards we’ll set up the locale.conf file and export it to the shell.

				
					locale-gen
echo LANG=en_US.UTF-8 > /etc/locale.conf
export LANG=en_US.UTF-8
				
			
Generate the Locale
Generate the Locale

Set the system timezone.

Next up we need to set our timezone, which is as easy as creating a symlink.  I live in US Central, so I am going to choose America/Chicago.  There is a list of the available timezones here otherwise you can use the command timedatectl list-timezones to list the available timezones.  Once you find the appropriate time zone, remember it and press the “q” key to exit the list.

Set the timezone by creating a symlink from your timezone to the /etc/localtime file.

				
					# Make sure you do /usr/share/zoneinfo/<your timezone>
ln -s /usr/share/zoneinfo/America/Chicago /etc/localtime
				
			
Set the timezone - How to install Arch Linux with BTRFS
Set the timezone

Set the hostname.

Our next step is to set the hostname for our Arch installation.  Hostnames can be from 1 to 63 characters long, and the allowed characters are a-z, A-Z, 0-9, and -.  We will just write our hostname into the /etc/hostname file.

				
					echo 'my-arch-system' > /etc/hostname
				
			

Configure the initial ramdisk.

The ramdisk is a bit out of scope for this guide, but you can read more about it here and here.  What it basically is though, is everything that needs to be loaded into RAM for the Linux environment to get started.

Because we are running btrfs, we have a change that we need to make to the initial ramdisk.   Edit the /etc/mkinitcpio.conf file.  Find the HOOKS and remove fsck, and add btrfs.

Modify mkinitcpio.conf
Modify the mkinitcpio.conf

We’ve made the configuration change, now we just need to generate the ramdisk with mkinitcpio.conf

				
					mkinitcpio -p linux
				
			
Create ramdisk
Create ramdisk

Create a non root user.

You shouldn’t be using the root user, really ever, so let’s make ourselves a normal user.  Use the command useradd to create a new user, and set the password for the new user.

				
					# replace daniel with your desired username
useradd -m -s /bin/bash daniel
passwod daniel
				
			
Create a new user
Create a new user

Give the new user sudo privileges.

sudo allows regular users to perform actions as root when needed.  We can add sudo privileges by add the user to the wheel group with the usermod command, and enabling it in the sudoers file.  We edit the sudoers file with the command visudo.  By default visudo will automatically use vim however, you can change the editor by prefixing the command with EDITOR= (ex EDITOR=nano visudo)

				
					# make sure you replace `daniel` with your username
usermod -aG wheel daniel
visudo
				
			
Enable wheel group
Enable wheel group

Install a graphical system.

We’ve got a barebones system all set up now.  The next thing we need is a graphical system.  I love KDE Plasma but there a ton of options out there.  A quick Google search will certainly get you a guide on how to install any other sort of system.

Install the necessary packages.

As you would expect, we need a few packages for this to work.  We’re gonna install a graphical display manager (sddm), the X window system (xorg), KDE Plasma (plasma), and the associated kde programs that are built for KDE (kde-applications).

				
					pacman -S xorg plasma kde-applications sddm
				
			

It will ask about 6 questions, you can just hit enter to accept the defaults on every question.  Depending on your internet connection and computer this could take a while.  Of the desktop environments out there, KDE tends to on the heavier side.  This tends to be the longest part of learning how to install Arch Linux with BTRFS because KDE is the heaviest part of the entire installation.

Install Plasma
Install Plasma

Enable SDDM display manager, and NetworkManager.

We need to enable the SDDM display manager on boot so that it can take over hand handle logins when the computer starts, as well as enable NetworkManager to handle the network on boot.

				
					systemctl enable sddm
# Notice the case on NetworkManager, it always gets me
systemctl enable NetworkManager
				
			
Enable Services - How to install Arch Linux with BTRFS
Enable Services

Install the bootloader.

We’re almost there, this is the last step of the installation.  We need to install the bootloader, which as you might have guessed, handles the system at boot.

Install the necessary packages.

There’s only one package to install, and that’s the bootloader itself grub-bios.

				
					pacman -S grub-bios
				
			
Install Grub - How to install Arch Linux with BTRFS
Install Grub

Install grub to the MBR.

Now that the package is installed, we need to install grub onto the MBR of the disk using the grub-install command.

				
					grub-install --target=i386-pc --recheck /dev/sda
				
			
Install grub to the MBR
Install grub to the MBR

Generate a grub configuration.

Now that Grub is installed to the MBR, we just need to generate a configuration for it, and it will be all set to go.

				
					grub-mkconfig -o /boot/grub/grub.cfg
				
			
Generate the grub configuration - How to install Arch Linux with BTRFS
Generate the grub configuration.

Clean up installation and reboot.

The installation is all complete at this point, so we need to get out of our chroot and unmount all the partitions.  Then we will be able to reboot into our new system.

				
					exit

umount /mnt/btrfs-current/home
umount /mnt/btrfs-current
umount /mnt/btrfs-root

reboot
				
			
Clean up and reboot
Clean up and reboot.

Upon a reboot (assuming everything went well) you will be presented with the SDDM default login screen.  From here you can use the user we created a bit ago and log into your new desktop.

SDDM Default Login
SDDM Default Login
KDE Plasma Desktop
KDE Plasma Desktop

Conclusion

Overall, learning how to install Arch Linux with BTRFS isn’t the most difficult task in the world, especially if you have even a little bit of experience with Linux in general.  If you look back through the guide it’s actually not that many commands and the concepts are mostly pretty straightforward.  BTRFS might be a little bit confusing to make sense of for some people but the documentation on the Arch Wiki is really great.

If you run into any issues, please don’t hesitate to get in touch with me.  You can leave a comment here, or you can also hop into my Discord server where there are others that can help as well.  Additionally you can contact me directly if you need to.  My information is the the Contact page.

Thanks a ton for reading, I really hope it was helpful!

Me
Daniel
I’m a web designer, developer, maker, father, husband, and U.S. Army veteran. I’ve been working professionally in the technology space for over ten years holding positions such as senior systems administrator, senior developer, and security analyst. I founded a company called Mozarks with my brother and have been working freelance ever since.
>