Sven and the Art of Computer Maintenance

Sven and the Art of Computer Maintenance

24 Feb 2019

Arch Linux quick start guide

Installing Arch Linux is not really that lengthy as the wiki makes it seem to be. What makes the official installation guide daunting is that it tries to keep track of every little aspect that could be relevant in obscure or rare situations. It provides a good reference manual for those who already have some experience with Arch Linux, but this puts those who lack experience in an uncomfortable position. To learn more about the installation process to understand the official guide better it is required to finish an installation at least once.

That is where this quick start guide comes into play. Instead of looking at all possible scenarios the scope is much more narrow, limited to a virtual machine. It makes the whole installation process more clear by limiting all the executed commands to a single overview.

This quick start guide assumes the use of a ‘Linux, Other Linux (64-bit)’ VirtualBox virtual machine or a ‘Other Linux 4.x or later kernel 64-bit’ VMware virtual machine. The machine has two Ethernet adapters: one connected to a NAT-based internet connection, the other to a bridged network on a physical network interface. This is to clarify the difference between using DHCP and using a static IP address.

Boot using the latest Arch Linux ISO image.

Run:

# Partition and format local storage, and install Arch Linux
echo -ne "o\nn\n\n\n\n\na\nw\n" | fdisk /dev/sda
mkfs.btrfs /dev/sda1
mount /dev/sda1 /mnt
btrfs subvolume create /mnt/root
umount /mnt
mount -o subvol=root /dev/sda1 /mnt

#For VirtualBox:
pacstrap /mnt base linux grub btrfs-progs sudo openssh \
  virtualbox-guest-modules-arch virtualbox-guest-utils-nox

#For VMware:
pacstrap /mnt base linux grub btrfs-progs sudo openssh open-vm-tools

# Make the system bootable
genfstab -U /mnt >> /mnt/etc/fstab
arch-chroot /mnt
grub-install --target=i386-pc /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

# Configure date/time and localization settings
ln -sf /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime
systemctl enable systemd-timesyncd.service

sed -i -E 's/^#(en_US.UTF-8 UTF-8)/\1/' /etc/locale.gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
locale-gen

# Configure network settings
echo "archlinux" > /etc/hostname
echo "127.0.0.1 localhost" >> /etc/hosts
echo "::1 localhost" >> /etc/hosts
echo "127.0.1.1 archlinux.localdomain archlinux" >> /etc/hosts

echo "[Match]" > /etc/systemd/network/ens32-nat.network
echo "Name=ens32" >> /etc/systemd/network/ens32-nat.network
echo "" >> /etc/systemd/network/ens32-nat.network
echo "[Network]" >> /etc/systemd/network/ens32-nat.network
echo "DHCP=yes" >> /etc/systemd/network/ens32-nat.network

echo "[Match]" > /etc/systemd/network/ens33-bridge.network
echo "Name=ens33" >> /etc/systemd/network/ens33-bridge.network
echo "" >> /etc/systemd/network/ens33-bridge.network
echo "[Network]" >> /etc/systemd/network/ens33-bridge.network
echo "Address=192.168.1.1/24" >> /etc/systemd/network/ens33-bridge.network
echo "#Gateway=" >> /etc/systemd/network/ens33-bridge.network
echo "#DNS=" >> /etc/systemd/network/ens33-bridge.network

# Disable DNSSEC if it is not supported by the DNS server
echo "DNSSEC=no" >> /etc/systemd/resolved.conf

systemctl enable systemd-networkd
systemctl enable systemd-resolved

# Configure local user accounts
passwd
sed -i -E 's/^# (%wheel ALL=\(ALL\) ALL)/\1/' /etc/sudoers
useradd -m -G wheel -s /bin/bash myusername
passwd myusername

# Enable OpenSSH server
systemctl enable sshd

# Enable virtual machine guest tools
# For VirtualBox:
systemctl enable vboxservice

# For VMware:
systemctl enable vmtoolsd
systemctl enable vmware-vmblock-fuse

# Create a snapshot of the freshly installed system
mkdir /.snapshots
btrfs subvolume snapshot -r / /.snapshots/system-installed

# Wrap up and restart
history -c && exit
sync
umount /mnt
reboot

Change the time zone, network configuration and ‘myusername’ to what suits you best. Also double check the names of the network interfaces, for example by using ip addr.

At the time of writing the total download size (aside of the ISO image) is around 280 MB for 162 packages, and the total installation size is around 1100 MB.

Hints:

  • If you install the operating system bare-metal, the VirtualBox and VMware packages can be skipped, of course.
  • If you need wireless network support, add the packages wpa_supplicant and dialog to the pacstrap command, which make initial configuration easier by offering wifi-menu in the freshly installed operating system. Make sure to stop systemd-networkd and systemd-resolved, and start netctl when using it.
  • A quick one-liner to get a graphical user-interface on a system with an Intel graphics adapter: pacman -S xorg xf86-vide-intel mesa sddm plasma-meta && systemctl enable sddm && systemctl start sddm. Note that this can increase your installation size by 1700 MB or more. Add package kdebase-meta to install some common graphical applications (a file manager, a terminal emulator, a text editor, etc.).
  • To support easy network configuration in a graphical user environment and using nmcli, disable systemd-networkd and systemd-resolved. Enable and start NetworkManager. Add the required widget to the taskbar through Panel options -> Add Widgets -> Networks.