User:Zodigram/Installation Guide for Beginners

From ArchWiki

This document is intended as an alternative and more beginner-accessible guide for installing Arch Linux. It differs in that it seeks to explain terminology and commands to a new user, and avoids a lot of the customization offered by the primary guide in favor of a more directed experience. Notably, it does not cover LVM, system encryption, or RAID. The installation medium provides accessibility features which are described on the page Install Arch Linux with accessibility options. For alternative means of installation, including the primary guide, see Category:Installation process.

Arch Linux should run on any x86_64-compatible machine with a minimum of 512 MiB RAM, though more memory is needed to boot the live system for installation.[1] A basic installation should take less than 2 GiB of disk space. This guide assumes a working internet connection is available for retrieving packages.

Entry Level Terminology and Terminal Commands

Live system or live environment
An instance of an operating system that can be booted from a USB flash drive or optical disk, and runs from your RAM.
Installation medium
The device you're using to boot the live environment. For the purpose of this guide, a USB flash drive.
x86_64
Also known as x64, x86-64, AMD64, and Intel 64, x86_64 is a popular processor microarchitecture, and the only one officially supported by Arch Linux. Make sure that you are not running an ARM or 32-bit processor.
$ cd /absolute/path/to/directory
$ cd relative/path/to/directory

cd (short for "change directory") is how you move between folders (also known as directories) in a terminal.

There are two ways to represent paths. An absolute path is the sequence of all the directories leading up to your target one. These all begin with "/", which is the name of the root directory at the beginning of the entire filesystem. However, in cases where your current directory is along the absolute path of your target directory, you can use a relative path, which starts with the name of the next directory in the path after your current one.

Note: If a command line features a word written in italics, that means it's a pseudo-variable that must be changed by the user when running the command.
$ ls
$ ls path/to/directory

ls (short for "list") by default prints the names of all directories and files in your current directory. However, if you pass it the path to a different directory, it will then print the contents of that directory instead.

$ cat path/to/file
$ cat path/to/file1 path/to/file2

cat (short for "concatenate") concatenates each file passed to it in order, and prints their contents.

$ cp path/to/source_file path/to/target_file
$ cp path/to/source_file path/to/target_directory

cp (short for "copy") can be used to either create a new file or overwrite an existing file with the same contents as the source. If you have no interest in changing the name of the new file, you can simply pass the directory you would like it to be placed in.

$ mv path/to/source_file path/to/target_file
$ mv path/to/source_file path/to/target_directory

mv (short for "move") can be used to move a file elsewhere. If you have no interest in changing the name of the file, you can simply pass the directory you would like it to be placed in. Alternatively, you may also use this command to rename the file and leave it in the same directory.

$ mkdir path/to/directory
$ mkdir -p path/to/directory

mkdir (short for "make directory") is used for creating new directories. Passing -p tells mkdir to create any directories in the middle of the path you provided which don't already exist.

$ nano file

nano is a tool for editing the contents of an existing file, or otherwise creating a new one. It lists certain common keyboard shortcuts on the bottom while editing. Most relevant for this installation are Ctrl+s to save and Ctrl+x to exit.

Pre-installation

Acquire an installation image

Visit the Download page and download the ISO file and the ISO PGP signature.

Verify signature

It is recommended to verify the image signature before use, especially when downloading from an HTTP mirror, where downloads are generally prone to be intercepted to serve malicious images.

On a system with GnuPG installed, do this by downloading the ISO PGP signature (under Checksums in the page Download) to the same folder as the ISO file, and verifying it with:

$ gpg --keyserver-options auto-key-retrieve --verify archlinux-version-x86_64.iso.sig

Look for the line Good signature from "Name <name@archlinux.org>", and make sure the primary key fingerprint is the same as the one listed for the Arch Linux developer Name at [2].

If you downloaded archlinux-version-x86_64.iso from an HTTP mirror, also download b2sums.txt and move it to the same folder. Then run:

$ b2sum -c b2sums.txt

If you see archlinux-version-x86_64.iso: OK in the first line, your image was downloaded correctly. Otherwise, download a new ISO until you have one that provides that output.

Prepare an installation medium

While it is possible to boot the live system from an optical disk as well, this guide will focus on booting from a USB flash drive.

Once you've connected one to your system, run the command:

$ lsblk

Look for the entries whose TYPE is listed as disk, and use the available information to deduce which label in NAME refers to your USB flash drive.

Then run:

# cp path/to/archlinux-version-x86_64.iso /dev/sdX

Make sure not to add a partition number after sdX such as sdX1, and to simply use sdX.

Warning: Be aware that this will erase all existing data on your USB flash drive. You may want to use an empty USB flash drive or move your files elsewhere first.

Partition the disks

When recognized by a live environment, disks are assigned to a block device such as /dev/sda, /dev/nvme0n1 or /dev/mmcblk0. To identify these devices, use the commands:

# lsblk

or

# fdisk -l

Results ending in rom, loop or airoot may be ignored.

Block devices are divided into sections called partitions, where different filesystems can be installed. As in the section on preparing the USB flash drive, you can use these partitions and their sizes to deduce which disk you want to install Arch Linux onto. However, we must also make sure we have the appropriate partitions for an installation to take place.

At minimum, a system in BIOS mode will require:

At minimum, a system in UEFI will require:

  • One partition for the root directory /.
  • An additional EFI partition with which to boot the operating system

However, modifying partitions can be messy, especially for an inexperienced user, so this specific guide will avoid explaining how to do so with a command line. Instead, it will recommend that you handle partitioning using a live environment belonging to a popular distribution such as Ubuntu, Linux Mint, or EndeavourOS, which come with a graphical application for modifying partitions called GParted.

Warning: Before you do anything, you should back up any files you care about from the disk you plan to partition, as partitioning can cause data loss.

Once in GParted, select your disk and analyze your existing partition table.

First, we must make sure there will be a partition for the root filesystem.

  • If there is an existing partition you want to erase and overwrite, no step is necessary at this time.
  • If you would like to install Arch Linux in a new partition and there is an insufficient amount of space that is listed as unallocated:
    • Shrink an existing partition in order to create space for your Arch installation. To shrink a partition, right-click on it, select Resize/Move, enter your desired value into Free space following (MiB), press Enter, and select Resize/Move.
    • Once you have created an unallocated area of sufficient size for your root filesystem, right-click on it, select New, set your desired partition size in New size (MiB), set File System to ext4, write arch in the section Label, and then press Add.
Note:
  • You may also clear up space by using the Free space preceding (MiB) field, although this should only be done if there is nothing on the partition.
  • If you have trouble thinking in MiB, you can compute your desired value by thinking in GiB and multiplying that value by 1024.

On the top bar of GParted, select View > Device Information. In the new box that appears on the left, read whether the section titled "Partition table" is followed by "mbr" or "gpt". If its the latter and you see an EFI partition with at least 300MiB of space, no step is necessary at this time. However, if there is no EFI partition with filesystem fat32 of at least 300MiB, create a new one. Once this is done, right-click on the new EFI partition, select Manage flags, and then make sure to mark the checks next to boot and esp.

Note:

If the disk does not show up, make sure the disk controller is not in RAID mode.

Boot the live environment

  1. If your computer has secure boot enabled, you must disable it for the duration of the installation. To enter your BIOS and do so, you must find the specific method implemented by your manufacturer. Generally, there is some key you must press or hold while your computer is in its initial boot process, which is often along the lines of Esc, F2, Del, or a different Fn key.
  2. Different computers will support different ways of booting from an installation medium, so to be sure, you should check which method your computer manufacturer has implemented. Sometimes a computer may be set to boot from an installation medium by default, but generally, there is a key one must press during the computer's initial boot process to bring up a menu of potential sources to boot from.
  3. When the installation medium's boot loader menu appears, select Arch Linux install medium and press Enter to enter the installation environment.
  4. You will be logged in on a full-screen terminal as the root user, who has superuser permissions.

