Skip to content

Instantly share code, notes, and snippets.

@subrezon
Last active July 20, 2023 08:35
Show Gist options
  • Save subrezon/c4d7b2a35b7d0d9dfba988d59f5e42ac to your computer and use it in GitHub Desktop.
Save subrezon/c4d7b2a35b7d0d9dfba988d59f5e42ac to your computer and use it in GitHub Desktop.
Arch Install Cheatsheet

Set console keyboard layout

Default console keyboard layout is US English. To list other available layouts:

ls /usr/share/kbd/keymaps/**/*.map.gz | less

Find the one you need and set it like this (example for German):

loadkeys de-latin1

Prepare installation environment

Verify boot mode (command should return 64):

cat /sys/firmware/efi/fw_platform_size

Make sure you're connected to the internet (if using WiFi - connect using iwctl first):

ip a
ping -c 1 google.com

Update system clock:

timedatectl

Set up drives, partitions and filesystems

Find the drive you want to use (in my case it is /dev/vda):

lsblk

Partition the disk (my example layout with ESP, swap and single large partition):

gdisk /dev/vda

o y
n 1 (default) +512m     ef00   # EFI system partition
n 2 (default) +16g      8200   # Linux swap (optional)
n 3 (default) (default) 8300   # Linux filesystem
w y
  • If installing alongside Windows or another Linux system, do not create another ESP, reuse the existing one
  • Swap is optional, should be same size as RAM (g means GiB, not GB, no need to calculate blocks)
  • You can reuse the same swap partition between multiple Linux systems
  • Watch out for partition numbers, they can differ from the given examples if you have another OS and/or do not create swap

Before formatting partitions, note which partition has which name:

lsblk

For my example, ESP is /dev/vda1, swap is /dev/vda2 and root is /dev/vda3.

Variant 1: ext4

If you want a simpler setup without btrfs:

mkfs.ext4 /dev/vda3
mount -o rw,noatime,discard /mnt

Variant 2: btrfs

Create, then mount BTRFS subvolumes:

mkfs.btrfs /dev/vda3
mount /dev/vda3 /mnt
btrfs su cr /mnt/@
btrfs su cr /mnt/@home
btrfs su cr /mnt/@root
btrfs su cr /mnt/@srv
btrfs su cr /mnt/@cache
btrfs su cr /mnt/@tmp
btrfs su cr /mnt/@log
btrfs su cr /mnt/@snapshots
umount /mnt

mount -o  rw,ssd,noatime,discard=async,compress-force=zstd:1,subvol=@ /dev/vda3 /mnt

mount --mkdir -o rw,ssd,noatime,compress-force=zstd:1,subvol=@home /dev/vda3 /mnt/home
mount --mkdir -o rw,ssd,noatime,compress-force=zstd:1,subvol=@root /dev/vda3 /mnt/root
mount --mkdir -o rw,ssd,noatime,compress-force=zstd:1,subvol=@srv /dev/vda3 /mnt/srv
mount --mkdir -o rw,ssd,noatime,compress-force=zstd:1,subvol=@cache /dev/vda3 /mnt/var/cache
mount --mkdir -o rw,ssd,noatime,compress-force=zstd:1,subvol=@tmp /dev/vda3 /mnt/var/tmp
mount --mkdir -o rw,ssd,noatime,compress-force=zstd:1,subvol=@log /dev/vda3 /mnt/var/log
mount --mkdir -o rw,ssd,noatime,compress-force=zstd:1,subvol=@snapshots /dev/vda3 /mnt/.snapshots

EFI system partition:

mkfs.vfat /dev/vda1
mount --mkdir -o nosuid,nodev,relatime,errors=remount-ro /dev/vda1 /mnt/boot/efi

NOTE: if installing alongside Windows, skip formatting the partition and just mount it.

Swap partition:

mkswap /dev/vda2
swapon /dev/vda2

NOTE: if installing alongside another Linux system with existing swap partition, skip mkswap and only do swapon.

Install base system

Install the Linux base, as well as other required packages:

pacstrap /mnt base base-devel linux linux-firmware vi vim

Generate fstab:

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

Change root into new system:

arch-chroot /mnt

Configure time

Set up time zone:

ln -sf /usr/share/zoneinfo/*Region*/*City* /etc/localtime

Update the hardware clock:

hwclock --systohc

Configure locales

Edit /etc/locale.gen and uncomment required locales. I use en_IE.UTF-8 UTF-8 and en_US.UTF-8 UTF-8.

...
en_IE.UTF-8 UTF-8
...
en_US.UTF-8 UTF-8
...

Why do I use Irish locale instead of American English? en_IE stands for English (Ireland), the language is exactly the same as American English, except with:
  • Metric system
  • Euro currency
  • 24-hour clock
  • dd/mm/yyyy date
  • Week starts on Monday
  • A4 paper

If you want vanilla American English - skip uncommenting en_IE. If you want another language - uncomment that.

Generate locales:

locale-gen

Create /etc/locale.conf and set the LANG variable to your primary locale (for example, en_IE.UTF-8):

LANG=en_IE.UTF-8

If you changed the keyboard layout, make the change persistent in /etc/vconsole.conf:

KEYMAP=de-latin1

Configure networking

Set hostname:

echo "your_hostname" > /etc/hostname
echo "127.0.0.1 your_hostname" >> /etc/hosts

Variant 1: systemd-networkd + systemd-resolved (better for wired)

systemd-networkd and systemd-resolved are both pre-installed on every Arch instance. Enable them:

systemctl enable systemd-networkd
systemctl enable systemd-resolved

Create a configuration at /etc/systemd/network/ethernet.network (use ip a to find your network interface name):

# /etc/systemd/network/ethernet.network

[Match]
Name=enp1s0

[Network]
DHCP=yes

Wired connections should work automatically. To use WiFi, install iwd and connect to wireless networks using iwctl.

Variant 2: NetworkManager (better for wireless)

Install networkmanager:

pacman -S networkmanager

Enable the NetworkManager service:

systemctl enable NetworkManager`

Wired connections should work automatically. To use WiFi, use nmcli or nmtui to connect to a wireless network.

Configure users

Set the root password:

passwd

Enable the wheel group to execute commands as root using sudo:

visudo
# Uncomment the following line (careful, you're in vi, not vim!):
# %wheel ALL=(ALL:ALL) ALL

Set up a sudo account:

useradd -mG wheel your_username
passwd your_username

Set up bootloader

Install GRUB (bootloader-id can be whatever you want):

pacman -S grub efibootmgr
# If you used a btrfs root filesystem - also install grub-btrfs
pacman -S grub-btrfs
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ARCH

(Optional) Enable dual-boot:

pacman -S os-prober
vim /etc/default/grub
# Uncomment the following line
# set GRUB_DISABLE_OS_PROBER=false

Generate GRUB config:

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

(Optional) Install your software

You can optionally install some software already (ex. a desktop environment):

pacman -S flatpak pipewire pipewire-pulse pipewire-alsa pipewire-jack \
  sway swaybg foot wofi waybar xorg-xwayland xorg-xlsclients

Exit chroot, unmount partitions and reboot (remove the installer USB during reboot):

exit
umount -R /mnt
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment