Arch Linux installation - step by step

Here it is - a complete guide to installing the Swiss knife of Linux distributions: the big, powerful and rough around edges Arch Linux. Today comes the day when you should become a Linux geek.

Arch Linux installation - step by step

Arch Linux - the best (and the worst) Linux there is! Why is it the best and the worst at the same time you ask? Let me explain...

Arch Linux is the best

The design approach of the Arch development team follows the KISS principle ("keep it simple, stupid") as the general guideline, and focuses on elegance, code correctness, minimalism and simplicity, and expects the user to be willing to make some effort to understand the system's operation. This makes the OS perfect for anyone trying to understand how Linux works after learning the basics on Ubuntu/Debian/Fedora etc. and to all Linux gurus tired of distributions forcing them to constantly adjust to the standards dictated by the development team, getting locked-out of some packages etc.

Arch Linux, by definition, is what Linux is truly about - freedom. Nobody's going to tell you what packages you have to use, what GUI to choose or what you can and cannot do with your OS. The distribution might seem to be rough around the edges and brutal, however once you learn it, you will definitely appreciate the cutting edge Linux performance which it is capable of.

Arch Linux is the worst

At the same time, Arch Linux is not a good operating system if you expect it to be stable straight out of the box, have excellent support or be enterprise ready.

While Arch has one of the best wikis out of all Linux distributions, covering nearly anything you could possibly imagine, there's no organization or company behind it. Even if you'd be willing to pay for the support, you just won't get it - it's not how Arch works. If you ever get stuck or your Arch crashes, the best what you can hope for is getting help from the official forum from some other individual user like you.

Having all that said, I wouldn't recommend Arch as the OS for Linux beginners or production-critical servers (unless you are ready to provide the complete support yourself).

Keep on rolling babe!

Arch Linux uses a rolling release model, such that a regular system update is all that is needed to obtain the latest Arch software; the installation images released by the Arch team are simply up-to-date snapshots of the main system components. The installation wizard of the OS is as simple as it can get - there is none! We'll get to this later.

The Arch User Repository - The Holy Grail

In addition to the repositories, the Arch User Repository (AUR) provides user-made PKGBUILD scripts for packages not included in the repositories. These PKGBUILD scripts simplify building from source by explicitly listing and checking for dependencies and configuring the install to match the Arch architecture.

The AUR is the biggest Linux repository around, hosting millions upon millions of PKGBUILDs which make the Arch Linux the most "app-rich" Linux in existence.

PKGBUILDs for any software can be contributed by ordinary users and any PKGBUILD that is not confined to the Arch User Repository for policy reasons can be voted into the community repositories.

I am myself an AUR maintainer (which means I am responsible for keeping some of the PKGBUILDs up to date) for the following packages (some of which you might quickly recognise):

  • vision-client - Desktop email client for the Exchange OWA
  • bin32-vmware-server-console - Remote console for VMware Server
  • webvirtmgr - Web front-end for KVM virtual machines
  • vmware-vcli - VMware vSphere Command-Line Interface (vCLI)
  • ffmpeg0.10 - Complete solution to record, convert and stream audio and video
  • belle-sip - A Voice-over-IP phone
  • xvkbd - Virtual (graphical) keyboard program for X Window System
  • google-keep-desktop - Google Keep packaged as a desktop application
  • libview - A collection of widgets that were developed at VMware
  • vmware-vsphere-web-client-plugin - Firefox and Chromium plugin, to access virtual machines console from vSphere Web Client
  • canon-pixma-mg5300-complete - Complete stand alone driver set (printing and scanning) for Canon Pixma MG5300 series

Arch Installation Tutorial

Ok - enough with the intro. It's time to get our hands dirty and start installing this beast of an operating system.

Let's get started by choosing where to install Arch. I recommend giving this a first try on a virtual machine, but if you wish to install it onto a desktop or a laptop, you are free to do so - the installation steps are identical in either case.

Please note you will need an active internet connection to install Arch. Offline installation with the official .iso is not supported. If you are going to install Arch on a physical machine, you will also need a way to connect it to the internet over cable (ethernet/usb with tethering) as Wi-Fi drivers are not available by default.

