Setting up Arch Linux from scratch

A step by step guide on how to setup Arch Linux on your system from scratch

Arch Linux is a lightweight and flexible Linux distribution that tries to Keep It Simple (KISS), but I am sure you have done your research on Arch Linux.

So lets dive into the steps to install Arch Linux from scratch:

Make a bootable drive

Download Arch Linux from here

If using Windows, download Rufus and create a bootable drive. If you are on Linux, you can use the dd command to create a live USB.

Installation

Insert your bootable drive and select “Install Arch Linux” and follow below steps:

Verify boot mode

1
ls /sys/firmware/efi/efivars

If the command shows the directory without error, then the system is booted in UEFI mode.
If the directory does not exist, the system may be booted in BIOS (or CSM) mode.

Connect to Internet

Step 1: Check network interfaces

1
ip link

Step 2: Setup wifi and Connect Internet

1
iwctl --passphrase <passphrase> station <wlan0> connect <wifi_ssid>

Replace <passphrase>, <wlan0>, <wifi_ssid> appropriately. <wlan0> is wifi interface, use ip link to check yours.

Step 3: Check if Internet is working

1
ping google.com

Setup datetime

Here we will setup System Clock, read more about system_time

Step 1: Set Network Synchronization

1
timedatectl set-ntp true

Step 2: Setting timezone, run timedatectl list-timezones to list all timezones

1
timedatectl set-timezone Asia/Kolkata

Step 3: Check if properly configured

1
timedatectl status

We will sync with hardware clock later.

Partition devices

Note: If you have dual boot, make sure you have already alloted blank space for linux partition. Else please do this in the current os (Windows for me).

Step 1: Check partition volumes

1
lsblk

Output for me:

partition volumes
partition volumes

Step 2: Minimum we need the following partitions:

You can have separate partition for SWAP, and even your home directory, skipping this here.

Step 3: Use fdisk to partition your drives.

Note: Be careful with the tool, it may delete your existing data and drives.

In my case, the drive was /dev/sdb, see below image:

partition volumes
partition volumes

Create a new partition using the tool (delete existing partition if required, be careful before you save your changes, you might lose your data on the drive).

Step 4: Format the partition

1
mkfs.ext4 /dev/sdb5

Use the partition which you created with fdisk, for me it is /dev/sdb5

Step 5: Format partition for UEFI filesystem (boot menu)

If reinstalling or replacing old linux distro, this would have been already there, so you can skip this. Replace with the partition you created, for me it is /dev/sdb1

1
mkfs.fat -F32 /dev/sdb1

Step 6: Extra:

If using SWAP, format SWAP partition also, replace swap_partition

1
mkswap /dev/swap_partition

Mount the file system

1
mount /dev/sdb5 /mnt

Here, I mounted /dev/sdb5 which was my partition (see above image).

Installing essential packages

1
pacstrap /mnt base base-devel linux linux-firmware vim vi

Configurations

Fstab

Fstab: Defines how disk partitions, various other block devices, or remote filesystems should be mounted into the filesystem

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

Changing root directory

Currently our root directory is that of bootdrive, we will change root directory to the system disk (/mnt -> drive we mounted in previous step)

This step is very important and all other configurations need to follow after this, or else the installation won’t be complete.

1
arch-chroot /mnt

Timezone

This is to setup local time configuration, see localtime for more info

1
ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime

Above I am setting Asia/Kolkata, you can select your timezone from this directory /usr/share/zoneinfo

1
ls /usr/share/zoneinfo

Sync with hardware clock

1
hwclock --systohc --utc

Localization

Edit /etc/locale.gen and uncomment en_US.UTF-8 UTF-8 and then run below commands:

1
locale-gen
1
echo "LANG=en_US.UTF-8" > /etc/locale.conf

Network

Setup a hostname for your system (here: wilstation)

1
echo "wilstation" > /etc/hostname

Configuring hosts file, replace hostname with what you setup above in below command

1
2
3
echo "127.0.0.1	localhost
::1		localhost
127.0.1.1	wilstation.localdomain	wilstation" > /etc/hosts

Users

Create user and setup password, creating wilspi here

1
2
useradd -m -g users -G wheel -s /bin/bash wilspi
passwd wilspi

Sudoers, users who can run sudo command, below is simple configuration wherein users who are part of wheel group can run sudo

1
pacman -S sudo
1
2
echo "root ALL=(ALL) ALL
%wheel ALL=(ALL) ALL" > /etc/sudoers
1
2
chown -c root:root /etc/sudoers
chmod -c 0440 /etc/sudoers

Boot Configuration

Run Below commands to setup your boot configuration:

1
pacman -S grub efibootmgr
1
mkdir /boot/efi

Note: For below command, /dev/sdb1 (my UEFI partition) is mounted to /boot/efi

1
mount /dev/sdb1 /boot/efi
1
grub-install --target=x86_64-efi --bootloader-id=GRUB --efi-directory=/boot/efi
1
grub-mkconfig -o /boot/grub/grub.cfg
1
mkinitcpio -P 

Root Password

1
passwd

Desktop Environment (GNOME)

We will be setting up GNOME as the desktop environment, as the GNOME page says, GNOME is simple, beautiful and elegant.

You can use any other from this list of desktop environments.

1
pacman -S xorg gnome

Enable GDM (Gnome Desktop Manager) service,
this will make sure when you next restart your system GDM service (graphical user interface) will be up and you won’t have to login via command line interface

1
systemctl enable gdm.service

Pre final steps

We are almost done, setting up drivers and enabling services.

Enabling means the system will run the service on the next boot. So if you enable a service, you don’t need to manually start the service after you start your service.

Step 1: Graphics driver

1
pacman -S nvidia

nvidia pkg works for most of the nvidia graphics driver, check other packages for nvidia drivers for confirmation.

Step 2: Enable NetworkManager

1
systemctl enable NetworkManager.service

You can use other network managers as well.

Step 3: Enable Bluetooth

1
systemctl enable bluetooth.service

Final steps before rebooting

Step 1: Unmount uefi partition

1
umount /boot/efi

Step 2: Exit chroot

1
exit

Step 3: Unmount system partition

1
umount /mnt

Step 4: Reboot

1
reboot now

Post Installation

After logging in,

Step 1: Connect Internet via wifi

Add wifi details using nmcli, a cli (command line interface) tool for NetworkManager, you can connect Internet via GUI also:

1
nmcli device wifi connect <wifi_SSID> password <password>

Step 2: Install other utility packages using pacman:

1
sudo pacman -S amd-ucode git bash-completion ntfs-3g pacman-contrib firefox net-tools gnome-tweak-tool 

Step 3: Setup yay for AUR, yay is yet another yogurt, pacman wrapper and AUR helper:

1
2
3
4
5
# Install yay
git clone https://aur.archlinux.org/yay.git
cd yay/
makepkg -si
cd .. && rm -rf yay

Remedies

GDM takes too much time to reboot, sometimes get stuck on loading screen.

This happens because nvidia drivers are not getting loaded before GDM.

Add nvidia modules in MODULES in file: /etc/mkinitcpio.conf, see below:

1
MODULES=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)

Rebuild image:

1
mkinitcpio -P

More details: Nvidia page on Arch Wiki

Not able to connect to Internet

Sometimes due to some mishap (configs/packages go outdated, you missed installing something) you are not able to connect to Internet.

You can chroot into the machine and fix the network issue.

  • Reload the bootloader
  • Load into the terminal (by choosing installing Arch)
  • Setup your internet
  • Change root to your system using chroot

System Screenshots

Keeping it simple silly.

Screenshot-1
Screenshot-1

Screenshot-2
Screenshot-2

Screenshot-3
Screenshot-3