User:NSIMMONDS

From ArchWiki

Unofficial Arch Linux Installation Guide

Warning: If you managed to find this, well done. I wrote this for myself so I never forget any steps. You are more than welcome to follow this guide but please adjust the steps to better suit your system

This is an unofficial Arch Linux installation guide written by myself.

This guides aim is to make it as easy as possible for some who has never used a GNU/Linux system to install Arch Linux.

nano should be used to edit text files, however vim is also available.

Text in italics means you should replace the text with something appropriate to your install.

Prerequisites (Pre-boot)

Note: Regardless of the installation you will be attempting these steps need to be followed.

Download Arch Linux.

Verify the ISO

Note: These next steps require either a system with GnuPG installed or an Arch Linux derivative.

Download the PGP signature, cd to the directory where both the ISO image is saved and the .sig file is saved, and then verify the ISO.

Example:

$ cd ~/Downloads
$ gpg --keyserver pgp.mit.edu --keyserver-options auto-key-retrieve --verify archlinux-version-x86_64.iso.sig

The following command can be used if using an Arch Linux derivative:

$ pacman-key -v archlinux-version-x86_64.iso.sig

Copy ISO to a USB

You can use the tool dd to copy the ISO to the USB via the command line, alternatively you could use Etcher if you like a GUI.

Below is an example of how you can use dd to copy the ISO to a USB.

# dd if=archlinux-version-x86_64.iso of=/dev/sdX status=progress

Once the ISO is copied to the USB boot to it.

Prerequisites (Live USB)

Note: Use Shift+PageUp and Shift+PageDown to scroll in the TTY.

Keyboard layout

If you need a keyboard layout that isn't standard QWERTY US English then use the command below to list possible keymaps.

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

Set the keymap.

# loadkeys uk

Verifying boot mode

# ls /sys/firmware/efi/efivars
Warning: If nothing is listed here, you are NOT in EFI mode.

Connecting to the internet

Wi-Fi

If using Wi-Fi use the command below.

# wifi-menu

Ethernet

If you are on a wired connection you should connect to the network automatically, if you don't use the command below.

# dhcpcd

Verifying connection

# ping archlinux.org

Changing mirrors

On another device visit the link below and generate mirrors for your country.

https://www.archlinux.org/mirrorlist/

Once you have generated mirrors edit /etc/pacman.d/mirrorlist with the new mirrors.

Sync the newly added mirrors.

# pacman -Syyy

Syncing the clock

Use the command below which will use systemd's Network Time Protocol service to sync the clock with a server.

# timedatectl set-ntp true

Verify the clock synced.

# timedatectl status

Standard UEFI Install

Partition the disk

Warning: The first thing to do is to list the disks in your system. This guide will be using /dev/sdX. Please make sure you are targeting the correct drive as loss of data will occur.

Use the command below to list the disks in your system.

# fdisk -l

Target the disk you will be using for installation.

# fdisk /dev/sdX

EFI partition

Use g to create a GUID partition table as opposed to a Master boot record.

Use n to create a new partition.

Skip the partition number with ENTER.

Skip the first sector resizing with ENTER.

Next make the size of the partition 512MB big with +512M. This will be used for UEFI.

Use t to change the type of the partition.

It will automatically select the partition as it is the only partition on the disk.

Use 1 to set the partition to EFI.

Root partition

Now create the root partition where Arch Linux will be installed with n.

Keep this partition as number 2 with ENTER.

Skip the first sector resizing .

Skip second sector resizing with ENTER, so the rest of the disk is used.

Finally write all these changes to the disk with w.

Note: You should check the partition layout with p before writing the changes.

Example layout

Your drive should look like something below.

Mount point Partition Type Size
/mnt/boot /dev/sdX1 EFI (FAT32) 512M
/mnt /dev/sdX2 Linux FS (ext4) 7.5G

Format partitions

Format the EFI partition to FAT32.

# mkfs.fat -F32 /dev/sdX1

Format root partition to ext4.

# mkfs.ext4 /dev/sdX2

Mount partitions

Next mount the partitions.

# mount /dev/sdX2 /mnt

Make a directory before mounting the boot partition otherwise it will fail.

# mkdir /mtn/boot

Now mount the boot partition.

# mount /dev/sdX1 /mnt/boot

Install the base system

Next install the base system along with base-devel and the linux-headers package.

Note: You can add more packages here if you would like.
# pacstrap -i /mnt base base-devel linux linux-headers linux-firnware e2fsprogs ntfs-3g dosfstools vim zsh grml-zsh-config

Generate fstab file

Generate a fstab file so Arch Linux knows how to boot properly.

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

Chroot into the system

This will transfer you from the live USB to your new Arch Linux install.

# arch-chroot /mnt

Changing the shell

List the available shells

Use the command below to list all of the shells installed on your system.

# chsh -l

Setting the shell

Use the full path to the shell and use the command below to set the shell.

# chsh -s /usr/bin/zsh

Install packages

Note: Microcode packages should be installed for your CPU.

The Intel package is intel-ucode

The AMD package is amd-ucode

Bootloader

Tip: This guide will use GRUB as it's choice of boot loader. Take a look at this wiki page for more boot loaders.
# pacman -S grub efibootmgr freetype2 fuse2 mtools os-prober

Essentials

# pacman -S xorg man-db man-pages texinfo networkmanager

Nice to have