The terminal you see when you first boot into the live environment is actually called tty1, and there are additional ones you can use labelled tty2 to tty6 that can be switched between using the Alt + Right Arrow and Alt+Left Arrow keyboard shortcuts. To begin using them, simply provide the user root when asked for an archiso login. This can be very useful for troubleshooting issues when you don't have a second device available, since there is a browser you can use in an Arch live environment terminal after setting up an internet connection called Lynx, which can be accessed with the command:

# lynx url

You can navigate around Lynx with the Arrow and Template:Enter keys, and it may ask you to press different keys to choose between different answers when it gives you a prompt.

Set the console keyboard layout

By default, the Arch live system assumes you are using an American keyboard layout. If you are using a different keyboard layout, the list of available layouts can be listed with:

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

To set the keyboard layout you prefer, pass it to the command loadkeys. It's not necessary to write out the layout's path or file extension. For example, to set a German or Spanish keyboard layout, one might use:

# loadkeys de-latin1

or

# loadkeys es

Verify the boot mode

Computers can boot an operating system in either an older mode called BIOS, or a newer mode called UEFI. To check which one your computer uses, we can see if you have a directory only present on UEFI systems.

To verify the boot mode, run:

# 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 is booted in BIOS mode.

Connect to the internet

To set up a network connection in the live environment, go through the following steps:

  • Find your network device with the command ip-link(8):
    # ip link
    • If you're trying to use a wired connection, your device likely starts with en (short for ethernet).
    • If you're trying to use a Wi-Fi connection, your device likely starts with wlan (short for wireless LAN).
  • For wireless, make sure the card is not blocked with rfkill.
  • Connect to the network:
    • Ethernet or Android USB tethering—plug in the cable.
    • Wi-Fi—authenticate to the wireless network using iwctl. Run:
      # iwctl station device scan
      # iwctl station device get-networks
      # iwctl station device connect NetworkSSID
  • The connection may be verified with ping:
    # ping archlinux.org
    • The shortcut Ctrl+c can be used to exit this check.

Update the system clock

In the live environment, a system function is enabled by default and time will be synced automatically once a connection to the internet is established.

Use timedatectl(1) to ensure the system clock is accurate and in sync with UTC time:

# timedatectl status

Format the partitions

Although there are several different filesystems supported by Arch Linux, this guide will use the popular Ext4 file system. Identify the partition you would like to install the root filesystem on and format it with:

# mkfs.ext4 /dev/root_partition

We will also label it with the name "arch" by doing:

# e2label /dev/root_partition arch

If you created a new EFI system partition, format it to FAT32 using:

# mkfs.fat -F 32 /dev/efi_system_partition
Warning: Only format the EFI system partition if you created it during the partitioning step. If there already was an EFI system partition on disk beforehand, reformatting it can destroy the boot loaders of other installed operating systems.

Mount the file systems

Mounting refers to temporarily making another partition's contents accessible at a given directory.

Mount the root partition to /mnt using:

# mount /dev/root_partition /mnt

For UEFI systems, create a mount point for the EFI system partition at /mnt/boot, and then mount there:

# mkdir /mnt/boot 
# mount /dev/efi_system_partition /mnt/boot

Installation

Select the mirrors

Packages to be installed must be downloaded from mirror servers, which are defined in /etc/pacman.d/mirrorlist. In the live environment, after connecting to the internet, a program called reflector updates the mirror list by choosing 20 most recently synchronized HTTPS mirrors and sorting them by download rate.

The higher a mirror is placed in the list, the more priority it is given when downloading a package. You may want to inspect the file to see if it is satisfactory. If it is not, edit the file accordingly, and move the geographically closest mirrors to the top of the list, although other criteria should be taken into account.

This file will later be copied to the new system by pacstrap, so it is worth getting right.

Install essential packages

The most basic install involves using the pacstrap(8) script to install the base package, Linux kernel and firmware for common hardware to the root file-system:

# pacstrap -K /mnt base linux linux-firmware
Tip:
  • You could omit the installation of the firmware package when installing in a virtual machine or container.

However, there are many other packages that this guide will recommend installing at this time.

Any of these packages or package groups can simply be added to the end of the pacstrap command, separated by spaces.

For example:

# pacstrap -K /mnt base linux linux-firmware firefox gnome intel-ucode networkmanager

Configure the system

Fstab

An fstab file stands for file system table, and is used by your system to know what partitions to mount at startup.

Generate one by using:

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

Check the resulting /mnt/etc/fstab file with:

# cat /mnt/etc/fstab

If you notice any errors, correct them with:

# nano /mnt/etc/fstab

Note: The argument -U tells fstab to identify partitions according to something called UUID. If you've labelled your partitions in GParted, -L can be used to identify partitions according to their labels instead.

Chroot

Move into the root filesystem of the the new system:

# arch-chroot /mnt

Installing additional packages

If at any point you would like to install additional packages not previously installed through pacstrap, simply install them with pacman like so:

# pacman -S package1 package2 etc

Time zone

To see available timezones for your new system, run:

# timedatectl list-timezones

You can move down this list by holding the Enter key, and quitting with the q key once you've found your desired one. Then, set the timezone with:

# ln -sf /usr/share/zoneinfo/Region/City /etc/localtime

Run hwclock(8) to generate /etc/adjtime:

# hwclock --systohc

This command assumes the hardware clock is set to UTC. See System time#Time standard for details.

Localization

Set your desired locale by running:

# nano /etc/locale.gen 

and uncommenting en_US.UTF-8 UTF-8 and other needed locales.

Generate the locales by running:

# locale-gen

Then edit /etc/locale.conf and create a LANG variable set to your desired locale like so:

/etc/locale.conf
LANG=en_US.UTF-8

If you set the console keyboard layout, make the changes persistent by editing /etc/vconsole.conf as well. For example:

/etc/vconsole.conf
KEYMAP=de-latin1

Network configuration

Create the hostname file:

/etc/hostname
myhostname

myhostname is just whatever name you want to use to uniquely label this computer on a network. You may want to simply write the model of your machine.

Root password

Set the password for the root user:

# passwd
Note:

Although there will be no visual indication when you type a new character, this is by design in order to ensure security. Each character is still being written, and when you're done with the password, press enter.

Creating a user

Create a new user by running:

# useradd -m username
Note: The argument -m tells the system to create a home folder for your user.

Give them a password by running:

# passwd username

If you've installed sudo, give them the ability to access superuser privileges with:

# usermod -aG wheel username
Note:
  • if you didn't install sudo in the pacstrap stage, you can do so now with pacman.
  • The argument -aG tells usermod to add you to a group without removing you from any other groups.
  • The wheel group refers to an old phrase "Big wheel", which was used in the past to refer to an important person.

Boot loader

Choose and install a Linux-capable boot loader.

For BIOS systems

Install the grub package. Then do:

# grub-install --target=i386-pc /dev/sdX

where i386-pc is deliberately used regardless of your actual architecture, and /dev/sdX is the disk (not a partition) where GRUB is to be installed. For example /dev/sda or /dev/nvme0n1, or /dev/mmcblk0. See Device file#Block device names for a description of the block device naming scheme.

If you want to be able to boot other operating systems as well, edit /etc/default/grub and add or uncomment the line:

GRUB_DISABLE_OS_PROBER=false

Now you must generate the main configuration file using:

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

For UEFI systems

Using Systemd-boot (Recommended)

Run the command:

# bootctl install

Then run the command

 # nano /boot/loader/loader.conf

and make it look like:

/boot/loader/loader.conf
default arch.conf
timeout 3

Then create the following files:

/boot/loader/entries/arch.conf
title   Arch
linux   /vmlinuz-linux
initrd  /initramfs-linux.img
options root="LABEL=arch" rw
/boot/loader/entries/arch-fallback.conf
title   Arch (Fallback)
linux   /vmlinuz-linux
initrd  /initramfs-linux-fallback.img
options root="LABEL=arch" rw

If you've also installed the linux-lts kernel as well, create the following files as well:

/boot/loader/entries/arch-lts.conf
title   Arch (LTS)
linux   /vmlinuz-linux-lts
initrd  /initramfs-linux.img
options root="LABEL=arch" rw
/boot/loader/entries/arch-fallback.conf
title   Arch (LTS Fallback)
linux   /vmlinuz-linux-lts
initrd  /initramfs-linux-lts-fallback.img
options root="LABEL=arch" rw
  • If you have an Intel CPU, add the line initrd /intel-ucode.img after the lines linux /vmlinuz-linux and linux /vmlinuz-linux-lts.
  • If you have an AMD CPU, add the line initrd /amd-ucode.img after the lines linux /vmlinuz-linux and linux /vmlinuz-linux-lts.

