Arch Linux installation guide

Arch Linux Simply Black wallpaper

The Arch Linux is a distribution focused on minimalism and efficiency, and follows a the “do it yourself” principle. For giving the user the power to build the system in the way he wants, its installation process may not be trivial to most PC users.

To overcome the complexity of the installation process, there are many solutions like the Zen Installer script or the ArcoLinux and Manjaro distributions, but the vanilla installation may be preferrable for its simplicity and flexibility.

Being so, I decided to present the steps I usually take in order to install Arch Linux.

This post doesn’t intend to be any ultimate installation guide, just a minimal reproducible script that guides my installation process. So I’m assuming that you are aware of the official installation guide (available in portuguese too).

There are many good tutorials online complementing the official installation guide and my favorites are:

My main motivation for writing this post is to present some troubles I had and doesn’t were covered in any tutorial available online. Finally, I will present some of the packages I usually install, like my window manager and text editors.

Installation

Initial setup

First, we need to set the correct keyboard layout. To me it is the ABNT2.

loadkeys br-abnt2

The Arch Linux installation relies on internet connection. To connect to a wireless network, we may use the iwctl command.

iwctl

This command will open a prompt where you can interact inside the program. You can list the devices, scan for networks and finally connect to a detected network:

device list # list the devices
station wlp3s0 scan # wlp3s0 is my device, detected with the previous command
station wlp3s0 connect SSID # you will get the SSID of your network with the previous command

To verify your connection you can ping the Arch Linux site.

ping archlinux.org

Partitioning the disks

To partition the disks we will use the fdisk utility. It has a concise built-in help so I will just describe the concepts behind the process. We just need 2 partitions: one for the EFI /boot/efi and other for /, but it is a good practice to use at least 4.

  • /dev/sda1: 512 MB for EFI system partition
  • /dev/sda2: 4 GB for Linux swap
  • /dev/sda3: 30 GB for /
  • /dev/sda4: rest of the space for /home

The official guide recommends at least 260 MB for the /mnt/boot/efi partition, but you may need some space in case of dual-boot.

There isn’t any consensus about the size of the swap partition or if a partition is really needed. You may prefer the swap partition over the swap file if you want to share it with other systems and I suggest the square root of the RAM for its size (in my case, square root of 16).

The Arch Linux is a really lightweight distro, and 10 GB may be more than enough for most of the users. I suggest 30 GB, but feel free to change its size.

After creating the partitions we need to format them:

mkfs.fat -F32 /dev/sda1
mkfs.ext4 /dev/sda3
mkfs.ext4 /dev/sda4
mkswap /dev/sda2

After that, we need to mount the partitions:

mount /dev/sda3 /mnt
swapon /dev/sda2
mkdir -p /mnt/boot/efi /mnt/home
mount /dev/sda1 /mnt/boot/efi
mount /dev/sda4 /mnt/home

This step is important because it will serve as reference to create the /etc/fstab file.

Installing the Arch Linux

Installing the Arch Linux is simple like that:

pacstrap /mnt base base-devel linux linux-firmware git neovim sudo

After installed, generate the /etc/fstab file with the genfstab command. Remember to pass the -U option to use the UUID of the partitions. Don’t worry, you still can edit the file later in case you want to auto mount any other drives, just be sure that it will be OK before rebooting.

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

Then, let’s change the root to the mounted driver and set up the system.

arch-chroot /mnt

Changed root

Clock setup

The time zones files are in the /usr/share/zoneinfo directory. You can identify your region folder with the ls command and inside it, your time zone file. The ln command here will create a symbolic link in the /etc/localtime folder.

ln -sf /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
hwclock --systohc

Hosts file

In the /etc/hostname file we will register our PC name. This is the name which will identify the computer in the network.

echo "pcname" >> /etc/hostname
vim /etc/hosts

In the /etc/hosts we will describe our IP addresses with the hostnames:

127.0.0.1      localhost
::1            localhost
127.0.1.1      pcname.localdomain      pcname

Locale

Uncomment your locale in /etc/locale.gen file. To me it’s the pt_BR.UTF-8 UTF-8 line. The locale-gen command is used to generate the locale.

vim /etc/locale.gen
locale-gen

In /etc/locale.conf we need to set an environment variable with our locale, and in the /etc/vconsole.conf we will set our keyboard layout (to me it is the br-abnt2).

echo "LANG=pt_BR.UTF-8" >> /etc/locale.conf
echo "KEYMAP=br-abnt2" >> /etc/vconsole.conf

Change root password

passwd

Add a user

The useradd command is used to create a user. The -m option is for creating a folder in /home directory and the -g wheel is for adding the user to the wheel group.

useradd -m -g wheel user
passwd user

Change sudo permissions

To execute commands with super user privileges without going root, we need to install the sudo package. After that, use the visudo command to edit the /etc/sudoers file. You will be able to edit the file directly, but the visudo is the safest way to do that.

sudo EDITOR=nvim visudo

You are able to change permissions in the /etc/sudoers file just by uncomment some of the existing lines. This is part of my file for reference:

## User privilege specification
##
root ALL=(ALL) ALL

## Uncomment to allow members of group wheel to execute any command
# %wheel ALL=(ALL) ALL

## Same thing without a password
%wheel ALL=(ALL) NOPASSWD: ALL

## Uncomment to allow members of group sudo to execute any command
# %sudo ALL=(ALL) ALL

In this case, I can execute the sudo command without my root password.

Grub installation

First we need to download the grub with pacman.

pacman -S grub efibootmgr

After that, for EFI boot, we have to run grub-install with --target, --efi-directory and --bootloader-id options set like that:

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

To generate the GRUB config file:

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

Download network utilities

My router sends a 2472 Hz signal, which isn’t common in the United States, so I have to make my wireless driver recognize my network with the crda utility. crda stands for central regulatory domain agent and relies on ISO standards to communicate with the kernel.

After that, the networkmanager and iw will be used to configurate the wi-fi network.

pacman -S iw crda networkmanager

Setting up the desktop environment

After downloaded all the network utilities, you are able to reboot and install all the softwares you want. If this is your first time with Arch, you will notice that you only have a black screen with a prompt, this is because we don’t have any graphic interface yet. There are plenty of options to install, and you can go for one of the desktop environments (DE) out there or you can simply install a window manager (WM).

To use any graphical interface, you need a graphical server like XOrg.

pacman -S xorg-server xorg-xinit

After that, you can install the window manager of your preference, or install a fully fledged desktop environment. I use my personal build of DWM, but if you have doubt about which one to install, you can read this section of Arch Wiki. In the future, I will show all the softwares I use and how to easily setup them.

Rik Ferreira Alves
Rik Ferreira Alves
Research assistant

Undergraduate in Geography at UNIMONTES.

Related