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
- Arch ISO
- Internet connection
- USB flashing software (e.g. Balena Etcher)
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
- Insert the USB into the PC.
- Install etcher:
paru -S etcher-bin
- Run as root:
sudo etcher
- If you're on Windows, run it as administrator.
- 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
- List disks:
fdisk -l
- Find the disk you want to install Arch Linux onto
- Use fdisk on disk:
fdisk /dev/sda
- 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
- Create the EFI/BOOT partition:
n
- Partition number: Enter
- First sector: Enter
- Last sector:
+512M
- Change partition type to EFI:
t
- Press the number corresponding to EFI
- list all types with
L
- list all types with
ROOT partition
- Partition number: Enter
- First sector: Enter
- Last sector: Enter
- Write changes to disk:
w
Make file systems
- Make BOOT file system:
mkfs.fat -F32 /dev/sda1 && fatlabel /dev/sda1 BOOT
- 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
- Create the ROOT partition:
n
- Partition number: Enter
- First sector: Enter
- Last sector: Enter
- Write changes to disk:
w
Make file system
- 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.
- Run
iwctl
- Find your device:
device list
- Scan for networks:
station <DEVICE> scan
- List all scanned networks:
station <DEVICE> get-networks
- Connect to your network:
station <DEVICE> connect <NETWORK_SSID>
- Enter the network passphrase
- Quit iwctl:
quit
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:
- Create or open the iwd config file:
vim /etc/iwd/main.conf
- Add:
[General] ControlPortOverNL80211=False
- Save and quit:
:wq
- Restart iwd:
systemctl restart iwd.service
- 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.
- Update current mirrors:
pacman -Syy
- Update the arch keyring:
pacman -S archlinux-keyring
- Install reflector:
pacman -S reflector
- Back up your current mirrorlist:
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
- 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
- Mount ROOT:
mount /dev/disk/by-label/ROOT /mnt
- Create mount point for BOOT partition:
mkdir /mnt/boot
- Mount BOOT:
mount /dev/disk/by-label/BOOT /mnt/boot
BIOS systems
- 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 — Goes over installing the base packages and using
arch-chroot
- Locale & Time — Set up system language and time related things
- Network Configuration — Populating
/etc/hosts
etc - Account Setup — Basic account setup
- Boot Manager — Setting up boot related things
- Finishing Up — Final touches before Arch is ready to use
Arch Chroot
- Packstrap base packages into mount point:
pacstrap /mnt base base-devel linux linux-firmware linux-headers neovim nano networkmanager dhcpcd iwd
- Generate FS Tab:
genfstab -U /mnt >> /mnt/etc/fstab
- Enter mount point:
arch-chroot /mnt
Locale & Time
In this section we setup the system language, clock and time-zone.
- Set timezone:
timedatectl set-timezone Europe/Stockholm
- Replace
Europe/Stockholm
with your time-zone
- Replace
- Correct time and sync the system clock:
hwclock --systohc
- Set locale:
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
- 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.
- Set hostname:
echo arch > /etc/hostname
- Open and edit
/etc/hosts
using eithernvim
ornano
:
127.0.0.1 localhost
::1 localhost
127.0.1.1 arch.localdomain arch
- Enable NetworkManager:
systemctl enable NetworkManager.service
Additional steps for wifi
- Connect to wifi using iwctl (refer to the wifi steps)
- Enable dhcpcd:
systemctl enable dhcpcd.service
- Run dhcpcd:
dhcpcd
- 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
- Set root password:
passwd
- Create user:
useradd -G wheel -m <user-name>
- Set new user password:
passwd <user-name>
- Grant wheel group sudo access:
echo "%wheel ALL=(ALL) ALL" >> /etc/sudoers
Boot Manager
- Install packages:
pacman -S grub os-prober efibootmgr
- Omit
efibootmgr
if you have a BIOS system
- Omit
- Install boot loader:
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub
- Make boot loader config:
grub-mkconfig -o /boot/grub/grub.cfg
Finishing Up
- Exit the arch-chroot environment:
exit
- Unmount BOOT:
umount /mnt/boot
- Unmount ROOT:
umount /mnt
- 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.