An example might look like:

/boot/loader/entries/arch-fallback.conf
title   Arch (LTS Fallback)
linux   /vmlinuz-linux-lts
initrd  /amd-ucode.img
initrd  /initramfs-linux-lts-fallback.img
options root="LABEL=arch" rw
Using Grub

Install the grub and efibootmgr packages. Then do:

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

/dev/sdX is the disk (not a partition) where GRUB is to be installed. For example /dev/sda or /dev/nvme0n1, or /dev/mmcblk0. See Device file#Block device names for a description of the block device naming scheme.

If you want to be able to boot other operating systems as well, edit /etc/default/grub and add or uncomment the line:

GRUB_DISABLE_OS_PROBER=false

Now you must generate the main configuration file using:

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

Install the refind and efibootmgr packages, then run:

# refind-install

Setting up systemd services

To be able to boot to a graphical login screen:

  • If you've installed the gnome desktop environment, run
     # systemctl enable gdm.service
  • If you've installed the plasma desktop environment, run
     # systemctl enable sddm.service
  • If you've installed the xfce4 desktop environment, run
     # systemctl enable lightdm.service
Note: Any of these graphical login screens can work with any of these desktop environments, but these are the ones recommended for each.

If you would like to have bluetooth enabled on boot, install the bluez package and run

 # systemctl enable bluetooth.service

If you would like to have networking enabled on boot, install the networkmanager package and run

 systemctl enable NetworkManager.service

If you installed systemd-boot, make sure that it's regularly updated every time you restart by running

 systemctl enable systemd-boot-update.service

Changing pacman configuration

Edit the file /etc/pacman.conf, move to the section titled # Misc options and set the following two lines:

ILoveCandy
ParallelDownloads = 5

Adding a swapfile

Swap space is a section of your hard drive that can be used as "Virtual memory", which can be helpful when you have a limited amount of RAM. There is no one size that swap space must be, or even a requirement that your system have it at all.

This guide will add a general set of instructions, without a specific amount to create.

# dd if=/dev/zero of=/swapfile bs=1G count=desired_amount_of_GB status=progress
# chmod 0600 /swapfile
# mkswap -U clear /swapfile
# swapon /swapfile

Finally, add the following line to your /etc/fstab to account for the new swapfile:

/etc/fstab
/swapfile none swap defaults 0 0

To remove a swapfile, simply remove it from /etc/fstab and run:

# swapoff /swapfile
# rm -f /swapfile

Reboot

Exit the chroot environment by typing exit or pressing Ctrl+d.

Optionally manually unmount all the partitions with umount -R /mnt: this allows noticing any "busy" partitions, and finding the cause with fuser(1).

Finally, restart the machine by typing reboot: any partitions still mounted will be automatically unmounted by systemd. Remember to remove the installation medium and then login into the new system with the root account.

Post-installation

System Maintanence

Installing, removing, and updating packages

You can install package(s) with:

# pacman -S package
# pacman -S package1 package2

Remove packages with :

# pacman -Rs package
# pacman -Rs package1 package2

Update with:

# pacman -Syu

.pacsave and .pacnew files

  • .pacsave files are created when the system stores configuration files of uninstalled packages
  • .pacnew files are created when the system recognizes that an updated package has an updated configuration file. However, the system does not want to overwrite your current configuration file, and leaves it up to you to merge the differences accordingly

To deal with these, install the meld and periodically run:

# DIFFPROG=meld pacdiff 

Updating Mirrors

As mirrors change, you can update the best mirrors for your system with the package reflector

If you'd like to have the 5 fastest mirrors from your country, run:

# reflector --protocol https --sort rate --fastest 5 --country Country  --save /etc/pacman.d/mirrorlist 

Exploring Applications

For a list of applications that may be of interest, see List of applications.