This section just lists nice packages to have on the system, e.g. neofetch.

# pacman -S neofetch flameshot

NAVI 10 GPU

The following packages are needed for a fully functioning system that has a NAVI 10 based GPU.

64-Bit packages from the default repositories

mesa clang libclc libdrm llvm llvm-libs opencl-mesa vulkan-mesa-layer vulkan-radeon xf86-video-amdgpu libva-mesa-driver mesa-vdpau

32-Bit packages from the default repositories

lib32-mesa lib32-clang lib32-libdrm lib32-llvm lib32-llvm-libs lib32-vulkan-radeon lib32-libva-mesa-driver lib32-mesa-vdpau

64-Bit packages from the AUR.

amdvlk

32-Bit packages from the AUR.

lib32-amdvlk

Configuring GRUB

Mount EFI partition

Create the folder below as the partition won't mount.

# mkdir /boot/EFI

Now mount the partition.

# mount /dev/sdX1 /boot/EFI

Install GRUB

Warning: The --efi-directory flag is crucial as GRUB will fail to install.
Note: The --bootloader-id flag can also be changed to your liking.
# grub-install --target=x86_64-efi --efi-directory=/boot/EFI --bootloader-id=Arch --recheck

English locale file

Copy english locale file for grub.

# cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo

Generating GRUB config file

You need to generate a config file for GRUB so the system boots.

Note: The microcode packages installed earlier will be included in this config.
# grub-mkconfig -o /boot/grub/grub.cfg

Installation Finished

Tip: It is recommended you follow the #Post-Installation guide for a more complete system.

Post-Installation

Creating a swap file

Tip: It is better to create a swap file rather than a swap partition because they are easier to manage.

This will create a file which is 4GB in size that is located in the root of your install:

# fallocate -l 4G /swapfile

Next set it so only root can manipulate the file:

# chmod 600 /swapfile

This makes the file a swap file:

# mkswap /swapfile

Finally configure fstab so the swap file is loaded on system boot:

/etc/fstab
/swapfile none swap defaults 0 0

Set the locale

Edit /etc/locale.gen and uncomment en_US.UTF-8 UTF-8 and any other needed locales e.g. en_GB.UTF-8 UTF-8

Generate the locales with:

# locale-gen

Next edit /etc/locale.conf with the locale you will use on your system:

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

Next do the same for /etc/vconsole.conf so you get the preferred keyboard layout in the TTY.

/etc/vconsole.conf
KEYMAP=uk

Set the time zone

Use the command below which will use systemd's Network Time Protocol service to sync the clock with a server:

# timedatectl set-ntp true

Verify the clock synced.

# timedatectl status

Make a link with your timezone so the clock can adjust accordingly.

# ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime

Lastly set the hardware clock from the system clock.

# hwclock --systohc

Set the hostname

Create /etc/hostname and add a desired hostname:

/etc/hostname
hostname

User / group management

Set the root password:

# passwd root

Creating a user

This will create a user and it will also create a directory for them in /home:

# useradd -m user

Set the password for the new user:

# passwd user

Creating a group

Use the following command to create a new group

# groupadd group

Adding a user to a group

The command below will allow you to add any user to a group, as long as you have permissions and the group exists.

# gpasswd -a user group

Adding user(s) to the sudo file

This step will show you how to add your newly created user to the /etc/sudoers file.

Warning: You should only use visudo on this file as it saves edits to a temporary file and helps prevent syntax errors before it is saved.

Single user

Open the /etc/sudoers file.

# visudo /etc/sudoers

Tap ESC on your keyboard and then / and start typing "User privilege specification" you should see root ALL=(ALL) ALL

Now tap ESC on your keyboard and then double tap d, after this press p twice.

This part of the file should now look like something below:

/etc/sudoers
root ALL=(ALL) ALL
root ALL=(ALL) ALL

Edit the bottom one and add the username of the user created in the last step.

Example:

/etc/sudoers
root ALL=(ALL) ALL
user ALL=(ALL) ALL

Allowing users in a group

Note: I'm using the sudo group for this example.

Open the /etc/sudoers file.

# visudo /etc/sudoers

Tap ESC on your keyboard and then / and start typing "# %" and press enter, then press n twice and it should take you to the needed line in the file. You should see %sudo ALL=(ALL) ALL

This part of the file should now look like something below:

/etc/sudoers
# %sudo ALL=(ALL) ALL

Simply remove the hash to uncomment the line.

Example:

/etc/sudoers
%sudo ALL=(ALL) ALL

Enabling multilib repositories

You will need to edit /etc/pacman.conf and uncomment the multilib section.

/etc/pacman.conf
[multilib]
Include = /etc/pacman.d/mirrorlist

AUR Helper

Warning: You cannot perform this step on the root user, use another TTY for this step and login using the account created earlier.

To install an AUR helper you first need to install git

$ sudo pacman -S git

Now clone the AUR helper of your choice.

$ git clone https://aur.archlinux.org/'{HELPER}'.git

Available helpers:

Tip: Check out the AUR Helpers wiki page for a full list of helpers.

Example git clone

$ git clone https://aur.archlinux.org/pikaur.git

Change directory to the package. From here I will use pikaurAUR as an example.

$ cd pikaur

To install the package use the following command.

$ makepkg -si

The above command will install any additional dependencies from the official repository, it will NOT install AUR dependencies. Once this is done it will then install the package.