My Arch Installation Experience

Posted on December 26, 2021

Just a notice, I originally published this in December of 2021, but I updated it in May of 2023 for "readability". If you think it's bad now, you should have seen it then! Anyhow, happy reading.

The main reason I'm writing this post is that every time I went on a forum related to installing Arch, I found multiple comments saying something to the effect of: installing Arch is easy as long as you can read instructions because there's the Arch Wiki. Arch's wiki is an invaluable resource, but there are some decisions that are hard to make, and the wiki doesn't help you make those decisions. For me, this stood out most when trying to figure out how the bootloader worked. When you partition your drives, you have to be mindful of the bootloader you intend to use because your bootloader determines if you need a UEFI partition, or if a partition needs to be bootable. This is laid out in the wiki, but it didn't really stick until my fourth installation or so.

The goal of this post, then, is to end up with a minimal Arch distribution: booting into a TTY as a non-root user. Before I get into the technical stuff in the next heading, I wanted to give some background into the routes I chose to take. I'm coming to Arch from Pop!_OS, so installing Arch required learning a lot of new things. I had two primary motivators behind my switch: 1) I wanted to see what a pure Wayland system was like and 2) I wanted to use a window manager. Sway was in the Arch repositories, so that's what I went with. Since Wayland is still in development, I wanted packages that were more up-to-date than what Pop provides. I looked at Open SUSE and then Manjaro, but wasn't happy with either. I was reluctant to take on Arch due to the learning curve, but once I finally got past the installation process I was surprised to find that I loved it!

Now, I have the installation process all figured out! I go one of two routes depending on my scenario: If I'm installing to a machine with UEFI support, I use a Global Partition Table (GPT) with systemd-boot. If I'm running Arch in a virtual machine, I use Master Boot Record (MBR) with GRUB. I use QEMU for my virtual machines, but I had a hard time configuring UEFI support for them and decided it wasn't worth the trouble and MBR was fewer steps anyway. Everything is covered for both scenarios here in UEFI or MBR subheadings where applicable. I was thinking about going over everything from blank disk to working desktop, but I think a good place to stop is at a bootable operating system and TTY. So let's start after the installation media's created and we're at that first blinky cursor of potential.

Wireless Network

If you're installing Arch over a wireless network, any command involving network will fail since your handy installation media flash drive doesn't know your network credentials. Start iwd:

iwctl

Once the ctl's active, we can find the device we'll use to talk to the internet:

device list

Hopefully, one of these devices looks right. If not, check the wiki for guidance. Once identified, connect the desired DEVICE to an SSID:

station DEVICE connect SSID

What Time is it, Archie?

The first thing I do is sync the system clock with the network:

timedatectl set-ntp true

That's it. If only it were all that easy! Just kidding, I'm a glutton for punishment.

Partition Drives

Now to format the drives and start from a clean slate! A good practice I have established for myself is to always check which drive to use by running

fdisk -l

I have lost track of how many times I've formatted the wrong drive, and frankly, I don't have the stomach to do so. It would only engender regret and woe. For the sake of following along, we'll say the disk to use is dev/sda. We've found the drive, it's time to dive! Get into that fdisk TUI:

fdisk /dev/sda

What happens next depends on if UEFI was being cooperative. Let's look at both branches to this quandary of a question!

UEFI

Assuming the UEFI installation media booted up, and we're still in fdisk, it's time to create a new GPT partition table by entering g. Create UEFI partition by entering n and making the partition 512M in size. The default partition type is linux, which is no good here, so change that by entering t and selecting 1 for EFI System.

Next comes the decision of creating a swap partition. Nowadays, I encrypt with LUKS, and it's easier for me to just use a swap file on the encrypted partition. This way, when I use hibernate, the system memory is stored in the encrypted partition and more difficult to extract should my computer get stolen. If a swap partition is desired, though, it's easy to create by entering n and making the partition 4G (or whatever size). Again, swap is not linux, so change that partition's type by entering t and selecting 19 for Linux Swap.

Now, arguably the moment we've all been waiting for: create a root partition. Entering n and making the partition occupy the remaining space gets it done, which is less fanfare than the other two partitions got. The partition type of should be Linux filesystem already, but if it isn't, it can easily be made so by entering t and selecting 20

With partitions done, it's time for write and flight. Enter w. Now how would I do this if I were using good ol' GRUB?

MBR

We're using a different partition table, so it's not surprising that the partitions will be created a bit differently (although I was surprised the first time). We create a new DOS partition table by entering o (not g, the rest will be so confusing). This partition table already saves a little space up front for the boot record, so no need for its own partition.

I've never created swap partition for a GRUB system, so I won't comment on it, lest I lead my or someone else's future self astray.

I have, however, used a GRUB system with a root partition, so let's create said partition by entering n and making the partition occupy the entire disk. The partition type should be Linux, which is great, it just needs to be bootable, which can be accomplished by entering a. We can end with delight by performing a write by entering w.

Create File Systems

Since the partition setup is different between UEFI and MBR, it's probably not surprising that formatting the partitions will be different, too. We'll start with UEFI again.

UEFI

Once we're out of fdisk, we can create a UEFI file system:

mkfs.fat -F32 /dev/sda1

If a swap partition was made, now's a great time to set it up:

mkswap /dev/sda2
swapon /dev/sda2

