How To Install Arch Linux

ALB
8 min readOct 25, 2020

A minimal installation guide for installing Arch Linux. This guide assumes you have downloaded the latest version of Arch Linux from their website, verified it, and made a bootable USB stick with the ISO using Rufus (Windows), Etcher (macOS or Linux) or the dd command in another Linux distribution.

This guide follows the Arch Linux Wiki Installation Guide and some YouTube guides like Distro Tube, but it also includes some modifications or additions that we have made to keep the installation as complete as possible. This guide will be kept up to date with the Arch Linux Wiki Installation Guide as frequently as possible. However, it is recommended to follow this guide along with the Arch Wiki Installation Guide and a latest YouTube tutorial like the one mentioned above which is not older than 2–3 months.

Please note that this is not an explanatory guide and will not explain the steps given below.

1. Check Network Status

To install Arch Linux, we need an internet connection. For some hardware, Ethernet is the only choice during setup. So please check your hardware if you want to use a Wireless connection. Also, for wireless internet to work, if supported, please check the ‘Notes’ section at the bottom. Now use the following command to see if you have network access:

# ping -c 3 google.com

2. Verify Boot Mode

To see if the machine is capable of a UEFI install, run the below mentioned command. If you get an output, you can run in UEFI mode, if not, then you system will install in BIOS/CSM mode.

# ls /sys/firmware/efi/efivars

3. Set The System Clock

Set the system clock with this command:

# timedatectl set-ntp true

Check the system clock:

# timedatectl status

4. Partition The Disk

We are assuming the disk where we want to install the OS is sda for simplification. Also, we are using cfdisk, not fdisk as mentioned in the Arch Linux Wiki Installation Guide.

For BIOS (CSM) mode, we only need one partition, which is root. For UEFI, we need root and an EFI partition.

We give the root partition 30 GiB space if there is a home partition, or else the entire remaining disk space after EFI and Swap (If in UEFI mode). The EFI partition should be 500 MiB according to us. A home directory can also be included here if need be.

For Swap, you can read this link or many others on the internet. There are two ways of using Swap, one is to create a partition at this stage, and the second one is to create a Swap file later on. This guide will document both processes.

Identify the device:

# lsblk

Wiping out the partition table (Optional):

You should wipe out the partition table and start afresh. This is also useful if you want to install Arch Linux on a hard drive/partition that was previously formatted for gpt or dos and you want to go the other way.

# dd if=/dev/zero of=/dev/sda bs=1M count=1

Enter into cfdisk:

# cfdisk /dev/sda
  • Select gpt for UEFI mode or dos for BIOS (CSM)

Delete any existing partitions, then create the necessary partitions and change the type of the partitions:

To create a partition, select “New” on free space, then mention the size of the partition in G (GiB) or M (MiB), then select the partition type.

  • For the EFI partition, the partition type will be “EFI System”, for root and home, “Linux filesystem”, and for Swap, “Linux swap”.
  • Then go to “Write” and write the changes typing “yes” and then quitting cfdisk.

You can use the following command again to see the end result.

# lsblk

5. Format The Partitions

Format all the partition in the following way:

EFI partition:

# mkfs.fat -F32 /dev/sda1

Swap partition:

# mkswap /dev/sda2# swapon /dev/sda2

Root and home partitions:

# mkfs.ext4 /dev/sda3# mkfs.ext4 /dev/sda4

6. Mount The Partitions

Now we need to mount the root partition and home partition using the following commands:

Root partition:

# mount /dev/sda3 /mnt

Home partition:

# mkdir /mnt/home# mount /dev/sda4 /mnt/home

Run lsblk to check the mount points:

# lsblk

7. Mirrors (Optional)

To get the latest mirrors with the HTTPS protocol, install Reflector (If not already installed in the ISO) using the following command and then create the new mirrorlist:

Install Reflector:

# pacman -S reflector

Create the mirrorlist:

# reflector --latest 10 --protocol https --sort rate --save /etc/pacman.d/mirrorlist

Update the repositories again:

# pacman -Syy

Install Nano and/or Vim (If not installed already):

# pacman -S nano vim

Edit the pacman.conf file to enable the multilib repository (multilib contains 32-bit software and libraries that can be used to run and build 32-bit applications on 64-bit installs):

# nano /etc/pacman.conf
  • Now find and uncomment the following two lines:
[multilib]Include = /etc/pacman.d/mirrorlist

8. Install Essential Packages

Install the base package along with the Linux kernel and the Linux firmware:

# pacstrap /mnt base base-devel linux linux-firmware

9. Generate FSTAB

Generate the FSTAB file:

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

Check the FSTAB entry:

# cat /mnt/etc/fstab

10. Chroot

Change root into the new system:

# arch-chroot /mnt

11. Creating The Swap File

If you did not create the Swap partition earlier, you can now create a Swap file instead by running the following commands. Here we have made a 24G Swap file. The calculation is 24*1024:

Make a Swap file:

# dd if=/dev/zero of=/swapfile bs=1M count=24576 status=progress

Set the right permissions:

# chmod 600 /swapfile# mkswap /swapfile# swapon /swapfile
  • In case you want to remove the Swap file:
# swapoff /swapfile# rm /swapfile

Add the Swap file to FSTAB:

# nano /etc/fstab
  • Add this line at the end of the FSTAB file after leaving a space. Use Tab to clean and align the file:
/swapfile none swap defaults 0 0

Check the Swappiness value. The default value should be 60. We recommend 10:

# sysctl vm.swappiness

To temporarily set the value, use this command:

# sysctl -w vm.swappiness=10

To permanently set the value (This will take affect after a reboot):

# nano /etc/sysctl.d/99-swappiness.conf
  • And then enter this line:
vm.swappiness=10

Check the status of the Swap file:

# swapon --show

12. Localization

Set the localization:

# ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime
  • If you don’t know the Country/Region, substitute ln -sf with ls and then find what you need
# ls /usr/share/zoneinfo/

Set the hardware clock:

# hwclock --systohc
  • Check the time:
# date

Edit the /etc/locale.gen file and uncomment en_US.UTF-8 UTF-8 line (Or any other line as required) and save the file:

# nano /etc/locale.gen

Generate the locales:

# locale-gen

Add the locale to the /etc file:

# echo LANG=en_US.UTF-8 > /etc/locale.conf
  • If you have set the keyboard layout, make the changes persistent in /etc/vconsole.conf. For example, UK will be KEYMAP=uk. By default, it is KEYMAP=us for US
  • Check the file:
# cat /etc/locale.conf

13. Hostname

Create a hostname:

# echo arch > /etc/hostname
  • Here, arch is the hostname

Edit the hosts file:

# nano /etc/hosts
  • Go to the last line and enter the following:
127.0.0.1   localhost::1         localhost127.0.1.1   arch.localdomain     arch
  • Use tab here after every block

If the system has a permanent address, it will be replaced with 127.0.1.1

14. Initramfs (Optional)

You can create a new Initramfs file in case of LVM, system encryption or RAID

# mkinitcpio -p linux

15. Root Password

Change the root password

# passwd

Now enter a new password

16. GRUB

For BIOS (CSM) systems, run the following commands:

# pacman -S grub os-prober# grub-install /dev/sda

For UEFI systems, the commands are given below:

# pacman -S grub efibootmgr os-prober

Make a boot directory:

# mkdir -p /boot/efi
  • Mount the EFI partition to the boot directory:
# mount /dev/sda1 /boot/efi

Check the mount points:

# lsblk

Install GRUB:

# grub-install --target=x86_64-efi --bootloader-id=GRUB --efi-directory=/boot/efi

Generate the GRUB configuration file. This is common for both BIOS (CSM) and UEFI systems:

