/arch-linux-installation-guide

An easy to follow Arch Linux installation guide. This guide will show you how to properly install Arch Linux on UEFI/BIOS systems, ext4/btrfs file systems; using systemd-bootloader/GRUB and systemd-networkd/NetworkManager for networking. These are the given examples but I have provided links to sections with the information necessary to install any 86_64 system

Arch Linux

Arch Linux Installation Guide

The goal of this Arch Linux installation guide is to provide an easier to interpret, while still chomprehensive how-to for installing Arch Linux on x86_64 architecture devices. This guide assumes you are technically inclined and have a basic understanding of Linux. This installation guide was made with intentions of sticking to systemd (systemd-boot, systemd-networkd). Due to the vast amount of options/prefrences for networking tools & boot loaders, instructions for NetworkManager & GRUB were included to their respective sections

This guide is a mix of knowledge and information from the ArchWiki

I use Arch BTW


Contents

  1. Live Media Creation
  2. Verify Boot Mode
  3. Inital Network Setup
    3.1. Ethernet
    3.1. WiFi
  4. System Clock
  5. Disk Partitioning
  6. Swap Space (Optional)
    6.1. Swap Partition
    6.1. Swapfile
  7. Format Partitions
  8. Mount Partitions
  9. Install Essential Packages
  10. Fstab
  11. Change Root
  12. Time Zone
  13. Localization
  14. Network Configuration
    14.1. Systemd-networkd
    14.1. NetworkManager
  15. Initramfs
  16. Users & Passwords
  17. Boot Loader
    17.1. Systemd-boot
    17.1. GRUB

1. Live Media Creation

if a system with access to linux commands is available, use dd to create a bootable arch linux installation image on a usb/sd card from the downloaded iso. there are several ways to create an installation medium -- see how to create an arch linux installer image, here

the 'of' path should be replaced with the destination to the usb/sd card; insert the device and use lsblk to check path. it should be something like 'sdb'

dd bs=4M if=/<path>/<to>/<archlinux>.iso of=/dev/<sdx> status=progress && sync

when a bootable image has sucessfully been created from the iso, attach the device and boot into the live enviornment.

secure boot must be disabled from the system bios menu to boot the installation medium

2. Verify Boot Mode

list the efivars directory

ls /sys/firmware/efi/efivars

if the command returns the directory without error, then the system is booted in uefi. if the directory doesn't exist the system may be booted in bios or csm mode

3. Initial Network Setup

check if the network interface is enabled with iplink

ip link

if disabled, check the device driver -- see ethernet#device-driver or wireless#device-driver

3.1. Ethernet

plug in an ethernet cable


3.1. WiFi

make sure the card isn't blocked with rfkill

rfkill list

