The Straightforward guide for installing Arch Linux (2023) — Part 1, installing the base system

Parsa Torbati
7 min readApr 26, 2020

--

The reason I’m writing this is that one of my friends wanted to install Arch Linux, and he couldn't find an up to date article, so here we go.

Before Installation

First, you should get an Arch Linux installation ISO from here. Since the ISO could be modified by third-parties to be malicious, it’s a common practice to verify the signature to check if it’s a legitimate image. To do that, first download the PGP signature (it’s in the same place as the ISO) and run the following command in a linux terminal:

gpg --keyserver-options auto-key-retrieve --verify <filename.iso.sig>

Then you are going to create a live USB or an optical disc to boot the installation.

Creating a live USB

macOS / Linux

Replace infile with path to the ISO file and outfile with path to the output device (not partition) for example, /dev/sdb. Make sure your drive is not mounted.

dd if=infile of=outfile status=progress oflag=sync bs=4M

Windows

Use Rufus.

Creating a live CD / DVD

Use a CD / DVD burning program to burn the ISO to your disc.

Booting your installation media and installing Arch Linux

For instructions on how to boot from external media, refer to your motherboard / laptop manufacturer.

Once you have booted the media, the following screen shows up. Press Enter to boot to Arch Linux.

Bootloader Menu
Bootloader Menu

Change keyboard layout (only for non-US keyboards)

If your keyboard layout is other than US, you can change the keyboard layout as follows:

To list available layouts:

ls /usr/share/kbd/keymaps/**/*.map.gz

To change keyboard layout (to de-latin1 for example)

loadkeys de-latin1

Check if system is booted in EFI or BIOS

Run the following command to check if EFI is enabled, and remember this, it will be needed:

ls /sys/firmware/efi/efivars

If EFI is disabled, the output looks like this:

Example Output with EFI disabled
Example output with EFI disabled

And with EFI enabled:

Example output with EFI enabled
Example output with EFI enabled

Connect to the internet

If you use a wired connection, skip to Verifying your internet connection.

For connecting to a Wi-Fi network, run the following command:

iwctl

First, if you do not know your wireless device name, list all Wi-Fi devices:

[iwd]# device list

Then, to scan for networks:

[iwd]# station device scan

You can then list all available networks:

[iwd]# station device get-networks

Finally, to connect to a network:

[iwd]# station device connect SSID

To verify your internet connection run this:

ping -c 4 archlinux.org
ping

Update system clock

Run the following command to update the system clock with NTP (the command has no output):

timedatectl set-ntp true

Partitioning

We are going to use fdisk for partitioning, but you may use any other program that you want.

First of all, If you create a new partition table, you will lose any data on your disk.

If you are going to install on UEFI, you must have a GPT partition table and if you have a GPT partition table I recommend installing with UEFI.

And If you are going to install on BIOS you must have a MBR partition table and with an MBR partition table you must install on BIOS.

First, open fdisk:

fdisk /dev/sda

BIOS is considered legacy now and I recommend installing on UEFI.

If you are going to create a new partition table (ALL data will be lost, although there are some ways to change your partition table without losing data, I am not covering them here, you can search online for it)

Enter o in the fdisk prompt if you want to create a MBR table, or g for a GPT partition table.

For EFI, you must create an EFI System Partition (also referred to as ESP). A size of 512MB is recommended. Press n to create a new primary partition, go with the default values for partition number and first sector , and enter +512M in last sectorprompt to make it 512 megabytes. After that, you must change the partition type. In order to do that, press t to change the type, and enter 1 for partition type (it is the code for EFI System type).

For the other two partitions, I recommend having half of your space for / and the other half for /home , but you can go with whatever you think is good. Having a third for / , another third for /home and the remaining third for a data partition is also a good idea. If your disk is larger than 512GB, having at most 200GB for / is more than enough.

Press n for each new partition, leave partition number and first sector the same as defaults, and in last sector write +xG where x is your desired size (for example for a 100GB drive write +100G )

Finally, write w to save your changes and exit fdisk .

