ArchLinux Tutorial, Part 1: Basic ArchLinux Installation

DZone 's Guide to

ArchLinux Tutorial, Part 1: Basic ArchLinux Installation

In this post, we take a look at how to get ArchLinux installed and running on our machine. Read on to learn more and get stared!

· Open Source Zone ·
Free Resource

This post is the first in a series of three posts on installing and configuring Archlinux with I3 Windows Manager on a hardware machine.

Part 1: Basic ArchLinux Installation

Part 2: X Window System and I3 Installation

Part 3: I3 Configuration and Operation


I have been an ArchLinux user for the past 10+ years and was running ArchLinux on all my desktops and laptops. The last time I deployed Arch on my desktop was almost six years ago, and I never reinstalled it since my first installation on a brand new (at that time) HW. The system is up-to-date with the latest kernel and apps.

uname -r

All these years, I was running XFCE and, I am happy with a very light desktop manager. Recently, I felt I needed a change for my desktop environment and decided to try something new. Besides, after all these years of experimentation in installing and uninstalling software packages, my system started to feel sluggish and slow in a few instances.

So I decided it was time to do a clean install and, in the process, to try a new GUI. I decided to try I3, as I was looking at it for some time but didn't find time until now to look into in more detail.

Download Archlinux ISO

ISO for Archlinux can be downloaded from Arch Linux Downloads. Select the closest mirror to you. The latest image at this date of writing is 2019.01.01, contains Linux Kernel 4.20, and is only 602.0 MB in size.

Once the image was downloaded you can write on a CD-ROM (if you still have one) or a USB stick.

Pre-Installation Checks

The current set up assumes you have EFI-enabled BIOS.

Once booted from a CD or USB stick, verify that the installation supports EFI.

ls -la /sys/firmware/efi

Verify that there is available disk space. Note that we assume we are installing on a /dev/sda disk; your disk name may be different, so pay close attention.

dmesg | grep sda && \lsblk

Initial Pre-Installation Configuration

You can install Arch from local media CD/USB stick, but my recommendation is to use online installation with the latest updated packages. For this, we will need to configure MirrorList for the Archlinux to use during installation.

nano /etc/pacman.d/mirrorlist

Manual Mirrorlist Configuration

Uncomment the mirrors located closest to you.

nano /etc/pacman.d/mirrorlist

Generate a Mirrorlist by specifying the type of the mirror and location.

Visit the Mirrorlist generator in the web browser on another computer and generate a Mirrorlist. Here's an example of the generated Mirrorlists that are near my location.

Server =https://sgp.mirror.pkgbuild.com/$repo/os/$arch
Server = http://mirror.nus.edu.sg/archlinux/$repo/os/$arch
Server = http://mirror.0x.sg/archlinux/$repo/os/$arch
Server = https://mirror.0x.sg/archlinux/$repo/os/$arch

Partition Disk

We will use two partitions: one partition for EFI 512 Mb, and one partition for the rest of the data.
We can partition in a more granular way depending on the requirements. For simplicity's sake, we use the minimum required for the two partitions.

Partition EFI

gdisk /dev/sda

Clear Partitions Table

This will remove all existing partitions.

Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): Y

Create EFI Partition

Command (? for help): n
Partition number (1–128, default 1):
First sector (34–268435422, default = 2048) or {+-}size{KMGTP}:
Last sector (2048–268435422, default = 268435422) or {+-}size{KMGTP}: +512M
Current type is ‘Linux filesystem’
Hex code or GUID (L to show codes, Enter = 8300): EF00
Changed type of partition to ‘EFI System’

Partition Root

Command (? for help): n
Partition number (2–128, default 2):
First sector (34–268435422, default = 1050624) or {+-}size{KMGTP}:
Last sector (1050624–268435422, default = 268435422) or {+-}size{KMGTP}:
Current type is ‘Linux filesystem’
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to ‘Linux filesystem’

Verify the partition table before writing.

Command (? for help): p
Disk /dev/sda: 268435456 sectors, 128.0 GiB
Model: Virtual Disk
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): 7A0873FE-EA25–4CC1–8543–1559F4861C2B
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 268435422
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number Start (sector) End (sector) Size Code Name
 1 2048 1050623 512.0 MiB EF00 EFI System
 2 1050624 268435422 127.5 GiB 8300 Linux filesystem

