Page loadedSkip to main content

Building Your Own Operating System with Arch Linux

00:01:57:59

Why Arch

Most distributions give you a finished product. Arch gives you parts and a manual. That is the entire appeal. You decide what goes on the machine, you understand every piece, and nothing runs that you did not explicitly put there.

This is a walkthrough of the full install process, from a blank disk to a bootable system.

Before you start

You will need a USB drive with the Arch ISO, an internet connection, and the willingness to read error messages carefully. For dual-boot setups with Windows, allocate at least 100GB for the Arch partition.

One easy gotcha: if your WiFi network name contains non-ASCII characters, it will not display in the TTY. Rename it or use ethernet.

The installation

Boot and verify UEFI

Boot from the USB and confirm you are in UEFI mode:

bash
ls /sys/firmware/efi/efivars

If the directory exists and has files, you are good.

Network

For wired connections, things usually work automatically. For WiFi:

bash
iwctl
station wlan0 scan
station wlan0 connect "your-network"

Verify with ping archlinux.org.

Time sync

bash
timedatectl set-ntp true

Partition the disk

I use Btrfs with subvolumes. The layout:

bash
fdisk /dev/nvme0n1

Create an EFI system partition (512MB, type EFI) and a Linux partition (rest of disk). Then format:

bash
mkfs.fat -F 32 /dev/nvme0n1p1
mkfs.btrfs /dev/nvme0n1p2

Create subvolumes for root, home, and snapshots:

bash
mount /dev/nvme0n1p2 /mnt
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
umount /mnt

Mount them properly:

bash
mount -o subvol=@ /dev/nvme0n1p2 /mnt
mkdir -p /mnt/{home,boot/efi}
mount -o subvol=@home /dev/nvme0n1p2 /mnt/home
mount /dev/nvme0n1p1 /mnt/boot/efi

Install the base system

bash
pacstrap -K /mnt base linux linux-firmware vim networkmanager

Generate fstab

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

Chroot and configure

bash
arch-chroot /mnt

Set timezone, locale, hostname:

bash
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock --systohc
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "archbox" > /etc/hostname

Bootloader

Install GRUB with UEFI support:

bash
pacman -S grub efibootmgr
grub-install --target=x86_64-efi --efi-directory=/boot/efi
grub-mkconfig -o /boot/grub/grub.cfg

For dual-boot, install os-prober and enable it in /etc/default/grub before generating the config.

Set password and reboot

bash
passwd
exit
umount -R /mnt
reboot

After reboot

Enable networking:

bash
systemctl enable --now NetworkManager

From here the system is yours. Install a window manager, a desktop environment, or nothing at all. That is the point.

The first time I went through this process it took an afternoon. Now it takes about twenty minutes. More importantly, I understand every service running on my machine, because I put each one there myself.