Installation Media

Download the most recent Arch Linux arch.iso from the official repository and burn it to the USB drive using the following command (on Linux/macOS):

dd bs=4M if=/path/to/the/arch.iso of=/dev/sdX status=progress

where sdX is the device identifier of your USB stick (use fdisk -l to find that)

On Windows you can use software like Rufus to do the same.

Obviously, if you are going to install Arch on VM, you can ignore the burning part.

First Few Steps

Now comes the time to boot your device/VM using the USB stick/iso file. On most physical devices the boot selection screen can be reached by pressing F2/12 key. On some devices (like Lenovo laptops), you might have to press an additional security button.

On some physical devices, you might have to enable non-secure and/or legacy boot in BIOS/UEFI before you'll be able to boot using an USB drive.

Once you boot into the drive/iso, you'll quickly notice how simple the installation is:

Screenshot-from-2018-08-17-10-08-37

Yeah, that's it - you're now booted into a live Arch iso and from this point onwards - you are completely on your own (well, not really as I'll be guiding you through the installation; you know what I mean).

Network

As I mentioned above, you will need stable, cabled internet access in order to install Arch Linux. If your device has no ethernet port, you will need to use an USB dongle or mobile USB tethering to proceed.

After connecting the WAN cable (USB/ethernet/virtual switch), you will need to enable DHCP on the adapter to get the internet access or set a static IP address if your network does not have a DHCP server.

First, run this command to get the adapter number:

root@archiso ~ # ip link

1: lo <LOOPBACK, UP, LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00:00 brd 00:00:00:00:00:00:00
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000

Let's analyze the output:

  • 1: lo - this is a loopback interface used for connecting from your device back to itself (loop). Have you ever used an address //localhost or 127.0.0.1? Yeah, that's what it is.
  • 2: enp0s3 - this is your adapter interface name; if you have multiple adapters (wifi, ethernet, tether), they all will appear under next numbers (2:, 3: etc.). It's easy to determine which address is which by analyzing the name:
    • enpXXXX - cabled (ethernet) interface
    • wlpXXXX - wireless (Wi-Fi) interface
    • ensXXXX - tether interface (might also appear as enpXXXX)

Having that done, we can move on to the network configuration on the device:

DHCP

To set your network interface to DHCP, you only have to run this one simple command (replace enpXXXX with the interface name you've got from the ip link output)

root@archiso ~ # dhcpcd enpXXXXXX

Verify if you have indeed received an IP address by running:

root@archiso ~ # ip addr

(...)
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 14:ab:c5:8c:7d:9b brd ff:ff:ff:ff:ff:ff
inet 10.0.0.1/24 brd 10.0.0.255 scope global dynamic noprefixroute enp0s3

Static

To configure static IP addressing, run the following command first to configure an IP address, network mask and broadcast address:

root@archiso ~ # ip address add 10.0.0.1/24 10.0.0.255 + dev enpXXXX

10.0.0.1 - replace with your desired IP address
/24 - replace with your network mask in the shortened format
10.0.0.255 - replace with your broadcast address
enpXXXX - replace with network interface name we've got from ip link output

After setting that up, we still need to configure a default route (gateway) and some DNS servers:

root@archiso ~ # ip route add default via 10.0.0.1 dev enpXXXX

10.0.0.1 - replace with the IP address you've just configured
enpXXXX - replace with the device name you've used in the previous step

root@archiso ~ # echo nameserver 8.8.8.8 > /etc/resolv.conf

8.8.8.8 - replace with your desired DNS server address or leave it as it is to use the Google one

One it's all done, restart your network interface by bringing it down and then up again:

root@archiso ~ # ip link set dev enpXXXX down
root@archiso ~ # ip link set dev enpXXXX up

enpXXXX - replace with you good ol' interface name

Lastly, verify if your configuration worked by running:

root@archiso ~ # ip addr

(...)
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 14:ab:c5:8c:7d:9b brd ff:ff:ff:ff:ff:ff
inet 10.0.0.1/24 brd 10.0.0.255 scope global dynamic noprefixroute enp0s3

Pre-System Configuration

Firstly, let's load some keyboard settings. If you're using anything else than English keyboard, please do loop-up the codename for it (it's usually something simple like pl, us, de, es etc.). For all the English (UK) users, this is going to be uk.

Run the following command to load the configuration:

root@archiso ~ # loadkeys uk

Moving on, let's setup a time & date. I recommend using NTP for this:

root@archiso ~ # timedatectl set-ntp true

Disk partitioning

Let's start working on the disk. Before we do anything, we need to get our disk device name:

root@archiso ~ # fdisk -l

Disk /dev/sda: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

On my system, this turned out to be /dev/sda (as expected). You shouldn't get anything else unless your machine has more than one disk attached to it.

With that name in mind, we can finally start working on the partition table:

root@archiso ~ # fdisk /dev/sda

In this tutorial I will assume you know the basics of fdisk - if that's not the case, please read the following article: https://wiki.archlinux.org/index.php/Fdisk

On top of the above, I will not get into every single detail as that would be enough material for another post (Linux Partitioning Scheme). In this tutorial, we will assume the machine we're working on has a blank, unused disk with no other OS installed on it. You have been warned.

Once you've launched fdisk, we can start entering its commands into the CLI. The commands are very simple, usually one letter long. By following the steps below, you will create a partition table of:

  1. 512MB - /boot partition - used for booting into the OS
  2. 2GB - /swap partition - used for hibernation and many other tasks
  3. all other space - / partition - the main root of the filesystem

Having that said, let's roll:

  1. Creating /boot:
    Command (m for help) : n
    Press Enter three times;
    Enter +512M as the last parameter;
    Command (m for help) : t
    This will set the newly created partition as /boot;
    Enter 1 as the parameter to finish;
  2. Creating /swap:
    Command (m for help) : n
    Press Enter three times;
    Enter +2G as the last parameter;
    Command (m for help) : t
    This will set the newly created partition as /swap;
    Enter 82 as the parameter to finish;
  3. Creating /:
    Command (m for help) : n
    Press Enter four times;
  4. Writing changes to disk:
    Command (m for help) : w

You can verify if all of the above worked by running fdisk -l:

root@archiso ~ # fdisk -l

Disk /dev/sda: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel: dos
Disk identifier: 0x45642435df

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sda1       xxxxxxxxx xxxxxxxxx   xxxxxxx  512M  1 FAT12
/dev/sda2       xxxxxxxxx xxxxxxxxx  xxxxxxxx  2G   82 Linux swap
/dev/sda3       xxxxxxxxx xxxxxxxxx xxxxxxxxx  236G 83 Linux

Formatting Partitions

Next, we need to specify the file systems to be used on every partition. This can easily be done through mkfs and mkswap commands:

root@archiso ~ # mkfs.fat /dev/sda1
root@archiso ~ # mkswap /dev/sda2
root@archiso ~ # mkfs.ext4 /dev/sda3

As you've probably guessed, we are formatting each of the partitions to a different format:

  1. /dev/sda1 - as it's the /boot partition, it is recommended to keep it as FAT12
  2. /dev/sda2 - /swap is formatted to swap, obviously
  3. /dev/sda3 - as it's the / partition (hosting most of OS files), we are using a most reliable filesystem: EXT4

To finish configuring the /swap partition, we also have to run:

root@archiso ~ # swapon /dev/sda2

Mounting the disks and "chrooting" into Arch

The next part of the installation is going to take place "within" the system we have not finished installing yet. To do so, we need to mount the new partitions we've just created, install some base packages on them and then do a "chroot"...

"Chrooting", or a "chroot" on Unix operating systems is an operation that changes the apparent root directory for the current running process and its children. A program that is run in such a modified environment cannot name (and therefore normally cannot access) files outside the designated directory tree. In simpler terms, we are going to "live switch" from the OS we've booted from the USB stick (or iso file) to the Arch Linux we're installing in this tutorial.

Ok, speaking of the tutorial, let's move on:
Using the following command, mount the / partition at /mnt point:

root@archiso ~ # mount /dev/sda3 /mnt

Once that's done, create a new directory /mnt/boot:

root@archiso ~ # mkdir /mnt/boot

...and mount the /boot partition in there:

root@archiso ~ # mount /dev/sda1 /mnt/boot

Moving forward, let's run this beast of a command to download & install the base system packages:

root@archiso ~ # pacstrap /mnt base

Before we can do a "chroot", we should also configure the fstab (documentation)

root@archiso ~ # genfstab -U /mnt >> /mnt/etc/fstab

Finally, we can "chroot" into our new OS:

root@archiso ~ # arch-chroot /mnt

System Configuration

At this stage, you should notice that the hostname in the CLI has changed:

root@arch ~ #

This is expected as we've just "live switched" from Arch on the USB to the Arch on the disk.

There are a couple of more things to be done before we'll be able to call it a day though.

Locale (system language, date & time)

Run the following command to set the timezone:

root@arch ~ # ln -s /usr/share/zoneinfo/Europe/Dublin /etc/localtime

...and this one to set the clock accordingly:

root@arch ~ # hwclock --systohc --utc

Lastly, edit the /etc/locale.gen file. You will need to remove the # character to uncomment the locale you need. The editor which we're going to use is WYSIWYG-based (Windows Notepad etc.); keep in mind CTRL+X saves & exits the file.

root@arch ~ # nano /etc/locale.gen

Approve and submit the changes by issuing:

root@arch ~ # locale-gen

The above command will generate a file /etc/locale.conf. You can play around with it using nano if you wish to tweak any language/timezone settings.

Hostname

This one is simple. Run the following commands to set a custom hostname for your Arch:

root@arch ~ # echo customhostname > /etc/hostname
root@arch ~ # echo 127.0.0.1 customhostname >> /etc/hosts

Root & users

We will begin setting up the users by generating a password for the root:

root@arch ~ # passwd

Creating a new user (guru in this example) is a similarly simple process requiring only a single command:

root@arch ~ # useradd -m -G wheel -s /bin/bash guru
root@arch ~ # passwd guru

Boot configuration

The last step - configuring the /boot is probably simpler than what you were expecting at this point. All you have to do is to run these two commands:

root@arch ~ # bootctl --path=/boot install
root@arch ~ # blkid -s PARTUUID -o value /dev/sda1 > /boot/loader/entries/arch.conf

We're done... I think

The Arch Linux operating system has been successfully installed on your harddrive and we've performed some basic configuration on it. If you wish, you can leave the Live OS right now and reboot your machine:

root@arch ~ # exit
root@archiso ~ # umount -R /mnt
root@archiso ~ # reboot

...or you can stick around for few more minutes as in the following (optional) step, I'll show you how to install something which you might be missing once you log in to your brand new OS - the GUI.

Installing GNOME Desktop

Installing GNOME display manager is actually very simple (it used to be a pain in the @ss, but that's not the case anymore). All you have to do is:

root@arch ~ # pacman -Syu gdm gnome gnome-extra

The above command can be split in the following four parts:

  • pacman -Syu - in this bit, we're asking the package manager for Arch - pacman - to install a package (S), update the mirrors (y) and upgrade the system (u). It is recommended to always use the -Syu switch instead of -S as installing packages without updating the others on the system might break it. Full documentation for pacman can be found here.
  • gdm - is the login manager for GNOME and GNOME-like desktops. Without this package you will still have to log into the system using CLI and then manually start the desktop (GNOME) by issuing a command startx.
  • gnome - is a collection of packages required for a basic GNOME desktop implementation.
  • gnome extra - is an optional collection of most-used GNOME apps. This includes things like a browser, notepad, calculator etc. You can safely skip this bit if you wish to choose your own applications for these purposes later on.

At this stage, we can safely logout from the "chrooted" system and reboot the box. Arch Linux is now ready for use.

root@arch ~ # exit
root@archiso ~ # umount -R /mnt
root@archiso ~ # reboot

We're actually done!

Congratulations! If you made it to this step, you've successfully installed and configured Arch Linux. I hope you found this guide informative and helpful. I can't wait to see you on the Arch Forums and on the AUR. Your journey with Linux just got a little bit more fun :)

Will you attempt to install Arch Linux by yourself? If you'd encounter any issues along the way, do not hesitate to contact me @wilk_it_wizard or #sshguru

Related Article