# Arch Linux Installation & Configuration

Table of Contents

This is a brief record of Arch Linux installation and configuration for quick reference.

Preparation

Download ISO

Download the latest ISO from the USTC Mirror.

Installation

Disable reflector

Terminal window
systemctl stop reflector.service

Ensure UEFI

Terminal window
ls /sys/firmware/efi/efivars

Connecting to WI-FI

Terminal window
iwctl
device list
station wlan0 scan
station wlan0 get-networks
station wlan0 connect wifi-name
station wlan0 show
exit

Update time

Terminal window
timedatectl set-ntp true
timedatectl status

Use mirror source

Terminal window
vim /etc/pacman.d/mirrorlist

Recommend mirrors:

mirrorlist
Server = https://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch

Setup Btrfs

Check partition layout

Terminal window
lsblk

Use cfdisk to setup the new partition

Terminal window
cfdisk /dev/sdx

Make a swap first. The recommended size is about 60% of your RAM (e.g. 10GB if your RAM is 16GB). The type should be Linux swap.

Then make the main partition for your files. The type should be the default Linux filesystem.

If you don’t already have a boot partition, make a partition of type EFI System. Around 200-300 MB is proper, however I would recommend 512 MB.

After completing the partition, check it again and [Write].

Now you can use fdisk -l or lsblk to check your partition layout.

Format Btrfs and others

If necessary, format EFI partition:

Terminal window
mkfs.fat -F32 /dev/sdxn

Format Swap

Terminal window
mkswap /dev/sdxn

Format Btrfs

Terminal window
mkfs.btrfs -L ArchZone /dev/sdxn

You can also use your own label instead of ArchZone

Terminal window
mount -t btrfs -o compress=zstd /dev/sdxn /mnt
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume list -p /mnt # if you want to check
umount /mnt

Mount

Terminal window
mount -t btrfs -o subvol=/@,compress=zstd /dev/sdxn /mnt
mkdir /mnt/home
mount -t btrfs -o subvol=/@home,compress=zstd /dev/sdxn /mnt/home
mkdir -p /mnt/boot
mount /dev/sdxn /mnt/boot
swapon /dev/sdxn

To check:

Terminal window
df -h
free -h

Install system

Terminal window
pacstrap /mnt base base-devel linux-zen linux-firmware btrfs-progs
Terminal window
pacstrap /mnt iwd networkmanager vim sudo zsh zsh-completions

Generate fstab

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

Change root

Terminal window
arch-chroot /mnt

Follow-up setup

Terminal window
vim /etc/hostname
Terminal window
vim /etc/hosts
hosts
127.0.0.1 localhost
::1 localhost
127.0.1.1 [hostname].localdomain [hostname]

(You may use TAB to align them)

Terminal window
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
Terminal window
hwclock --systohc
Terminal window
vim /etc/locale.gen # en_US.UTF-8 UTF-8 & zh_CN.UTF-8 UTF-8
locale-gen
echo 'LANG=en_US.UTF-8' > /etc/locale.conf
Terminal window
passwd root
Terminal window
# Choose one
pacman -S intel-ucode
pacman -S amd-ucode

Boot software

Install GRUB:

Terminal window
pacman -S grub efibootmgr os-prober
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB

Get your swap partition id:

Terminal window
lsblk -o name,mountpoint,size,uuid | grep SWAP

Configuration:

Terminal window
vim /etc/default/grub
grub
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=5 nowatchdog resume=UUID=[your swap partition uuid]"
GRUB_DISABLE_OS_PROBER=false
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
GRUB_DISABLE_SUBMENU=y # Optional

Apply:

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

Edit resume hook:

Terminal window
vim /etc/mkinitcpio.conf

Add resume in the HOOKS line. It must be added after udev, after block, before filesystems and before lvm2 if there is it.

Regenerate initramfs:

Terminal window
sudo mkinitcpio -P

Enter your Arch Linux

After the above steps, you can reboot and boot into your Arch Linux!

Connecting to WIFI

Terminal window
vim /etc/NetworkManager/conf.d/wifi_backend.conf
wifi_backend.conf
[device]
wifi.backend=iwd
Terminal window
systemctl enable --now NetworkManager

Then use nmtui or iwctl.

fastfetch

Terminal window
pacman -S fastfetch
Terminal window
fastfetch

Basic configuration

Terminal window
pacman -Syu

Do this regularly :)

Edit your .bash_profile

Terminal window
vim ~/.bash_profile

to add:

Terminal window
export EDITOR='vim'

to use vim as default editor.

Add a main admin user:

Terminal window
useradd -m -G wheel -s /bin/bash [username]
passwd [username]
EDITOR=vim visudo
#%wheel ALL=(ALL) NOPASSWD: ALL

Config pacman:

Terminal window
vim /etc/pacman.conf

Uncomment [multilib] and Color, add archlinuxcn at the bottom:

pacman.conf
[archlinuxcn]
Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch

Then

Terminal window
pacman -Sy archlinuxcn-keyring
pacman -Syyu

Hyprland and more with my dotfiles (Optional)

Login with your main user instead of root for the following steps.

CLI Configuration & Hyprland Rice
10

My dotfiles repository includes modern configuration files for CLI tools like zsh and a fancy rice for Hyprland. For example, get a modern zsh instantly through that:

Terminal window
sudo pacman -S yadm
yadm clone -b dotfiles git@github.com:pstron/dotfiles.git

Now you can change your shell to zsh:

Terminal window
pacman -S fzf # fzf is required
chsh -s /bin/zsh

To install Hyprland and other related components, refer to the next post.

References

Arch Linux Brief Guide - A really nice guide for Arch Linux installation. Especially for CN users.

Arch Linux Wiki - Almost everything you want to know about Arch Linux or even more can be found here.

My avatar

Positron

has a spin of Β½