Building an Operating System


Introduction

An operating system can be built from software components in the same way that a PC can be built from hardware components. The most important component of an OS is its kernel, which is a program that interfaces with a computer’s hardware and acts as a platform for other programs to run on. The only available kernel with modern hardware support is Linux.


Software

A complete desktop operating system is composed of the following main components:




Arch Linux

Linux distributions (distros) are software update services featuring repositories of continuously maintained packages.

Arch Linux is the most well-suited distro for a personal desktop OS. It’s designed around systemd and pacman (a package manager).

The Arch Linux iso can be downloaded, and flashed (i.e. copied) on a USB flash drive (the flash drive must have a sufficient storage capacity to support the iso) using various methods.

Once the flash is complete, the computer (on which the OS is being installed) must boot from the USB drive in order to begin the installation. The system must be powered off and the USB drive must be plugged into it; the boot device can be specified in the computer’s firmware - the firmware menu can be accessed by pressing a specific key on the keyboard during the system’s startup process. Unfortunately, the key is not standardized, but it’s usually Escape, Delete, F2 or F12.


Pre-Installation

A guided installation procedure can be started by running the command:

archinstall

Boot Method

The simplest and most straight forward boot configuration for a single operating system is to use Unified Kernel Images with no bootloader (i.e. the EFISTUB bootloader).

Filesystems

Filesystems in Unix-derived systems (such as Linux-based operating systems) are not only used for file storage, but also act as an interface for the kernel, representing kernel functionality as files (devices, processes, etc.).

The simplest filesystem for a single NVMe drive is ext4.

Users

User accounts in Unix-derived systems are a security mechanism and don’t necessarily refer to human users. The default privileged user account used for system administration is root. For the default unprivileged user account, the name user can be used.

User account setup can be skipped; it will be done in the Post-Installation section.

Additional packages

A useful package for editing configuration files (used in the next section) is nano.


Post-Installation

Networking

The first requirement for internet connectivity is handled by systemd-networkd.

The service must be enabled (so it starts automatically on boot):

systemctl enable systemd-networkd

Network setup can be done using a network file. When using a wired internet connection, it makes more sense to set up a static internal IPv4 address than to use DHCP.

Example configuration:

nano /etc/systemd/network/20-wired.network
[Match]
Name=enp1s0 # network interface name

[Network]
Gateway=192.169.100.1 # gateway (router) IPv4 address
Address=192.168.100.2/24

The second requirement (DNS resolution) is handled by systemd-resolved:

systemctl enable systemd-resolved

Example configuration:

nano /etc/systemd/resolved.conf
[Resolve]
DNS=9.9.9.9#dns.quad9.net
DNSOverTLS=yes

Home Directory

Encrypted home directories for personal data are handled by systemd-homed:

systemctl enable --now systemd-homed

The home directory itself (along with the user user) must be created:

homectl create user --storage=luks --fs-type=ext4 --disk-size=90%

All data within the home directory will be stored in a single file (/home/user.home) and the home directory (/home/user) will be available after logging in as user.

Multimedia

Multimedia streams (audio & video) are handled by PipeWire, which must be installed:

pacman --sync pipewire

To function, PipeWire requires a session manager such as WirePlumber:

pacman --sync wireplumber

Bluetooth

Bluetooth support can be added like so:

pacman --sync bluez
systemctl enable bluetooth

Desktop Environment

The main components of the Plasma desktop environment can be installed like so:

pacman --sync plasma-desktop plasma-pa

Some basic applications such as a terminal emulator (Konsole) and file manager (Dolphin) will be necessary:

pacman --sync konsole dolphin

The desktop environment is started by a display manager (SDDM):

pacman --sync sddm sddm-kcm sddm-theme-breeze

Required configuration:

nano /etc/sddm.conf.d/10-wayland.conf
[General]
DisplayServer=wayland
GreeterEnvironment=QT_WAYLAND_SHELL_INTEGRATION=layer-shell

[Wayland]
CompositorCommand=kwin_wayland --drm --no-lockscreen --no-global-shortcuts --locale1

Once SDDM is enabled, the next boot will present a graphical login screen.

systemctl enable sddm

An application manager such as Flatpak allows desktop applications to be installed and work in the same way across all distros:

pacman --sync flatpak flatpak-kcm xdg-desktop-portal-kde

To finish system configuration and boot into the desktop environment:

systemctl reboot

Applications

Flatpak applications (flatpaks) can be installed from Flatpak repositories.

Flathub is the main repository of community-maintained flatpaks available:

flatpak --user remote-add flathub https://flathub.org/repo/flathub.flatpakrepo

All that is needed to install a flatpak from Flathub is its Application ID (in the form com.example.application):

flatpak --user install com.example.application

Alternatively, a flatpak can be installed without specifying a repository from a flatpakref file. Once it’s installed, it should appear in Plasma’s application menu.

Flatpaks are isolated from the system, and may sometimes need explicit permissions granted to access certain resources such as filesystem paths or special hardware devices (e.g. a webcam).

To update all installed flatpaks:

flatpak --user update

Maintenance

System packages are updated regularly by package maintainers. To update all packages to the latest versions:

run0 pacman --sync --refresh --sysupgrade

Games

Since the vast majority of modern computer games are Microsoft Windows applications, Wine (an implementation of the Windows API) is required:

run0 pacman --sync wine

Once installed, running a game (with game.exe being the game’s main executable file) is as simple as running wine game.exe within the game’s directory.

For finding more technical information about games, PCGamingWiki can be a useful website.


Beyond

The ArchWiki is an invaluable resource, however be wary that many parts of the Linux software ecosystem are in constant and rapid change - articles which have not been updated over time can provide outdated and misleading information.