Installing Arch Linux on a desktop PC
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.
-
Setting up the live boot environment
-
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 - make sure you have network connection using the
ifconfig
orip -a
command -
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)
-
verify that you have EFI boot mode enabled by checking if the directory
-
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.- locate the drive you want to install Arch Linux to using
lsblk
orfdisk -l
- partition the drive using
fdisk /dev/<drive name>
command
- locate the drive you want to install Arch Linux to using
-
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.
- format the EFI partition to FAT32 using the
mkfs.fat -F 32 /dev/<EFI partition name>
command - format the OS partition to ext4 using
mkfs.ext4 /dev/<OS partition name>
command
- format the EFI partition to FAT32 using the
-
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
- mount the OS partition to
/mnt
directory using themount /dev/<OS partition name> /mnt
command - create boot directory inside the
/mnt
directory using themkdir /mnt/boot
command - mount the EFI partition to the newly created directory using the
mount /dev/<EFI partition name> /mnt/boot
command
- mount the OS partition to
-
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.
- update the
gnupg
andarchlinux-keyring
packages using thepacman -Sy gnupg
andarchlinux-keyring
command - reinitialise the list of pacman’s trusted keys with the
pacman-key --init
command - reload keys from the archlinux keyring using the
pacman-key --populate archlinux
command
- update the
-
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 keysman-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 packagesgrub
,efibootmgr
– bootloader toolsxorg
,xorg-xinit
,xorg-drivers
– Xorg display server packages and drivershtop
– process viewersudo
– command for executing commands as root or other usersgit
– content trackerusbutils
,pciutils
– add programs for listing USB (lsusb) and PCI(-E) (lspci) devicesnet-tools
– addsifconfig
networkmanager
– network manager daemonnetwork-manager-applet
– applet for network configurationopenssh
– SSH serverca-certificates
– SSL certificates
-
run the
-
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
- generate the fstab file using the
-
“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
-
use
-
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 theln -sf <timezone file> /etc/localtime
command
-
create symlink in
-
Setting up system locales
- uncomment your correct locale (
en_US.UTF-8 UTF-8
in my case) in the/etc/locale.gen
file - generate locales using the
locale-gen
command - write your correct locale in the
LANG=<your locale>
format (LANG=en_US.UTF-8
in my case) into the/etc/locale.conf
file - write your keyboard layout in the
KEYMAP=<your keyboard layout>
format (KEYMAP=cz-qwertz
in my case) into the/etc/vconsole.conf
file
- uncomment your correct locale (
-
Creating and configuring system hostname
- write your hostname into the
/etc/hostname
file -
add following to
/etc/hosts
127.0.0.1 localhost ::1 localhost 127.0.1.1 <your hostname>.local <your hostname>
- write your hostname into the
-
Enabling network manager
This will enable networking daemon on system startup
systemctl enable NetworkManager
-
initramfs generation
- generate initramfs using the command
mkinitcpio -P
- generate initramfs using the command
-
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
-
install grub with the
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
command -
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
-
install grub with the
-
Setting up root password
- set your root password (ideally to something secure) using the command
passwd
- set your root password (ideally to something secure) using the command
-
Setting up new user account
- add your user account using the command
useradd -m <your username>
- set password of your user account using the command
passwd <your username>
- add your account to groups
wheel
,tty
anduucp
using the commandusermod -aG wheel,tty,uucp <your username>
- add your user account using the command
-
Change system permissions for group wheel
- open the file
/etc/sudoers
withvisudo
and uncomment sudo permissions for groupwheel
WARNING: this will open the file in
vi
(notvim
) so make sure to use the proper vi controls keys - open the file
-
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.
- exit chroot using the
exit
command - umount your boot drive with
umount -R /mnt
command - reboot to your Arch Linux installation with
reboot now
command
- exit chroot using the
-
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 androfi
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.
-
install the package manager called
yay
, which has the same functionality aspacman
but also allows easy installation of AUR repositories, by cloning its git repository with the commandgit clone https://aur.archlinux.org/yay.git
and running the commandmakepkg -si
to install it -
install font packages
noto-fonts
,noto-fonts-emoji
,ttf-dejavu
andttf-droid
to get greater font compatibility with Unicode -
install audio packages
alsa-card-profiles
,alsa-firmware
,alsa-lib
,alsa-utils
,pulseaudio-alsa
,pulseaudio
,pulsemixer
andpavucontrol
to get better control over your system audio -
if you have installed the file manager called
caja
(which I would recommend using) install packagesgvfs-mtp
andgvfs-smb
so that you can transfer files over MTP and Samba respectively