Write changes to the disk:

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.

Format Partitions

The 512 MB EFMI partition we created previously will need to be formatted on OLD FAT32:

mkfs.fat -F32 /dev/sda1

Format Root Partition

For simplicity's sake, we will format in EXT4 but you can always decide to use any other type of partition supported by Linux, like XFS, BTRFS etc.

mkfs.ext4 /dev/sda2

Mount Partition

mount /dev/sdc2 /mnt && \
mkdir /mnt/boot && \
mount /dev/sdc1 /mnt/boot

Archlinux Installation

First, we will need to update the system clock.

timedatectl set-ntp true

Once this is synced up, we can proceed to install Archlinux.

We will install the base OS, base development packages, and OpenSSH to allow us to SSH into the box.

pacstrap /mnt base base-devel openssh

The final step is to generate a fstab file that will include partition information.

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

Before we reboot into the newly installed OS, we will need to add a few configuration changes and install and configure the boot loader.

A Base Configuration of the Newly Installed Archlinux HERE

chroot into the newly installed Archlinux:

arch-chroot /mnt

Boot Loader

Configure the bootctl loader.

We will need to configure the boot menu for the boot loader:

bootctl install && \
echo “default arch” > /boot/loader/loader.conf && \
echo “timeout 3” >> /boot/loader/loader.conf && \
echo “editor 0” >> /boot/loader/loader.conf

cat /boot/loader/loader.conf

default arch
timeout 3
editor 0

Find the /dev/sda2 root partition UUID:

blkid -s PARTUUID -o value /dev/sda2
Note down PARTUUID nr Ex. 2caa8dfe-ac06-4f64-b719-2991249a52c4
  • Add PARTUUID to the /boot/loader/entries/arch.conf file.
nano /boot/loader/entries/arch.conf

title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options root=PARTUUID=af06626c-51a5–4e99–8e09–2eaf3ee90959 rw
This is optional if you have another OS installed, which you can add to the boot loader as well.
title Windows
efi /EFI/Microsoft/Boot/bootmgfw.efi

Install the Boot Loader

bootctl install && \
bootctl update && \
bootctl list && \

Archlinux Base Configuration

Generate the locale:

mv /etc/locale.gen /etc/locale.gen.bak && \
echo “en_US.UTF-8 UTF-8” >> /etc/locale.gen && \
echo “LANG=en_US.UTF-8” > /etc/locale.conf && \
cat /etc/locale.gen && \
cat /etc/locale.conf && \

Check the locale:

locale -a && \
localedef — list-archive && \

Configure the time zone:

I am based in Singapore. You may need to select the correct time zonein the /usr/share/zoneinfo/ file
ln -sf /usr/share/zoneinfo/Asia/Singapore /etc/localtime && \
ls -la /etc/localtime && \
hwclock — systohc

Enable SSH and DHCP services to start during the boot.

systemctl enable sshd.service && \
systemctl enable dhcpcd

The final steps are to change the root password that will allow us to log in after the restart:


Exit the chroot environment:


Un-mount the partitions:

umount /mnt/boot && \
umount /mnt

And reboot the system:


If all went well, you should be able to log in to the Archlinux shell.

We are not yet done with all our configurations, however.

Post Installation Configuration

Set the hostname.

In the below case, I name my box,arch you're free to name it whatever suits your desire:

hostnamectl status && \
hostnamectl set-hostname arch && \
hostnamectl status

Set the locale:

localectl list-locales && \
localectl set-locale LANG=en_US.UTF-8

Network Configuration

First, I will need to find our network interfaces:

ip a show && \
ip route show
  • Use a static IP. 
In the below case, my network interface name is enp3s0f0, but you may have a different name for your network interface.
nano /etc/systemd/network/20-wired.network



Use the dynamically allocated IP:

nano /etc/systemd/network/20-wired.network



Configure the DNS service:

In the below case, we will use the systemd resolved service
grep “DNS=” /etc/systemd/resolved.conf && \
sudo sed -i -e ‘s/#DNS=/DNS=’ /etc/systemd/resolved.conf && \
grep “DNS=” /etc/systemd/resolved.conf

