How to install Arch Linux

How to install Arch Linux

How to install Arch Linux

Updates:

2021–12–06: There is an easy way to install Arch Linux if you want to get an arch installation up and running within a few minutes without the hassle. 
The Arch Installer is a python script provided with the arch ISO that follows the same philosophies of Arch.
You can invoke the arch installer with the following command and follow the screen instructions.

archinstall

Repository: https://github.com/archlinux/archinstall

Although this is simple and fast, I would encourage following the guide and setting up your arch to understand how everything works together, make mistakes, and resolve those. It would save time in the future.


Arch Linux is an excellent Linux distribution with the support for multiple desktop environments, and it has a great community behind it.

Every step here is described in detail in ArchWiki https://wiki.archlinux.org, so if you run into any issues, the wiki is the first place you should look at.

Arch Linux installation is hands-on, compared to the installation of other Linux distributions like Ubuntu. The best experience about this is that once you install it, Arch feels like the distribution that you always needed.

The installation can be different on the hardware you have, for example, if you have an AMD processor and or UEFI based hardware, boot configuration can be different from an Intel-based system.

File system: btrfs
DE: Gnome
Boot: UEFI with GPT (systemd-boot) / BIOS with MBR untested — refer to the arch documentation for partition layouts. https://wiki.archlinux.org/index.php/Partitioning#Example_layouts
Processor: AMD
Graphics: AMD and Nvidia

Last updated: 07/June/2020


Step 1: Download the Arch ISO and create a bootable USB

Download: https://archlinux.org/download/

Make sure you have read the system requirements on the download page.

To create a bootable disk, you can use Etcher or Rufus. If you are on Windows, use Rufus. It does the job really well, and I have not had any problems so far.

If you use Rufus, make sure you select the target system as BIOS or UEFI that will make sure the bootable will work with both BIOS and UEFI systems.

Step 2: Boot from the live USB and Partitioning disks

Boot from the Live USB you have created, and Arch Installer will boot into a shell prompt.

Use timedatectl to ensure the system clock is accurate:

$ timedatectl set-ntp true

Before starting the partitioning process, use the below command to identify the disk you need to partition:

$ fdisk -l
fdisk -l

then create the following partition structure:

  1. boot
  • 512MB
  • EFI system partition type

2. root

  • Remaining space
  • Default type Linux file system

I prefer to use gdisk utility to create partitions there are other partitioning tools like cfdisk, you can use your preferred partitioning tool.

$ gdisk /dev/nvme0n1

Press o to create a new gpt partition table and press n to add a new partition.

Press enter for the first sector, for the last sector type +512MB, set the file system type as ef00 to create UEFI boot partition for UEFI systems.

again press n to add a new partition notice that partition number automatically identified as 2 and start sector is automatically set after the Last sector of the first sector. Just press enter for the rest of the prompts. This will create the second partition using the rest of the disk space, and finally, press w to write the new partition table to the disk.

fdisk -l

Step 3: Create filesystem

Create filesystem for the first partition we resaved for UEFI and create a btrfs partition for the second partition.

$ mkfs.fat -F32 /dev/
$ mkfs.btrfs /dev/
fdisk -l

Since we are using btrfs as our root volume, now is the time to create subvolumes.

  • / subvolume
  • /home subvolume in case a root snapshot needs to be restored
  • /var changes often so also a separate subvolume.
  • noatime and nodiratime are used to prevent a write every time a file or directory is accessed (not great for a COW filesystem like btrfs).
  • zstd is used for compression because it is fast and provides compression similar to xz.
  • Don’t use discard . Issue manual trim commands with fstrim or enable the fstrim.timer.
fdisk -l
$ mount /dev/nvmen1p2 /mnt
$ btrfs subvolume create /mnt/@
$ btrfs subvolume create /mnt/@home
$ btrfs subvolume create /mnt/@var
$ umount /mnt
$ mount -o subvol=@,ssd,compress=zstd,noatime,nodiratime /dev/nvme0n1p2 /mnt
$ mkdir -p /mnt/{boot,home,var}
$ mount -o subvol=@home,ssd,compress=zstd,noatime,nodiratime /dev/nvme0n1p2 /mnt/home
$ mount -o subvol=@var,ssd,compress=zstd,noatime,nodiratime /dev/nvme0n1p2 /mnt/var
$ mount /dev/nvme0n1p1 /mnt/boot
fdisk -l

Step 4: Installation of the system

Install base system:

Here I install zsh and released packages because I prefer zsh over bash. If you like to keep bash as default, you can remove all zsh* package arguments.

AMD systems

$ pacstrap c /mnt base base-devel linux linux-firmware btrfs-progs zsh zsh-autosuggestions zsh-completions zsh-syntax-highlighting amd-ucode vim