# grub-mkconfig -o /boot/grub/grub.cfg

17. Install Packages (Optional)

Here are some recommended packages that you can install at this point:

# pacman -S alsa-plugins alsa-tools alsa-utils bash-completion bind bluez bluez-utils dialog dhcpcd dnsmasq dosfstools exfat-utils git gvfs gvfs-afc gvfs-smb gvfs-mtp htop linux-headers lsb-release man-db man-pages mesa mlocate mtools networkmanager network-manager-applet ntfs-3g openssh p7zip pacman-contrib pavucontrol pulseaudio pulseaudio-alsa pulseaudio-bluetooth pulseaudio-equalizer-ladspa smartmontools terminus-font usbmuxd usbutils unrar unzip wget wireless_tools wpa_supplicant xdg-user-dirs xdg-utils reflector vim xarchiver zip

Install either one of the two microcode (AMD or Intel) depending on your processor:

# pacman -S intel-ucodeor# pacman -S amd-ucode

18. Enable Services (Optional)

Enable essential services:

Enable Internet:

# systemctl enable NetworkManager

Enable dhcpcd:

# systemctl enable dhcpcd

Enable Bluetooth:

# systemctl enable bluetooth

19. New User

Add a new user to the system:

# useradd -m -g users -G wheel,power,input,storage,network johndoe
  • Here johndoe is the new user

Give the new user sudo privileges:

# EDITOR=nano visudo

Uncomment the below line:

%wheel ALL=(ALL) ALL

Change the password for the new user:

# passwd johndoe

20. Reboot

Exit and reboot the system:

# exit

Unmount the partition:

# umount -R /mnt
  • If the target is busy, use this command:
# umount -l /mnt

Reboot:

# reboot

21. Check Network Status Again

Run this command to see if your system has an IP address:

# ip a

If on a wireless network:

# nmtui

22. Graphics Drivers

Install your corresponding graphics drivers. Please refer to this Arch Linux Wiki article for more information.

Intel:

# sudo pacman -S xf86-video-intel

AMD:

# sudo pacman -S xf86-video-amdgpu

NVIDIA:

# sudo pacman -S nvidia nvidia-utils nvidia-settings

ATI:

# sudo pacman -S xf86-video-ati

23. Install Paru (Optional)

To install Paru (AUR), run these commands:

# git clone https://aur.archlinux.org/paru.git# cd paru# makepkg -si

24. SSD TRIM (Optional)

If you are using SSDs, it is recommended to use TRIM for better performance:

# sudo systemctl enable fstrim.timer

You can install a Desktop Enviornment (GNOME, XFCE, KDE, etc.) or a Tiling Window Manager (DWM, AwesomeWM, i3, Qtile, etc.) now along with applications like a web browser, a terminal emulator, a text editor and a file manager. You can also install a Display Manager for logging in. You can follow this Arch Linux Wiki page for an extensive list of applications to install.

You can also follow the General Recommendations Wiki page for further reading on what to do after the installation.

If you are interested in maintaining the Arch Linux system, this is a great read on the Arch Linux Wiki.

Notes:

For anyone who uses WiFi, netctl (and therefore wifi-menu) was removed from the Arch Linux ISO starting July, 2020. To connect to WiFi while installing Arch Linux, please use iwctl.

Make sure that your wireless connection is not being blocked (either by a physical button/switch or by the ISO). If it’s blocked, either use that physical switch, or use rfkill unblock wifi. Then, type in iwctl. When you’re in iwctl, use device list to see the name that the WiFi router is using. For commands after this, replace device with the name of the device as found using the device list command. If you want to get the name of the network you want to use, use station device scan and then station device get-networks. After that, type in station device connect SSID*, with the *SSID being the name of the internet connection you want to use. If there is a password, type that in. After that, press Ctrl+C to get back to the terminal.

--

--

ALB

A blog on Arch Linux and some other things. But mainly Arch Linux