Arch Linux


                    -@                
                   .##@               
                  .####@              
                  @#####@             
                . *######@            
               .##@o@#####@           
              /############@          
             /##############@         
            @######@**%######@        
           @######`     %#####o       
          @######@       ######%      
        -@#######h       ######@.`    
       /#####h**``       `**%@####@   
      @H@*`                    `*%#@  
     *`                            `* 

After seeing the i3 window manager in action on a very minimal disttribution, I knew it was my time to take the pilgrimage to Arch.

As a long time Linux fanatic I’d never really taken the time to understand what makes Arch different.

  • The Arch Way
  • Forces one to build the system up by hand.
  • This encourages you to question each piece of the system.
  • The result is a highly tailored and minimal system that meets precisely your needs.
  • The Arch User Repository (AUR) is a treasure chest of pre-packaged useful recent software. Somehow every program I’ve ever needed has been available on AUR.
  • Rolling upgrades.
  • Practical and pragmatic documentation. The Arch Wiki is the gold standard when it comes to documentation.

Thanks to Luke Smith and his excellent YouTube channel, and as usual the Arch Wiki got a great walkthrough and tips and tricks of what to expect setting up an Arch system from scratch.

Pre Install

Boot disk

To bootstrap the install process, a boot key is the way to go. Obtain the latest iso image, and block write it to a USB drive using dd. dd (aka disk destroyer to some) trusts you know what you’re doing and can destroy data very easily if not used correctly.

Use lsblk to determine the mapped device name (e.g. /dev/sdb). When ready, pull the trigger and flash the drive with arch:

dd if=Downloads/archlinux-2019.03.01-x86_64.iso of=/dev/sdb status="progress"

Boot the target system on the new boot drive. If all goes well, you will end up on a bash shell, in the temporary boot preparation system provided by Arch.

Post boot

Get network connectivity:

wifi-menu
ip a

Enable NTP:

timedatectl set-ntp true

Partitioning

UEFI (supports newer 64-bit based GPT) or BIOS (based on traditional MBR). If the below sys node doesn’t exist, go BIOS:

ls /sys/firmware/efi/efivars

Determine the target block device (e.g. an SSD) for installation, using lsblk.

Assuming a BIOS compatible system, will go with fdisk (not gdisk) for the partitioning setup:

fdisk /dev/sda

fdisk shortcuts:

  • m help
  • p print partition table
  • d delete
  • n new

In a nutshell, blow away any existing partitions (d), and create 4 new (n) primary partitions. Note when specifying the last sector can size with +200M style syntax, +200M is 200MiB, +50G is 50GiB. I cut my ~500GB drive up into the following 4 partiions:

  • 200M for boot partition (grub etc)
  • 24G for swap (rule of thumb is 150% of total system memory)
  • 100G for root partition
  • ~340G+ for home partition (leave last sector unspecified in fdisk to use all remaining space)

We are aiming for a partition layout similar to this:

$ lsblk            
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465.8G  0 disk 
├─sda1   8:1    0   200M  0 part /boot
├─sda2   8:2    0    24G  0 part [SWAP]
├─sda3   8:3    0   100G  0 part /
└─sda4   8:4    0 341.6G  0 part /home

Format partitions (file systems)

Apply ext4 (the fourth extended filesystem) to the boot, root and home partitions (i.e. all but the swap):

mkfs.ext4 /dev/sda1
mkfs.ext4 /dev/sda3
mkfs.ext4 /dev/sda4

Then setup the swap space:

mkswap /dev/sda2
swapon /dev/sda2

Mount partitions

Now its time to mount these new partitions into the Arch bootstrapped system, so they be used.

The four partitions will be mounted into the current Arch boot preparation systems file system tree under /mnt so a chroot can occur, and then system installation. First mount the root partition, then the boot and home partitions within the root mount under /mnt/boot and /mnt/home respectively.

mount /dev/sda3 /mnt
mkdir -p /mnt/boot /mnt/home
mount /dev/sda1 /mnt/boot
mount /dev/sda4 /mnt/home

Installation

Setup pacman mirrors

Defined in /etc/pacman.d/mirrorlist. Higher mirrors in the list taken precedence over lower once, rearrange as desired:

##
## Arch Linux repository mirrorlist
## Filtered by mirror score from mirror status page
## Generated on 2019-04-01
##

## Australia
Server = http://mirror.internode.on.net/pub/archlinux/$repo/os/$arch
## Turkey
Server = http://mirror.veriteknik.net.tr/archlinux/$repo/os/$arch

Install Arch with pacstrap

The pacstrap script will install the base, and if desired other package groups, such as base-devel for common build related programs.

pacstrap /mnt base base-devel

Configuration

fstab

