Installing Arch Linux on a desktop PC

screenshot of Arch Linux desktop installation

Quick introduction to Arch Linux

Arch Linux is a more minimalist Linux distribution that uses a rolling release model. This means the installation will be constantly updated without the need of reinstalling to get the latest version. As such, Arch Linux has one of the most up-to-date Linux kernels which means getting the latest security and compatibility patches almost as soon as they come out. It’s very flexible and customisable, but not very user-friendly. This means it’s not really intended for average users, but makes it ideal for people that have good understanding of Linux (such as system administrators or developers) and like tinkering with the OS to get the most out of it.

The installation process

If you are already familiar with Arch Linux, or you want to try your hand at figuring out how you want it set up this part next part isn’t for you and you should go to ArchWiki instead, but if you’re curious about my personal preferences for installing Arch Linux this should give you all the important information. I have also provided a description of each command and package I’ll use step by step. I’ll assume that you already have an image prepared on your installation media of choice.

  1. Setting up the live boot environment

    1. verify that you have EFI boot mode enabled by checking if the directory /sys/firmware/efi/efivars is present, otherwise you won't be able to install GRUB with EFI
    2. make sure you have network connection using the ifconfig or ip -a command
    3. you can set your keyboard layout using the loadkeys command with the correct keyboard layout name that you can find in the subdirectories of the /usr/share/kbd/keymaps directory (cz-qwertz in my case)
  2. OS drive partitioning

    We’ll need to use GPT partition table and create 300MB EFI partition and OS partition spanning rest of the drive on the boot drive using fdisk. If you're not familiar with it you can learn about it on ArchWiki.

    1. locate the drive you want to install Arch Linux to using lsblk or fdisk -l
    2. partition the drive using fdisk /dev/<drive name> command

  3. Creation of filesystems on partitions

    Before mounting the OS and EFI partitions we need to create a filesystems on them so they can be mounted and files can be stored on them.

    1. format the EFI partition to FAT32 using the mkfs.fat -F 32 /dev/<EFI partition name> command
    2. format the OS partition to ext4 using mkfs.ext4 /dev/<OS partition name> command

  4. Mounting OS and EFI partitions

    With the partitions having file system on them we can finally mount them so that we can install and set up Arch Linux on them

    1. mount the OS partition to /mnt directory using the mount /dev/<OS partition name> /mnt command
    2. create boot directory inside the /mnt directory using the mkdir /mnt/boot command
    3. mount the EFI partition to the newly created directory using the mount /dev/<EFI partition name> /mnt/boot command
  5. Updating GPG signatures for pacman (may not be required but recommended)

    If our installation image is a bit older it may be that not all GPG signatures that are required to verify validity of pacman packages are present in which case we need to update them.

    1. update the gnupg and archlinux-keyring packages using the pacman -Sy gnupg and archlinux-keyring command
    2. reinitialise the list of pacman’s trusted keys with the pacman-key --init command
    3. reload keys from the archlinux keyring using the pacman-key --populate archlinux command
  6. Installing essential packages to the OS partition

    Now we can finally start installing Arch Linux and our essential packages.

    • run the pacstrap /mnt archlinux-keyring man-db man-pages texinfo base base-devel linux linux-firmware grub efibootmgr xorg xorg-xinit xorg-drivers htop vim sudo git usbutils pciutils net-tools networkmanager network-manager-applet openssh ca-certificates command to install Arch Linux and our essential packages

    We don’t need all of these packages to get Arch Linux working but installing these packages now can save us time later and it will make the whole process easier. Let me walk you through all the packages that we’ll install.

    • archlinux-keyring – Arch Linux GPG keys
    • man-db, man-pages, texinfo – man (manual for commands and other useful things)
    • base-devel – development tools for building programs (gcc, make, etc.)
    • linux, linux-firmware – core linux packages
    • grub, efibootmgr – bootloader tools
    • xorg, xorg-xinit, xorg-drivers – Xorg display server packages and drivers
    • htop – process viewer
    • sudo – command for executing commands as root or other users
    • git – content tracker
    • usbutils, pciutils – add programs for listing USB (lsusb) and PCI(-E) (lspci) devices
    • net-tools – adds ifconfig
    • networkmanager – network manager daemon
    • network-manager-applet – applet for network configuration
    • openssh – SSH server
    • ca-certificates – SSL certificates
  7. fstab configuration

    Before we finally enter into our boot drive we should generate an fstab file for it so that all the partitions mount automatically

    • generate the fstab file using the genfstab -L /mnt >> /mnt/etc/fstab command
  8. “chrooting” into the mounted OS partition

    Now that the boot drive is fully prepared we can chroot into it to configure the remaining parts of Arch Linux before we will be able to boot directly into it

    • use arch-chroot /mnt command to chroot into the OS partition on the boot drive
  9. Timezone and hardware clock configuration

    • create symlink in /etc/localtime pointing to your timezone that you can find in subdirectories of the /usr/share/zoneinfo directory using the ln -sf <timezone file> /etc/localtime command
  10. Setting up system locales

    1. uncomment your correct locale (en_US.UTF-8 UTF-8 in my case) in the /etc/locale.gen file
    2. generate locales using the locale-gen command
    3. write your correct locale in the LANG=<your locale> format (LANG=en_US.UTF-8 in my case) into the /etc/locale.conf file
    4. write your keyboard layout in the KEYMAP=<your keyboard layout> format (KEYMAP=cz-qwertz in my case) into the /etc/vconsole.conf file
  11. Creating and configuring system hostname

    1. write your hostname into the /etc/hostname file
    2. add following to /etc/hosts
      
      127.0.0.1	localhost
      ::1			localhost
      127.0.1.1 	<your hostname>.local <your hostname>
      						
  12. Enabling network manager

    This will enable networking daemon on system startup

    • systemctl enable NetworkManager
  13. initramfs generation

    • generate initramfs using the command mkinitcpio -P
  14. Installing and configuring GRUB

    One of the very last steps we have to do before rebooting into Arch Linux is to install and configure GRUB into which we’re going to boot after restart

    1. install grub with the grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB command
    2. configure grub using the grub-mkconfig -o /boot/grub/grub.cfg command

    IMPORTANT NOTE: file extension of the configuration file is .cfg and NOT .conf

  15. Setting up root password

    • set your root password (ideally to something secure) using the command passwd
  16. Setting up new user account

    1. add your user account using the command useradd -m <your username>
    2. set password of your user account using the command passwd <your username>
    3. add your account to groups wheel, tty and uucp using the command usermod -aG wheel,tty,uucp <your username>
  17. Change system permissions for group wheel

    • open the file /etc/sudoers with visudo and uncomment sudo permissions for group wheel

    WARNING: this will open the file in vi (not vim) so make sure to use the proper vi controls keys

  18. Leaving chroot and rebooting into Arch Linux

    Congratulations! You’ve now installed, and prepared Arch Linux for installation of a graphical user interface. Now exit chroot, unmout your boot drive and reboot to your Arch Linux installation.

    1. exit chroot using the exit command
    2. umount your boot drive with umount -R /mnt command
    3. reboot to your Arch Linux installation with reboot now command

  19. Installing DM (desktop manager) and DE (desktop environment) or WM (window manager)

    There are many ways you can use Arch Linux as a desktop OS. You can use it with a desktop manager like lightdm, for example, or not use it at all. You can choose between installing just a bare window manager like openbox and configure it yourself, or whole desktop environment like plasma which will provide you with complementary applications to make everything look and feel more seamless. Since there are so many options I recommend you to do your own research into this topic to decide your preference. There are many great videos on this topic from YouTube channels such as DistroTube and many have an article about them on Arch Wiki that you can read to get more detailed information. I personally am using the Openbox window manager configured almost exactly as is shown in a video from DistroTube with tint2 panel and rofi without a desktop manager.

Tips and tricks to do after DM and DE/WM installation

After you’re done with completing the last step you are already completely finished with installing as a desktop OS, but there are still few improvements you can do to your installation to make it a bit more pleasant.

  1. install the package manager called yay, which has the same functionality as pacman but also allows easy installation of AUR repositories, by cloning its git repository with the command git clone https://aur.archlinux.org/yay.git and running the command makepkg -si to install it
  2. install font packages noto-fonts, noto-fonts-emoji, ttf-dejavu and ttf-droid to get greater font compatibility with Unicode
  3. install audio packages alsa-card-profiles, alsa-firmware, alsa-lib, alsa-utils, pulseaudio-alsa, pulseaudio, pulsemixer and pavucontrol to get better control over your system audio
  4. if you have installed the file manager called caja (which I would recommend using) install packages gvfs-mtp and gvfs-smb so that you can transfer files over MTP and Samba respectively