Arch install

Notes

This guide goes through installing Arch Linux on a UEFI system and assumes you want to wipe your disk clean before you install. If you want to keep some data on the disk you are installing Arch on, you dont want to follow the disk partitioning steps in this guide.

Report mistakes

If you find anything in this guide that is wrong or can be improved, please feel free to open an issue or a pull request here

Prerequisites

Bootable USB

This section is intended for Linux, if you're on Windows you download Etcher from their website listed in the previous section.

This section also assumes you have paru, the AUR helper installed, but any other helper should work the same way.

Steps

  1. Insert the USB into the PC.
  2. Install etcher: paru -S etcher-bin
  3. Run as root: sudo etcher
    • If you're on Windows, run it as administrator.
  4. Flash the ISO file onto the USB stick following the instructions in Etcher.

Reboot after the image has been flashed onto the USB and head into your UEFI setup. This can usually be done by pressing the Del key on boot although this might vary.

Pre-install Setup

This section takes care of partitioning the disk you are installing Arch on and creating file systems.

These following sections provide more information regarding each step:

  • Disk Partitioning — Clear disk and create partition(s)
  • WiFi — Setup WiFi (not necessary if you have a wired connection)
  • Pacman Mirrors — Setting up optimal pacman mirrors
  • Mounting — Mounting the new partitions

Disk Partitioning

This part of the guide is divided into two steps:

  • UEFI system
  • BIOS system

Note: For this guide we assume that the disk you're installing on is named /dev/sda.

Delete partitions

  1. List disks: fdisk -l
  2. Find the disk you want to install Arch Linux onto
  3. Use fdisk on disk: fdisk /dev/sda
  4. Wipe all partitions on disk: d
    • Repeat this step for all partitions

Creating partitions

UEFI Systems

If you have an UEFI system you need a ROOT and a BOOT partition.

BOOT partition

  1. Create the EFI/BOOT partition: n
  2. Partition number: Enter
  3. First sector: Enter
  4. Last sector: +512M
  5. Change partition type to EFI: t
  6. Press the number corresponding to EFI
    • list all types with L

ROOT partition

  1. Partition number: Enter
  2. First sector: Enter
  3. Last sector: Enter
  4. Write changes to disk: w

Make file systems

  1. Make BOOT file system: mkfs.fat -F32 /dev/sda1 && fatlabel /dev/sda1 BOOT
  2. Make ROOT file system: mkfs.ext4 -L ROOT /dev/sda2

BIOS Systems

If you have a BIOS system you only need a ROOT partition.

ROOT partition

  1. Create the ROOT partition: n
  2. Partition number: Enter
  3. First sector: Enter
  4. Last sector: Enter
  5. Write changes to disk: w

Make file system

  1. Make ROOT file system: mkfs.ext4 -L ROOT /dev/sda1

WiFi

Note: You can skip this part of the guide if you have a wired connection.

  1. Run iwctl
  2. Find your device: device list
  3. Scan for networks: station <DEVICE> scan
  4. List all scanned networks: station <DEVICE> get-networks
  5. Connect to your network: station <DEVICE> connect <NETWORK_SSID>
  6. Enter the network passphrase
  7. Quit iwctl: quit
  8. ping archlinux.org
    • If everything went well, you should see ping responses indicating you have an internet connection

Troubleshooting

General troubleshooting information can be found on the archwiki

Operation failed when trying to connect

Running journalctl -u iwd gives you information about what has gone wrong.

Recieved Deauthentication event, reason: 2, from_ap: true

If you are encountering this issue you can follow these steps:

  1. Create or open the iwd config file: vim /etc/iwd/main.conf
  2. Add:
    [General]
    ControlPortOverNL80211=False
    
  3. Save and quit: :wq
  4. Restart iwd: systemctl restart iwd.service
  5. Try connecting again

Pacman Mirrors

When installing the base packages needed for an installation you want the fastest download mirrors. To obtain these you can use reflector, a simple tool to update your mirrorlist.

  1. Update current mirrors: pacman -Syy
  2. Update the arch keyring: pacman -S archlinux-keyring
  3. Install reflector: pacman -S reflector
  4. Back up your current mirrorlist: cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
  5. Generate new mirrorlist (replace "XX" with your country code): reflector --protocol https -c "XX" -f 12 -l 10 -n 12 --save /etc/pacman.d/mirrorlist

Mounting

UEFI systems

  1. Mount ROOT: mount /dev/disk/by-label/ROOT /mnt
  2. Create mount point for BOOT partition: mkdir /mnt/boot
  3. Mount BOOT: mount /dev/disk/by-label/BOOT /mnt/boot

BIOS systems

  1. Mount ROOT: mount /dev/disk/by-label/ROOT /mnt

Base System

This section of the guide goes through the process of entering the new environment and setting up the base system which can be booted into.

These following subsections will go through each step of the process:

Arch Chroot

  1. Packstrap base packages into mount point: pacstrap /mnt base base-devel linux linux-firmware linux-headers neovim nano networkmanager dhcpcd iwd
  2. Generate FS Tab: genfstab -U /mnt >> /mnt/etc/fstab
  3. Enter mount point: arch-chroot /mnt

Locale & Time

In this section we setup the system language, clock and time-zone.

  1. Set timezone: timedatectl set-timezone Europe/Stockholm
    • Replace Europe/Stockholm with your time-zone
  2. Correct time and sync the system clock: hwclock --systohc
  3. Set locale: echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
  4. Generate locale: locale-gen

Network Configuration

Here we will set a hostname and configure /etc/hosts.

Note: replace all instances of arch with your preferred hostname in the steps below.

  1. Set hostname: echo arch > /etc/hostname
  2. Open and edit /etc/hosts using either nvim or nano:
  127.0.0.1  localhost
  ::1        localhost
  127.0.1.1  arch.localdomain arch
  1. Enable NetworkManager: systemctl enable NetworkManager.service

Additional steps for wifi

  1. Connect to wifi using iwctl (refer to the wifi steps)
  2. Enable dhcpcd: systemctl enable dhcpcd.service
  3. Run dhcpcd: dhcpcd
  4. Test your connection: ping archlinux.org

Account Setup

This section takes care of these things:

  • Creating a new root password
  • Creating a new user with the following things:
    • A home directory
    • Membership in the "wheel" group
    • A new password
  • Permit the "wheel" group to use sudo

Steps

  1. Set root password: passwd
  2. Create user: useradd -G wheel -m <user-name>
  3. Set new user password: passwd <user-name>
  4. Grant wheel group sudo access: echo "%wheel ALL=(ALL) ALL" >> /etc/sudoers

Boot Manager

  1. Install packages: pacman -S grub os-prober efibootmgr
    • Omit efibootmgr if you have a BIOS system
  2. Install boot loader: grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub
  3. Make boot loader config: grub-mkconfig -o /boot/grub/grub.cfg

Finishing Up

  1. Exit the arch-chroot environment: exit
  2. Unmount BOOT: umount /mnt/boot
  3. Unmount ROOT: umount /mnt
  4. Reboot and remove the USB: reboot

Final words

That's it! You now have a basic working installation of arch. It's worth noting that you, following these steps, won't have a graphical interface but this can be added. I won't go through that in this guide but there are plenty of resources elsewhere.