So that the mount are automatically applied as part of the system boot process, add them to /etc/fstab as UUID’s, which are more robust than device names which can change.

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

chroot

Now to change root into the new system, from the Arch boot preparation system:

arch-chroot /mnt

root password

Set the password for the root account with passwd

Localisation

Uncomment en_US.UTF-8 and UTF-8 in /etc/locale.gen, and generate:

locale-gen

Create /etc/locale.conf with:

LANG=en_US.UTF-8

Time zone

Symlink in the appropriate zone definition:

ln -sf /usr/share/zoneinfo/Australia/Canberra /etc/localtime

Run hwclock --systohc to generate /etc/adjtime

Networking

  • Create /etc/hostname, and define a name for the host.
  • Edit /etc/hosts for loopback based on the defined hostname above, 127.0.1.1 myhostname.localdomain myhostname
  • Install NetworkManager which provides persistent network configuration across reboots, pacman -S networkmanager and enable it systemctl enable NetworkManager

Boot loader (GRUB)

Several boot loaders are supported but here are going with GRUB.

pacman -S grub
grub-install --target=i386-pc /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

Reboot

A minimal base system is installed and configured, and ready to be used.

  • Escape chroot with ctrl+d or exit.
  • Unmount everything umount -R /mnt, lsblk should confirm this.
  • reboot
  • Remove the USB drive

Post boot

Fix wifi

Unfortunately wifi settings were not persisted. Fix with:

nmcli dev wifi connect wifi-sid-goes-here password wifi-password-goes-here

Add users

useradd -m -g wheel ben
passwd ben
sudo vi /etc/sudoers

Uncomment (line 85) to allow members of the wheel group to sudo with (or without) password prompting:

%wheel ALL=(ALL) NOPASSWD: ALL

Desktop Environment (DE) vs Window Manager (WM)

In a nutshell a DE (like gnome or kde) is very heavy weight includes everything bar the kitchen sink, such as music players, document editors, file managers. They are incredibly bloated, but aimed at novice users that just want their computer “to work”. A WM (like i3wm) on the other hand is incredibly lean, I mean you don’t even get a status bar, but are very customisable and do just what you want and no more. Becuase of this WM’s tend to be allot snappier.

i3-gaps

i3-gaps is a fork of the excellent i3wm tiling window manager. As its name implies it supports placing gaps (i.e. regions of space) between the tiled windows, providing a very neat and satisfying perseption of order when windows are automatically laid out.

i3-gaps in action

pacman -S xorg-server xorg-xinit
pacman -S xf86-video-amdgpu
pacman -S i3-gaps i3status rxvt-unicode dmenu

To autostart i3:

Edit ~/.xinitrc with following:

exec i3

Then startx. A black screen desktop should appear. This is good.

Essential applications

If you’ve gone down the window manager route, there is literally nothing. Given nothing is installed, here are some nice lightweight options I use:

  • Text editor: nvim
  • PDF viewer: qpdfview
  • Hypervisor (VM’s): vbox
  • IRC client: irsii
  • Games: steam, nethack
  • VPN: openvpn
  • Video player: vlc
  • Music player: mpd, mpc, ncmpcpp
  • Screenshots: maim, xclip
  • Image viewer: sxiv

i3 ricing

The term ricing originates from the auto enthusiast community, and was used predominantly as a perjorative to describe people who make modifications to their (usually Japanese) cars that add visual flair, but don’t improve performance. In the context of unixporn, it means customizing your desktop to make it look snazzy.

Wallpaper

pacman -S feh

Add a task runner to ~/.config/i3/config to always set the wallpaper whenever i3 runs.

exec_always --no-startup-id feh --bg-scale /home/ben/Pictures/Wallpapers/nature3.jpg

Sound

pacman -S alsa-utils

Can now run alsamixer to manage the sound card.

Load Xresources at startup

Need to customise the appearance of apps like urxvt.

exec_always --no-startup-id xrdb -load ~/.Xresources

If you dont have a ~/.Xresources of your own, checkout my dotfiles.

Install fonts

pacman -S ttf-font-awesome powerline-fonts noto-fonts adobe-source-code-pro-fonts

Making GTK and QT apps pretty

pacman -S lxappearance gtk-chtheme gtk-engine-murrine gtk-engines gnome-themes-extra qt5ct

Define the following environment variables to override default QT styling:

export QT_STYLE_OVERRIDE=adwaita
export QT_QPA_PLATFORMTHEME="qt5ct"
export QT_AUTO_SCREEN_SCALE_FACTOR=0

Conclusion

This is a worth while endevour to take. I now have a very tailored system that works exactly how I want, without any bloat, and its FAST. Finally if interested, all my configuration from vim to urxvt to i3 is in my dotfiles git repo. Enjoy.