If you're going the swap file route, you can set that up at any time, I'll cover it in another post about disk encryption. Finally, create a root file system:

mkfs.ext4 /dev/sda3~

MBR

Somewhat off-topic, but this is why I don't mind my VMs running MBR: One partition, one command! Create root file system:

mkfs.ext4 /dev/sda1

Mount Up

The file system is set up, so now we can install stuff. All we have to do is tell the installer where to put files. The first thing I mount is the root partition (sdaN where N would be 3 for UEFI and swap partition or 1 for MBR according to the fdisk commands executed above):

~mount /dev/sdaN /mnt

If using UEFI, create a /mnt/boot/ directory and mount the UEFI partition (sdaM where M is 1 according to above fdisk commands):

mount /dev/sdaM /mnt/boot

Prepare for Entry

Now that we're mounted up, time to install base packages:

pacstrap /mnt base linux linux-firmware

Now is also a great time to decide how you want to manage your network. For a while, I used dhcpcd and wpa_supplicant. This worked great until I tried using multiple networks. Rather than figure out how to keep separate configurations for different networks, I looked for a package to manage that for me and switched to NetworkManager, which is in the Arch repositories as networkmanager. I also throw in sudo, mesa, and nano because I tend to forget them. Next, I create me an fstab file:

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

Now we can configure the system as its root. We're one step closer to being a real person as far as this machine can tell.

I'm In

With that, we can now start acting as the root user of the file system:

arch-chroot /mnt

Any good system needs a time zone, so let's set ours:

ln -sf /usr/share/zoneinfo/US/Central /etc/localtime

You can navigate around /usr/share/zoneinfo/ to figure out which one best fits your location. After the time zone's set, I set the hardware clock from the system clock I set at the outset:

hwclock --systohc

Now, it's time to get our locales. Edit /etc/locale.gen and uncomment the locales you want. Mine are en_US.UTF-8 UTF-8 and en_US ISO-8859-1. Now generate them:

locale-gen

Set the LANG variable:

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

Set the host name:

echo "ArchPC" > /etc/hostname

Slap this in /etc/hosts:

127.0.0.1    localhost
::1          localhost
127.0.0.1    ArchPC

Give it the Boot

That wraps up the system config, but how do we boot it?

UEFI and Systemd-Boot

The boot partition should already be mounted to /boot/. If it's not, see this section, the run bootctl:

bootctl install

Replace contents of /boot/loader/loader.conf with the two lines below:

default arch.conf
timeout 0

I don't like hanging around in the boot-loader for any amount of time, hence the timeout 0 line. Anyway, next we tell systemd how to boot Arch! Create file /boot/loader/entries/arch.conf with the following contents:

title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options root=PARTUUID=<PARTUUID> rw quiet splash

If you haven't guessed, PARTUUID will be replaced with something much more difficult to remember. I like to get that options line fleshed out by running blkid, which gives a readout of all the disks and where they're mounted. Generally, if the root partition is on dev/sda3, what I like to do is run blkid | grep /dev/sda3 >> /boot/loader/entries/arch.conf. Make sure there's two greater-than symbols and not one, lest you overwrite the file. From there, return to the /boot/loader/entries/arch.conf file, remove the extra text from the grep output, and fill in the rest of the options line.

MBR and GRUB

This is substantially easier than fiddling with systemd-boot and UEFI. First, install grub and generate the config file:

grub-install --target=i386-pc /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

Laptop-Specific Stuff

My laptop has an integrated Intel GPU, and most require mesa drivers to function properly:

pacman -S mesa

Network Setup

We're finally getting around to making use of all that deliberation we did earlier on which network management solution to use. I'm only looking at NetworkManager, the other solutions weren't much fun and frankly I don't remember them, anyway. The first thing to do is enable the service:

systemctl enable --now NetworkManager

If on WiFi, find a suitable network:

nmcli device wifi

Once the network's identified, punch in the SSID and password:

nmcli device wifi connect SSID password PASSWORD

Root Login

Technically, we should be able to reboot, remove the installation media, and see the login prompt we've been working for, but we wouldn't be able to login. Let's spare ourselves the misery of a premature celebration and set the root password by running passwd and following the prompts.

It's finally time to login as root. The true root, not this shell of a root we've been impersonating. Reboot and remove installation media. You're ready, I can feel it:

reboot now

Hopefully, we are hearing ourselves say "We did it!" as that coveted login screen appears. If it doesn't, I hope you find the guide you are looking for. Clearly it was not this one.

Now What?

Since you don't want to log in as root all the time, let's create a new user and give them sudo access (via the wheel group):

useradd -m -G wheel user

Arch provides the wheel group, but doesn't give it anything by default, so let's fix that:

EDITOR=nano visudo /etc/sudoers

This should open a file. All we have to do is uncomment the line # %wheel ALL=(ALL) ALL by removing the #. Now all the user needs is a password:

passwd user

Exit root by entering exit and log in as your brand-new user, bringing us to the end of this post. From here, a desktop environment or window manager (or both, unless you intend to use Wayland) need to be installed, but that's just a matter of installing things. When I was figuring all of this out, it was helpful to read through a bunch of Arch installation posts to see how multiple people got through the process. My hope is that this post serves as another data point to help provide some clarity to the less intuitive parts of the Arch Wiki's installation guide.