The rest of this article assumes that you have ESP on /dev/sda1 , / on /dev/sda2 , and /home on /dev/sda3. A swap file will be created in / in the next part of this article.

Formatting the partitions

Run these commands to format your partitions:

To format the ESP:

mkfs.fat -F32 /dev/sda1

To format / and /home :

mkfs.ext4 /dev/sda2
mkfs.ext4 /dev/sda3

Mounting the partitions

First, mount /dev/sda2 as /mnt :

mount /dev/sda2 /mnt

Then create the mount points for /dev/sda1 and /dev/sda3 and mount them:

mkdir /mnt/efi
mkdir /mnt/home
mount /dev/sda1 /mnt/efi
mount /dev/sda3 /mnt/home

Installing base system

First, update the keyring so you won’t get into errors:

pacman -Sy
pacman -S archlinux-keyring

You can choose the package groups by your needs, but this is a generic selection of groups:

  • base, well, is the base system (mandatory)
  • base-devel, for utilities like make and gcc (highly recommended)
  • linux and linux-firmware for the linux kernel (mandatory unless if you want to use another kernel)
  • wpa_supplicant, wireless_tools for wireless networks (mandatory for connecting to Wi-Fi networks)
  • dhcpcd for obtaining DHCP leases (highly recommended)
  • wget for downloading files via the command line (optional)
  • vim for editing files (optional)
  • sudo (highly recommended)
  • NTP for managing system time automatically (highly recommended)
  • man-db, man-pages for manual pages (highly recommended)

There are also plenty of other package groups that you can browse here.

pacstrap /mnt base linux linux-firmware base-devel dhcpcd wpa_supplicant wireless_tools wget vim sudo ntp man-db man-pages

Also you can omit the optional / highly recommended package groups and install them after installation with pacman .

At this point, Arch Linux is installed, but it is NOT bootable yet, so do not reboot and proceed to the next section.

Configuration

Generate fstab file (it’s job is to tell the kernel what partitions should be mounted and where)

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

Change root to the newly-installed system

arch-chroot /mnt

Set the timezone

List available timezones:

ls /usr/share/zoneinfo/*/*

Set timezone (replace region and city with your own):

ln -sf /usr/share/zoneinfo/region/city /etc/localtime

Set the hardware clock from system clock:

hwclock --systohc

Localization

Uncomment or append your needed locales and en_US.UTF-8 in /etc/locale.gen with your editor of choice. Then generate locales with

locale-gen

Then set the LANG environment variable to the one of your choice in /etc/locale.conf

example locale.conf

If you have changed the keyboard layout, make your changes persistent by adding KEYMAP=de-latin1 (example for de-latin1 layout) to /etc/vconsole.conf .

Set hostname and configure the loopback address

Create /etc/hostname and put your desired hostname in it (archlinux in my case):

example of /etc/hostname

And configure the /etc/hosts file (the first two lines should be added as is, modify the third line with your hostname)

Note that you can use any number of any whitespace character (I used one tab for the first line and two for the second line to make it look good)

example of /etc/hosts

Make initramfs

mkinitcpio -P

Set root password

Set a strong password for the root account

passwd

Installing the GRUB Bootloader

First, install grub, os-prober and efibootmgr (Only for EFI systems) with pacman :

pacman -S grub os-prober             # for BIOS
pacman -S grub os-prober efibootmgr # for UEFI

Installing GRUB on EFI+GPT disks

Assumed that the ESP is mounted in /efi :

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

Installing GRUB on BIOS+MBR disks

grub-install --target=i386-pc /dev/sda

Generating the configuration file for GRUB

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

Intalling wifi-menu for easier Wi-Fi connection

pacman -S dialog netctl

Exiting chroot and rebooting into the installed system

Exit chroot

exit

Unmount the filesystems

umount -R /mnt/efi
umount -R /mnt/home
umount -R /mnt

Reboot and remove the installation media:

reboot

At this point, you have a bare Arch Linux installation. For installing extra things (including a GUI) see the next part.

References

ArchWiki

--

--