Intel Systems

$ pacstrap c /mnt base base-devel linux linux-firmware btrfs-progs zsh zsh-autosuggestions zsh-completions zsh-syntax-highlighting intel-ucode vim

Generate fstab and verify:

$ genfstab -U /mnt >> /mnt/etc/fstab
$ cat /mnt/etc/fstab
fdisk -l

Step 5: Configure system

Use arch-chroot and enter the mounted disk as root. This is an operation that changes the apparent root directory for the current running process and their children. A program that is run in such a modified environment cannot access files and commands outside that environmental directory tree. This modified environment is called a chroot jail.

$ arch-chroot /mnt

Setup the hostname:

$ echo barney > /etc/hostname

edit /etc/hosts

127.0.0.1   localhost
::1 localhost
127.0.1.1 barney.localdomain barney
::1 barney.localdomain barney

Change the shell to zsh: 
Continue to the next step if you do not like zsh as default

$ chsh -s /bin/zsh

Set the timezone:

$ timedatectl list-timezones
$ timedatectl set-timezone Asia/Colombo

Enable NTP auto time synchronisation:

$ systemctl enable systemd-timesyncd

Install and Enable network manager:

$ pacman -S networkmanager
$ systemctl enable NetworkManager

Localization:

Set up locale by uncommenting the correct locale in /etc/locale.gen file

$ vim /etc/locale.gen
$ locale-gen
$ echo LANG=en_US.UTF-8 > /etc/locale.conf
$ export LANG=en_US.UTF-8

Setup root password:

$ passwd

Step 5: Setup the boot loader

Since we are using btrfs as root partition we need to configure

$ vim /etc/mkinitcpio.conf

Add btrfs to HOOKS. This will make sure btrfs module will be added to the Linux boot image when generating.

HOOKS=”base udev autodetect modconf block btrfs filesystems keyboard fsck”

Regenerate the boot image:

$ mkinitcpio -p linux

Install systemd-boot bootloader:

$ bootctl --path=/boot install

Get UUID of cryptoLUKS partition:

$ blkid
fdisk -l

Create Arch entries:

Create /boot/loader/entries/arch.conf:

This is a script I used to copy UUID to arch.conf file. It will create the file with UUID.

$ blkid | grep -i p2 | awk '{ print $2 }' > /boot/loader/entries/arch.conf

modify the file to match with below configuration

ll for AMD based systems:

title Arch Linux 
linux /vmlinuz-linux
initrd /amd-ucode.img
initrd /initramfs-linux.img
options root=UUID=UUID_FROM_ABOVE rootflags=subvol=@ rw
fdisk -l

for Intel based systems:

title Arch Linux 
linux /vmlinuz-linux
initrd /intel-ucode.img
initrd /initramfs-linux.img
options root=UUID=UUID_FROM_ABOVE rootflags=subvol=@ rw

Edit /boot/loader/loader.conf and add below:

default arch
fdisk -l

Verify the config:

Navigate to /boot/loader/entries and check the configurations

  • Default
$ exit
$ umount -R /mnt
$ reboot

You should have a fully functioning Arch system. What comes next is your personal preferences. The example is a very basic vanilla Gnome desktop.

Step 6: Install a desktop environment

There are many desktop environments supported you can visit here and find the instructions to install your favourite desktop.

$ pacman -Syu gnome realtime

Ignore realtime package if you are using DE other than gnome. the realtime package is required for jack and jack2 audio used by the gnome.

Add user and set the password:
Make sure you set the correct shell for the user. I have used zsh as default, if you prefer bash use /bin/bash

$ useradd -mUG lp,network,power,sys,wheel,realtime -s /bin/zsh 
$ passwd newuser

Add user to wheel group to support administrative(sudo) permissions

$ EDITOR=nano visudo

Uncomment and save

%wheel ALL=(ALL) ALL

Enable display manager:

$ systemctl enable gdm

Reboot:

$ systemctl reboot

Step 7: Install graphic drivers

Installation of the graphic drivers can be different based on the graphics hardware.

to install Nvidia graphic driver

$ pacman -S nvidia

to install AMD graphics

$ pacman -S f86-video-ati

Step 8: Install yay for aur package management

The Arch User Repository (AUR) is a community-driven repository for Arch users. It contains package descriptions (PKGBUILDs) that allow you to compile a package from source with makepkg and then install it via pacman.

Install git:

$ sudo pacman -S git

Clone yay repo from aur:

$ cd /opt
$ git clone https://aur.archlinux.org/yay-git.git

generate the yay package and install:

$ cd yay-git
$ makepkg -si

Enjoy!