cat /etc/systemd/resolved.conf

cat /etc/systemd/resolved.conf
We are using Google DNS, which has an SLA of 100%, but you can use other DNS IP entry points, like DNS=

Restart and reconfigure the network services:

systemctl enable systemd-networkd && \
systemctl enable systemd-resolved && \
systemctl start systemd-networkd && \
systemctl start systemd-resolved && \
systemctl stop dhcpcd && \
systemctl disable dhcpcd && \
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf && \
ls -la /etc/resolv.conf && \
resolvectl status

Check the resolver configuration:

cat /etc/resolv.conf && \
cat /run/systemd/resolve/resolv.conf

Add the time sync systemd service:

timedatectl set-ntp true && \
timedatectl status

Add an entry into the hosts file:

cat /etc/hosts && \
echo “ localhost.localdomain localhost” >> /etc/hosts && \
echo “::1 localhost.localdomain localhost” >> /etc/hosts && \
echo “ arch.localdomain arch” >> /etc/hosts && \
cat /etc/hosts localhost.localdomain localhost
::1 localhost.localdomain localhost arch.localdomain arch

Install Useful Linux Tools

pacman -Syyuu && \
pacman -S p7zip python unzip pygmentize docker \
vim htop git jq rsync tmux bash-completion keychain \
mlocate wget words lsof which go pciutils lshw pacman-contrib reflector

Update the latest and newest mirror.

Arch Linux uses a list of the mirrors where all packages are synchronized using.pacman -Syyuu
The file that keeps all mirrors is located in /etc/pacman.d/mirrorlist, and it is a good idea to configure the Mirrorlist file with the mirror that's fastest and closest to you. We will use the reflector tool that will configure the file automatically.

reflector - verbose - latest 200 - number 5 - sort rate - save /etc/pacman.d/mirrorlist

Start the Docker daemon:

systemctl enable docker && \
systemctl start docker

Create a New User and Group

It's not a good idea to run this as a user. The best practice is to configure a separate user that can be used as default and a root user in case you need to configure system files.

groupadd -r autologin && \
useradd -m -g users -G wheel,storage,power,docker,autologin,audio -s /bin/bash your_user_name && \
passwd your_user_name

Add sudo Access to the User



Login into the newly created user:

su - your_user_name

Install the AUR Package Manager

Users of Archlinux can use packages maintained by the community, called AUR. In order to use AUR, we need a tool similar to pacman to allow us to install packages from AUR.

A few AUR installers are available and, over the years, I have used a few, like yaourt and packer. Recently, I switched to YAY, and, so far, it works very nicely and without any issues.

Installing YAY

mkdir sources && \
cd sources && \
git clone https://aur.archlinux.org/yay.git && \
cd yay && \
makepkg -si && \
yay - editmenu - nodiffmenu - save

Optimizing the system for faster compilation of the source-based packages:

grep “COMPRESSXZ=(xz” /etc/makepkg.conf && \
grep “#MAKEFLAGS=\”-j” /etc/makepkg.conf && \
sudo sed -i ‘s/COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -T 8 -z -)/g’ /etc/makepkg.conf && \
sudo sed -i ‘s/#MAKEFLAGS=”-j2"/MAKEFLAGS=”-j9"/g’ /etc/makepkg.conf
grep “COMPRESSXZ=(xz” /etc/makepkg.conf && \
grep “#MAKEFLAGS=\”-j” /etc/makepkg.conf 
In the "COMPRESSXZ=(xz -c -T 8 -z -)" -T 8 represents the number of CPU cores and you can find the correct number by running "lscpu | grep "CPU(s):" | grep -v NUMA"

Optional: Add Color to the pacman Output

The final touch is to add some color to the package manager:

grep “Color” /etc/pacman.conf && \
sudo sed -i -e ‘s/#Color/Color/g’ /etc/pacman.conf && \
grep “Color” /etc/pacman.conf

In the next article, we will install and configure X Window and i3 Desktop manager.

archlinux ,iso ,linux ,open source

Published at DZone with permission of Ion Mudreac . See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}