if the card is soft-blocked by the kernel, use this command: rfkill unblock wifi`

the card could be hard-blocked by a hardware button or switch, e.g. a laptop. make sure this is enabled

authenticate to a wireless network in an iwd interactive prompt

iwctl

list all wireless devices

[iwd] device list

scan for networks

[iwd] station <device> scan

list scanned networks

[iwd] station <device> get-networks

finally, connect to specified network

[iwd] station <device> connect <SSID>

verify connection

[iwd] station <device> show

exit prompt (ctrl+c)

exit

° for wwan (mobile broadband) -- see nmcli

4. System Clock

set system clock timedatectl

timedatectl set-ntp true

check status

timedatectl status

5. Disk Partitioning

list disk and block devices

lsblk

using the most desirable partitioning tool(gdisk, fdisk, parted, etc) for your system, create a new gpt or mbr partition table, if one does not exist. a gpt table is required in uefi mode; an mbr table is required if the system is booted in legacy bios mode

if booted in uefi, create an efi(512MB) system partition (boot); not necessary for legacy bios systems. create an optional swap partition (half or equal to RAM) and the required root(10GB+) partition

if the system has an existing efi partition, don't create a new one. do not format it or all data on the partition will be lost, rendering other operating systems potentially un-bootable. skip the 'mkfs.vfat' command in the format partitions section below and mount the already existing efi partition if available

to create any stacked block devices for lvm, system encryption or raid, do it now

partitioning with gdisk

gdisk /dev/sdX

new gpt partition table (erases any existing partitions)

o

efi system partition

n

+512M

ef00

(swap partition)

n

+4G

8200

root partition

n

+10G

8300

write changes

w

6. Swap Space (Optional)

in order to create a swap consider creating either a swap partition or a swapfile now. to share the swap space system-wide with other operating systems or enable hibernation; create a linux swap partition. in comparison, a swapfile can change size on-the-fly and is more easily removed, which may be more desirable for a modestly-sized ssd


6.1. Swap Partition

if a swap partition was made, format it by replacing 'swap_partition' with it's assigned block device path, e.g. sda2

mkswap /dev/<swap_partition>

then activate it

swapon /dev/<swap_partition>

6.1. Swapfile

to create a swapfile instead, use dd. the following command will create a 4gb swapfile

dd if=/dev/zero of=/swapfile bs=1M count=<4096> status=progress

format it

mkswap /swapfile

then activate it

swapon /swapfile

a swapfile without the correct permissions is a big security risk. set the file permissions to 600 with chmod

chmod 600 /swapfile

7. Format Partitions

format the root partition just created with preferred filesystem and replace 'root_partition' with it's assigned block device path, e.g. sda3

mkfs.<ext4> /dev/<root_partition>

for uefi systems, format the efi partition by replacing 'efi_partition' with it's assigned block device path, e.g. sda1

°if an efi partition already exist, skip formatting

mkfs.vfat -F32 /dev/<efi_partition>

8. Mount Partitions

mount root partition to /mnt

mount /dev/<root_partition> /mnt

mount the efi system partition to /boot

mkdir /mnt/boot
mount /dev/<efi_partition> /mnt/boot

9. Install Essential Packages

pacstrap base, kernel choice and if the system has an amd or intel cpu, install the coinciding microcode updates

pacstrap /mnt base linux linux-firmware nano sudo <cpu_manufacturer>-ucode

10. Fstab

generate an fstab file from detected mounted block devices, defined by uuid's

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

check generated fstab

cat /mnt/etc/fstab

11. Change Root

chroot into freshly installed system

arch-chroot /mnt

12. Time Zone

set time zone

ln -sf /usr/share/zoneinfo/<region>/<city> /etc/localtime

generate /etc/adjtime with hwclock

hwclock --systohc

° this assumes the hardware clock is set to utc. for more, see system time#time standard

13. Localization

edit /etc/locale.gen and un-comment 'en_US.UTF-8 UTF-8' or any other necessary locales by removing the '#'

nano /etc/locale.gen

use ctrl+x then 'y' to save and close nano

° for a different editor -- see documents#editors

generate the locales

locale-gen

create the locale.conf file and set the system locale

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

14. Network Configuration

create hostname file

echo <hostname> > /etc/hostname

add matching entries to hosts

nano /etc/hosts
127.0.0.1    localhost  
::1          localhost  
127.0.1.1    <hostname>.localdomain <hostname>

° if the system has a permanently assigned ip address, use it instead of '127.0.1.1'

install any desired network managment software. for this guide systemd-networkd is used. if you prefer a gui and configureless setup -- check out networkmanager below

14.1. Systemd-networkd

install wpa_supplicant

pacman -S wpa_supplicant

connect to the network with wpa_passphrase

wpa_passphrase <ssid> <password> > /etc/wpa_supplicant/wpa_supplicant-<interface>.conf

enable & start the wpa_supplicant daemon reading the config file just created

systemctl enable --now wpa_supplicant@<interface>

setup systemd-networkd for wireless networking

nano /etc/systemd/network/25-wireless.network
[Match]
Name=<interface>

[Network] 
DHCP=yes

enable and start systemd-network service daemon

systemctl enable systemd-networkd

° for a static connection -- see #static; for ethernet -- see #wired adapter


14.1. NetworkManager

install networkmanager

pacman -S networkmanager

enable and start networkmanager service daemon

systemctl enable NetworkManager

15. Initramfs

° creating an initramfs image isn't necessary since mkinitcpio was ran when pacstrap installed the kernel

for lvm, system encryption or raid modify mkinitcpio.conf then recreate the initramfs image with:

mkinitcpio -P

16. Users and Passwords

create a new user

useradd -m <username>

add created user to the wheel group

usermod -aG wheel <username>

uncomment '%wheel'

EDITOR=nano visudo

set created user password

passwd <username>

set root user password

passwd

disable login to superuser/root, locking password entry for root user. this will give the system increased security and a user can still be elevated within the wheel group to superuser priveleges with sudo and su commands

passwd -l root

17. Boot Loader

install a linux-capable boot loader. for simplicity and ease-of-use I recommend systemd-boot, not grub for uefi. systemd-boot will boot any configured efi image including windows operating systems. systemd-boot is not compatible with systems booted in legacy bios mode

17.1. Systemd-boot

install systemd-boot in the efi system partition

bootctl --path=/boot install

add a boot entry and load installed microcode updates

nano /boot/loader/entries/<entry>.conf
title <Arch Linux>  
linux /vmlinuz-linux  
initrd /<cpu_manufacturer>-ucode.img  
initrd /initramfs-linux.img  
options root=/dev/<root_partition> rw quiet log-level=0

° if a different kernel was installed such as linux-zen, you would add '-zen' above to 'vmlinuz-linux' and 'initframs-linux' lines. this will boot the system using the selected kernel. for more -- see kernel paramters

edit loader config

nano /boot/loader/loader.conf`
default <entry>.conf  
timeout <3>  
console-mode <max>  
editor <no>

verify entry is bootable

bootctl list

17.1 GRUB

install grub. also, install os-prober to automatically add boot entries for other operating systems

pacman -S grub os-prober

17.2. UEFI

for systems booted in uefi mode, install efibootmgr

pacman -S efibootmgr

and install grub to the efi partition

grub-install --target=x86_64-efi --efi-directory=/boot/grub --bootloader-id=GRUB

17.2. BIOS

othwerwise, if booted in bios mode; where path is the entire disk, not just a partition or path to a directory install grub to the disk

grub-install --target=i386-pc /dev/sdx

generate the grub config file. this will automatically detect the arch linux installation

grub-mkconfig -o /boot/grub/grub.cfg

° if a warning that os-prober will not be executed appears then, un-comment 'GRUB_DISABLE_OS_PROBER=false'

nano /etc/default/grub

18. Arch Linux Installation Complete 🥳

exit (ctrl+d) chroot

exit

unmount all partitions; check if busy

unmount -R /mnt

reboot the system

reboot