How to Install Arch Linux

Use updated, cutting-edge software and packages with this rolling-release model

The Arch Linux logo.

Arch Linux is a powerhouse Linux distribution that offers a rolling release, so all of your software is always up to date. But with that power comes a bit of operating system installation complexity. In other words, installing Arch Linux isn’t easy … but not impossible. Here you will learn how to install Arch Linux as a virtual machine (using VirtualBox). The process is the same if you’re installing on bare metal (the only difference being the need to create a bootable media, such as a USB drive or CD/DVD for the bare metal installation). Taking your first steps using a virtual machine makes the process of learning a bit easier.

This tutorial will not detail the steps for creating the VirtualBox virtual machine. To learn how that process is completed, read Run Ubuntu Within Windows Using VirtualBox. The steps for creating a virtual machine in VirtualBox are similar, regardless of hosting platform.

Download the ISO

The first thing you must do is download the latest Arch Linux ISO file. Point your browser to the Arch Linux Download page and download the latest image to your hard drive. With that ISO image, you’ll create your virtual machine in the standard fashion. Once you’ve created the virtual machine, boot Arch Linux. You will eventually find yourself faced with a bash prompt (where you can begin running the necessary commands).

Partitioning the Drive

The Arch Linux ISO boots to a command prompt.

The first thing to be done from the command prompt is partitioning the drive. Issue the command:

fdisk /dev/sda

Next type “n” (without quotes) and hit Enter. Now type “p” (without quotes) and hit Enter. You will then want to keep the default partition number (1) by hitting Enter. Do the same when prompted to select the First sector and for the Last sector (just hit Enter). Finally type “w” (no quotes) to write the changes to the disk.

Formatting the Partition

Now we have to format the newly created partition. To do this, issue the command:

mkfs.ext4 /dev/sda1

Mount that newly formatted partition with the command:

mount /dev/sda1 /mnt

Installation

The Arch Linux base installation is complete.

And now we install base Arch Linux package. This will install the bare minimum needed to run the system (such as GNU BASH shell, data compression tool, file system utilities, C library, compression tools, Linux kernels and modules, library packages, system utilities, USB devices utilities, vi text editor, and more) and is accomplished with the command:

pacstrap /mnt base base-devel

Configuring the System

Next we need to configure the system. The first step in this process is to generate an /etc/fstab file, which defines how block device and remote file systems are mounted. Do this with the command:

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

Now we need to change the root directory for the current running process with the command:

arch-chroot /mnt

Setting Timezone, Hardware Clock, and Locale

Setting the locale information in Arch Linux by commenting out the necessary line.

We need to set both the timezone and the locale for the installation. This is done with the following commands:

ln -sf /usr/share/<ZONEINFO>/<REGION>/<CITY> /etc/localtime

Where ZONEINFO is the Country, REGION is the State, and CITY is the city. For example, if you are in Louisville, Kentucky, your command would be:

ln -sf /usr/share/America/Kentucky/Louisville /etc/localtime

Set the hardware clock with the command:

hwclock --systohc --utc

And now we set the locale, which defines the language and local settings. To do this, issue the command:

vi /etc/locale.gen

At this point, you are using the vi text editor, which is far from user friendly. What you need to do is first hit the “i” key to enter insert mode. Next scroll through and uncomment (remove the “#” symbol from the beginning of a line) the locale that suits your location/need.

By default United States English is uncommented. If you are not located in America, you’ll want to comment that out and uncomment the best location.

Once you’ve taken care of this change, hit the Escape key, followed by wq and Enter. This will save and close the file. Generate the necessary locale file with the commands:

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

Substitute your locale for en_US (if necessary).

Set the Hostname and Install the Bootloader

Setting the hostname in Arch Linux with the echo command.

In order for your Arch Linux distribution to boot, you must install a bootloader. Before we do that, let’s set the hostname for the system (choose the hostname that suits your needs). The command for this is:

echo HOSTNAME > /etc/hostname

Where HOSTNAME is the name you’ve chosen.

Install the bootloader with the following commands:

pacman -Sy grub
grub-install /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

Finally, set a root password with the command:

passwd

At this point, you have a base installation of Arch Linux. If you reboot the system, you’ll find yourself at a command prompt, where you can log in as the root user.

Configure Networking

The command to locate your networking device name.

Before continuing on, you’ll need to configure networking. If you attempt to ping something from the command line, it becomes all too clear that networking isn’t functioning yet. The first thing to be done is find out the name of our networking device. That can be found with the command:

ip link

You’ll see a listing for lo (loopback) and one for a standard network interface. To configure the network interface, issue the command:

vi /etc/systemd/network/DEVICE_NAME.network

Where DEVICE_NAME is the name of your networking device.

In this empty file, paste the following:

[Match]
name=en*
[Network]
DHCP=yes

Save and close that file.

Start and enable networking with the commands:

systemctl restart systemd-networkd
systemctl enable systemd-networkd

Next create the necessary DNS entries with the command:

vi /etc/resolv.conf

In that file, add the following:

nameserver 8.8.8.8
nameserver 8.8.4.4

Save and close that file.

Networking should now be functioning.

Install a Desktop Environment

Let’s install the GNOME desktop environment. To do this, issue the commands:

pacman -S xorg xorg-server
pacman -S gnome gnome-extra

During the above commands, hit Enter to select the defaults for all options.

Finally, start and enable the display manager with the commands:

systemctl enable gdm.service
systemctl start gdm.service

You should now be able to log into GNOME and enjoy your Arch Linux installation.