Whether out of frustration with Microsoft Windows, for curiosity, fun, for a challenge, or to learn something new, many people make the decision to overwrite their factory installed operating system with something else. I experimented a lot with alternative operating systems over the years, and used Ubuntu regularly since 2007.
Well the mind wanders in unhealthy ways sometimes, and I found myself thinking too much about the past, and what could have been different about it. In particular, I thought of when I was a teenager with hundreds of dollars in cash from working my first summer job at a local amusement park. I bought a desktop computer with a Pentium Pro processor at a custom computer shop, and the owner let me help him build it.
I experimented obsessively with programming, the Internet, and FreeBSD; but what I found myself wondering was what else I could have done with access to more informational resources and confidence. Unable to draw my mind away from the storyline, I decided to turn my regret and fantasy into a present day hobby. What if I installed a challenging modern operating system on my laptop, and learned it as deeply as I could?
Cool operating system. I liked the modular design of Arch Linux that encouraged users to thoroughly research, understand, choose, and customize small components. The wiki was detailed and extensive, and the developers and maintainers had a reputation for being really good at what they did.
Learn about Linux. Choosing and configuring small pieces meant a lot of learning. I wanted a deeper appreciation for what happened in my operating system.
Community fun. Several of my friends used Arch already. I wanted to connect with them more. Having an unusual operating system in common could give us something to talk about. I wanted to explore new technologies together, share success stories, and troubleshoot issues.
During the installation process, I drew from many online sources. They all have slightly different goals and focus areas. Many offer a useful generality and depth this document may lack, since I recorded only the steps I used to get Arch Linux running on my particular hardware. Having the latest installation image on a USB stick, I booted into the prompt...
I used the fdisk utility to delete all the partitions on my disk and create two new ones. The first was an EFI partition for the bootloader. The second was a root partition for the operating system. Hopefully already well understood, but always worth mentioning, these instructions delete all data on the disk. The command line argument is the disk's device name. Device names vary by system.
fdisk /dev/nvme0n1
The fdisk utility launches. It presents an interactive prompt.
Delete any existing partitions. Enter d and accept the default partition repeatedly until no partitions remain.
Create EFI partition. Enter n to create a new partition. Enter 1 for the partition number. Accept the default first sector. Enter +4G for the size. Then fdisk returns to its top-level prompt. Enter t to set the partition type. Enter 1 for the partition number. Enter uefi for the partition type.
Create root partition. Enter n to create a new partition. Enter 2 for the partition number. Accept the default first sector. Accept the default size to use all remaining disk space.
Write changes. Optionally enter p to display the changes. Enter w to write the changes to disk. Then fdisk exits automatically.
Two new devices /dev/nvme0np1
and /dev/nvme0np1
exist now, and correspond to the two new partitions.
I read about an interesting filesystem called btrfs that supported snapshots, and I formatted the root partition with it. Unlike most partitions which normally get mounted directly, btrfs partitions get broken down into subvolumes, and each subvolume gets mounted separately. However temporarily during the installation process, the partition itself gets mounted it for the purpose of creating the subvolumes. Good candidates are parts of the filesystem that contain large or rapidly changing data unimportant for system restoration purposes.
Create the subvolumes. The subvolumes appear under the partition's mount point as directories. Unmount the partition. Mount each of the subvolumes in its proper place. The noatime
option improves performance by not tracking access times on files.
# Format the root partition mkfs.btrfs /dev/nvme0n1p2 # Mount the partition temporarily mount /dev/nvme0n1p2 /mnt # Create subvolumes in the partition btrfs su cr /mnt/@ btrfs su cr /mnt/@home btrfs su cr /mnt/@root_btrsnap btrfs su cr /mnt/@tmp btrfs su cr /mnt/@var_cache btrfs su cr /mnt/@var_log btrfs su cr /mnt/@var_tmp # Umount the partition umount /mnt # Mount the subvolumes mount --mkdir -o noatime,compress=lzo,space_cache=v2,subvol=/@ /dev/nvme0n1p2 /mnt mount --mkdir -o noatime,compress=lzo,space_cache=v2,subvol=/@home /dev/nvme0n1p2 /mnt/home mount --mkdir -o noatime,compress=lzo,space_cache=v2,subvol=/@root_btrsnap /dev/nvme0n1p2 /mnt/root/btrsnap mount --mkdir -o noatime,compress=lzo,space_cache=v2,subvol=/@tmp /dev/nvme0n1p2 /mnt/tmp mount --mkdir -o noatime,compress=lzo,space_cache=v2,subvol=/@var_cache /dev/nvme0n1p2 /mnt/var/cache mount --mkdir -o noatime,compress=lzo,space_cache=v2,subvol=/@var_log /dev/nvme0n1p2 /mnt/var/log mount --mkdir -o noatime,compress=lzo,space_cache=v2,subvol=/@var_tmp /dev/nvme0n1p2 /mnt/var/tmp
Format the EFI parition with a FAT32 filesystem for compatibility with the firmware that will need to interact with it, and then mount the partition. The fmask
and dmask
options may help prevent certain nondescript boot issues I encountered.
mkfs.vfat -F32 /dev/nvme0n1p1 mount --mkdir -o fmask=0077,dmask=0077 /dev/nvme0n1p1 /mnt/efi
Connect to the internet wirelessly, replacing MyNetwork and MyPassphrase appropriately. Install the minimum necessary packages. Generate the fstab
file. This file remembers where we mounted everything.
iwctl --passphrase MyPassphrase station wlan0 connect MyNetwork pacstrap -K /mnt base linux linux-firmware genfstab -U /mnt >> /mnt/etc/fstab # Optionally take a snapshot btrfs su snapshot /mnt /mnt/root/btrsnap/0000.base
Enter into the new installation. Install iwd and openresolv for internet access without help from the installation image, the text editor vim for editing configuration files, and btrfs-progs
for taking system snapshots. Go through a number of mundane steps per the installation guide.
arch-chroot /mnt pacman -S iwd openresolv vim btrfs-progs # Set root password passwd # Create /etc/localtime (replace MyRegion and MyCity appropriately) ln -sf /usr/share/zoneinfo/MyRegion/MyCity /etc/localtime # I didn't read up on what this does hwclock --systohc # Uncomment the appropriate UTF-8 line, generate locale(s) vim /etc/locale.gen locale-gen
Install the necessary packages to make a grub
bootloader. Then install the bootloader and set up its configuration. Consider saving the bootloader installation and configuration lines as a script for later use.
pacman -S grub efibootmgr grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=arch_grub grub-mkconfig -o /boot/grub/grub.cfg # Optionally take a snapshot btrfs su snapshot / /root/snapshots/0001.configure
Exit out of the chroot
, unmount all the filesystems, and restart the system.
# Back in the installation image environment umount -R /mnt reboot
Remove the installation media and restart the laptop. If all goes well log in as root.
The internet access I had in the installation media boot environment did not carry through when I booted into the operating system. I configured a wireless internet daemon iwd and a domain name resolution service. For domain name resolution, I tried extensively to get systemd-resolved
working but could not get past an issue where many names resolved but some did not, including the name of this site for instance. I switched to resolvconf
.
On a single line in /etc/hostname
assign the machine a hostname. For example the entire contents of the file could be MyHostname. Local applications can use the hostname to reference the machine.
vim /etc/hostname
Per the Arch wiki, create the resolv.conf
configuration file.
resolvconf -u
There is no iwd configuration file by default. Paste in this minimal configuration file when the time comes. This is /etc/iwd/main.conf
.
[General] EnableNetworkConfiguration=true [Network] NameResolvingService=resolvconf
Start and enable the iwd service. Starting the service launches it immediately. Enabling the servicec causes it to start automatically on boot. Connect to the internet wirelessly, replacing MyNetwork and MyPassphrase appropriately.
# Create the iwd config file vim /etc/iwd/main.conf # Start and enable iwd systemctl enable iwd systemctl start iwd # Connect to a wireless network iwctl --passphrase MyPassphrase station wlan0 connect MyNetwork # Optionally view the network file that was created cat /var/lib/iwd/MyNetwork.psk
Further wireless refinements are possible and likely desirable. The installation guides I consulted contain additional network configuration recommendations I do not yet understand. Meanwhile these steps suffice to make the Arch installation usable.
One usually creates a non-root user for regular operations. Even in cases where only one person uses the system, having a safeguard against accidentally running dangerous commands as root is nice.
I added a new user with a home directory and bash for a login shell. Set the new user's password. Optionally exit the root session and test logging in as the new user.
useradd -m -s /bin/bash MyUsername passwd MyUsername # Optionally see the new home directory ls /home
The user should be able to become the root user when it needs to. Install the sudo package. Edit the sudo configuration file with the special visudo utility per below. Sources recommend doing otherwise, but editing /etc/sudoers
directly also seems to work. Add the new user to the wheel
group. Optionally test running commands as root by prefixing them with sudo when logged in as the new user.
# Install sudo pacman -S sudo # Uncomment the line "%wheel ALL=(ALL:ALL) ALL" EDITOR=vim visudo usermod -a -G wheel MyUsername
For convenience, the root user should have the ability to shut down and reboot the system without becoming the root user. Install the polkit package.
pacman -S polkit
Surprisingly without enabling any service the non-root user now has the ability to use the shutdown
and reboot
commands. Perhaps they can now run other commands as well. There are certainly many things I still do not understand about polkit.
Chrome needs a graphical environment to run in, such as a wayland compositor like sway. Install sway and choose gnu-free-fonts
when the installation process asks about a font. Other choices probably work fine. Also install alacritty which is a terminal for sway. Copy the default sway configuration file to the user home directory. Edit the configuration file to set alacritty as the default terminal. Launch sway. Open a terminal by pressing the Win+Enter keys together. Continue to the remaining steps in the alacritty terminal.
# Install sway and alacritty sudo pacman -S sway alacritty # Use the default sway configuration file mkdir -p ~/.config/sway cp /etc/sway/config ~/.config/sway # Change "set $term foot" to "set $term alacritty" vim ~/.config/sway/config # Launch sway sway
Google Chrome and most other software of interest is not available through pacman, only through the AUR. A straightforward way to use AUR is with the yay package. The most straightforward way to install yay is cloning it using git.
Install git. Optionally set the name for default branches. This avoids warning messages when cloning repositories. The common choice used to be master but recently seems to have shifted to main. Optionally set a name and email which will attribute authorship to future commits.
sudo pacman -S git git config --global init.defaultBranch main git config --global user.name "My Name" git config --global user.email "myemail@bitflippin.com"
Clone the yay repository. Build and install yay. Once installed the repository is no longer necessary. Interestingly yay seems to install itelf as a yay package!
git clone https://aur.archlinux.org/yay.git cd yay sudo pacman -S base-devel makepkg -si cd .. rm -rf yay
The last step to having a nice baseline system that can be further is having a web broser. I installed Google Chrome and ran it. On wayland the additional flag below may be necessary. It was for me.
yay -S google-chrome google-chrome-stable --ozone-platform=wayland
Usability gaps like having sway start on login, having google-chrome-stable
launch without a terminal, and further customizations of sway still remain; however these steps are sufficient to get started.
The installation process took a lot of time, but I also learned a lot. Despite some frustrations, it was also fun. I used Arch Linux for a while, building out useful scripts, and experimenting with splash screens.Going with Arch Linux had downsides too.
Complicated mess. I envisioned a collection of well designed designed and maintained components that could work togther nicely. Instead, the components had overlapping responsibilities, nonuniform methods of configuration, and interacted with each other in unpredictable ways. From the multiple package managers to wireless networking challenges, Arch Linux did not have the beautiful simplicity I hoped for.
Instability. A recurring theme in reading the documentation and writings from people in the community is that it isn't necessarily a good idea to trust updates. Even routine updates can apparently often break the installation. Dealing with a broken system is not always compatible with productivity.
Maintenance time. The installation process took a lot of time; but I expected that, and gaining a better understanding of the operating system and its components was all part of the adventure. An expectation about reading all the release notes to assess the impact of new package releases and to engage in ongoing troubleshooting was not.
I dreamed of perfection when it came to a computer, but no computer is perfect. Buggy software with usability issues run on top of buggy operating systems that have design flaws that can sometimes manifest in strange ways. The hardware on which the the operating system runs has weaknesses too, from choices about the instruction set, to the chipset, to the peripherals.
Ultimately my laptop had to be a tool I could use productivity and without a lot of cognitive overhead; and other Linux distributions like Ubuntu require far less cognitive overhead.
I relied on a lot of guides and help to get as far as I did. Here are the ones I relied on the most.
ext4
filesystems, but features an encrypted /home
partition. Discusses docker
configuration, and measures to ensure the compatibility of the installation with wake-on-lan. systemd
bootloader instead of grub
. Splash screen on startup and shutdown using plymouth
. Covers setting up secure boot and hibernate. /etc/hostname
and /etc/hosts
. google-chrome
on Arch Linux straight from the AUR, and alternatively with yay. Nothing new, but well put together.