Reference Computer Software OS Linux Distributions Arch Help Guides Installation

Arch Linux Installation Guide

for Laptop "Cera"

by Paul Moffat - 211021


Guide Notes (230304)

  • This is a web-adaption of the original guide I created in 2021 using Microsoft Word which I then printed to hardcopy for personal reference.
  • This was created to support a new installation of Arch Linux for a new laptop computer (Cera) that replaced my previous PC (Serena) after it was stolen.
  • The laptop came pre-installed with Windows 10 Home, only supported one internal storage device, so effectively this installation of Arch Linux was to replace Windows on this computer.
  • The existing drivers and installation software found within root folders on C:\ were backed up (in the event I needed to reinstall Windows 10) and then Windows 10 prepared otherwise to be discarded.
  • After having my PC stolen along with all its external hardware including all the external storage/backup devices (which were completely open & unprotected), I decided to research and utilise disk encryption within this installation of Arch Linux. This was the first time I had ever used disk encryption on any core installation of any operating system.
  • With the above in mind and after a period of research I decided to utilise LVM virtual partitions with LUKS encryption.
  • I also realised the error in my judgement with how I had decided to utilise the Swap Partition in my previous installation of Arch. Creating an oversized swap partition that wasted gigabytes of harddisk space in the guise of "future-proofing" the system was in hindsight a terrible idea on my part. Because of the various and high storage capacity of the devices in my PC it didn't really cause any immediate storage availability issues, but this laptop only had one 1TB SSD so disk space in this circumstance was a valuable resource I had to be careful with.
  • With the above in mind I decided to change my tack and start utilising a small initial 2GB swap file that could be increased in size as/if required. The fact this swap file could be resized quite easily provided the future-proofing I wanted but in a more efficient manner. I'll admit that up until this install I was a bit hesitant to use swap files as I had always used swap partitions for all my past linux installs. It is what I knew, it had worked so I was a bit resistant to the change, despite the various online recommendations I had read over the years promoting swap files. But hey, I got there in the end :)

Partitions Overview

  • Partition 1 - EFI
    Size 500 MB
    Type 1 (EFI System)
  • Partition 2 - BOOT
    Size 500 MB
    Type 136 (Linux extended boot)
  • Partition 3 - SYSTEM
    Size All Remaining Free Space
    Type 43 (Linux LVM)

Partition 3 - SYSTEM will be further partitioned into root and home sub-partitions using LVM. No swap partition will be created. A minimal 2 gig swap file will be created which can be resized as required.

Installation Instructions

BIOS

Make sure UEFI is ENABLED in the BIOS before beginning the setup/installation process!

Networking


Initialisation

Initialise DHCP Client # dhcpcd
Verify Available Network Devices # ip addr show

Configure Wifi Access using Internet Wireless Control Utility

Start IWCTL # iwctl
List Available Wireless Network Devices device list
Scan For Available Wireless Access Points station <DEVICE> scan
Get List Of Available Wireless Access Points station <DEVICE> get-networks
Connect To Available Wiress Access Point station <DEVICE> connect <SSID>
Exit IWCTL CTRL+D

Verification

Verify Wifi Interface Availability # ip addr show
Verify Internet Connection Availability # ping -c 5 8.8.8.8

Disk Configuration (UEFI with Encryption)


Create Physical Disk Partition Table

Verify Disk Device ID Intended to Install Arch onto # fdisk -l
Configure Device Partitions using fdisk # fdisk /dev/<DEVICE>
Verify Existing Partition Table p
Create New GPT Partition Table g

Create EFI Partition (500 megabytes)

New Partition n
Partition Number - Accept Default of 1 ENTER
First Sector - Accept Default ENTER
Last Sector +500M
Remove Existing Type (if asked) y
Create New Type t
Partition Number - Accept Default of 1 (if asked) ENTER
Choose Partition Type "EFI System" 1

Create BOOT Partition (500 megabytes)

New Partition n
Partition Number - Accept Default of 2 ENTER
First Sector - Accept Default ENTER
Last Sector +500M
Remove Existing Type (if asked) y
Create New Type t
Partition Number - Accept Default of 2 ENTER
Choose Partition Type "Linux extended boot" 136

Create System (LVM) Physical Partition (all remaining free space)

New Partition n
Partition Number - Accept Default of 2 ENTER
First Sector - Accept Default ENTER
Last Sector ENTER
Remove Existing Type (if asked) y
Create New Type t
Partition Number - Accept Default of 3 ENTER
Choose Partition Type "Linux LVM" 43

Finalise Physical Partition Table

Verify the Partition Table p
Write the Partition Table (save) w
Quit fdisk (if required) q
Verify Changes to Disk # fdisk -l

Format Startup Physical Partitions

Format EFI Partition # mkfs.fat -F32 /dev/<device>1
Format BOOT Partition # mkfs.ext4 /dev/<device>2

Configure LVM Partition

Encrypt LVM Physical Partition # cryptsetup luksFormat /dev/<device>3
IGNORE Warning "Warning: Locking Directory ... is missing!"
Open LVM Physical Partition # cryptsetup open --type luks /dev/<device>3 lvm
Create Physical Volume # pvcreate --dataalignment 1m /dev/mapper/lvm
Create Volume Group # vgcreate vg0 /dev/mapper/lvm
Create Root Logical Volume # lvcreate -L 50GB vg0 -n lv_root
Create Home Logical Volume # lvcreate -l 100%FREE vg0 -n lv_home
Activate LVM Kernel Module # modprobe dm_mod
Scan Volume Groups # vgscan
Activate Volume Groups # vgchange -ay

Format LVM Logical Partitions

Format ROOT Partition # mkfs.ext4 /dev/vg0/lv_root
Format HOME Partition # mkfs.ext4 /dev/vg0/lv_home

Prepare System Drive

Mount ROOT Partition # mount /dev/vg0/lv_root /mnt
Create HOME Directory # mkdir /mnt/home
Create BOOT Directory # mkdir /mnt/boot
Create ETC Directory # mkdir /mnt/etc
Mount HOME Partition # mount /dev/vg0/lv_home /mnt/home
Mount BOOT Partition # mount /dev/<device>2 /mnt/boot
Create EFI Directory # mkdir /mnt/boot/EFI
Mount EFI Partition # mount /dev/<device>1 /mnt/boot/EFI
Generate File System Table # genfstab -U -p /mnt >> /mnt/etc/fstab
Verify File System Table # cat /mnt/etc/fstab
Backup File System Table # cp /mnt/etc/fstab /mnt/etc/fstab.bak

Install Arch Linux


Install OS Foundation

Install Base Packages # pacstrap -i /mnt base
Transfer to Arch Installation # arch-chroot /mnt

Configure Package Mirrors

Install Reflector Mirror Script # pacman -Sy reflector
Set 10 Fastest NZ Mirrors # reflector --verbose --latest 10 --country 'New Zealand' --sort rate --save /etc/pacman.d/mirrorlist
Verify Mirror List # cat /etc/pacman.d/mirrorlist

Install System Packages

Install Kernel & Headers # pacman -S linux linux-lts linux-headers linux-lts-headers
Install Linux Firmware # pacman -S linux-firmware
Install CPU Firmware Microcode # pacman -S amd-ucode
Install LVM Support Package # pacman -S lvm2
Install Boot Packages # pacman -S dosfstools efibootmgr grub mtools os-prober
Install Networking Packages # pacman -S dialog netctl networkmanager openssh wireless_tools wpa_supplicant
Install SUDO (if required) # pacman -S sudo

Install Utility Packages

Install Base Development Packages # pacman -S base-devel
Install Console Text Editors # pacman -S emacs micro nano vim

Configure Arch Linux


Enable Swap File Support

Create Swap File # dd if=/dev/zero of=/swapfile bs=1M count=2048 status=progress
Change Permissions # chmod 600 /swapfile
Create Swap Space # mkswap /swapfile
Append Swapfile to FSTAB # echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab
Verify Updated FSTAB # cat /etc/fstab
Test Updated FSTAB # mount -a
Enable Swap Memory # swapon -a
Check Memory for Swap # free -m

Setup Ramdisk Environment

Edit MKINITCPIO Configuration # micro /etc/mkinitcpio.conf
Find the line that begins with "HOOKS="
Between "block" & "filesystems" add ... encrypt lvm2 ...
Generate Image for Primary Kernel # mkinitcpio -p linux
Generate Image for LTS Kernel # mkinitcpio -p linux-lts

Setup Locale Configuration

Open Locale-Gen Config # micro /etc/locale.gen
Uncomment-Out Line en_NZ.UTF-8 UTF-8
Set English Language Locale # localectl set-locale LANG="en_NZ.UTF-8"
Set US Style Keymap # echo 'KEYMAP=us' > /etc/vconsole.conf
Generate Locales # locale-gen

Setup Grub

Install Grub onto MBR # grub-install --target=x86_64-efi --bootloader-id=grub_uefi --recheck
Create Locale Folder (if missing) # mkdir /boot/grub/locale
Install English Locale Messages # cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo
Open Grub Configuration # micro /etc/default/grub
Uncomment Line GRUB_ENABLE_CRYPTODISK=y
Find Line Beginning With "GRUB_CMDLINE_LINUX_DEFAULT="
At (Above) - Make First Parameter ... cryptdevice/dev/<device>3:vg0:allow-discards
Generate Grub Configuration # grub-mkconfig -o /boot/grub/grub.cfg

Setup Networking Host

Setup Local Host Name # hostnamectl set-hostname Cera
Set Hostname File # echo 'Cera' > /etc/hostname
Verify Hostname File # cat /etc/hostname
Open Hosts File # micro /etc/hosts
Add After Comment Lines
1 127.0.0.1 localhost
2 ::1 localhost
3 127.0.1.1 Cera.localdomain Cera
Verify Hostname # hostnamectl
Enable Network Manager Service # systemctl enable NetworkManager
Enable SSH Service # systemctl enable sshd

Setup Timezone

Set System to Use NZ Timezone # timedatectl set-timezone "Pacific/Auckland"
Enable Timezone Sync Service # systemctl enable systemd-timesyncd

Setup User Accounts

Set ROOT Password (VERY IMPORTANT!) # passwd
Create Primary User Account # useradd -m -g users <username>
Configure Primary User Groups # usermod -aG wheel,audio,video,optical,storage,power <username>
Open Sudo Configuration # EDITOR=micro visudo
Uncomment Line %wheel ALL=(ALL) ALL

Install Graphical User Interface (GUI)

Install XORG Server # pacman -S xorg-server
Install X Video Drivers # pacman -S xf86-video-amdgpu
Install NVIDIA Video Drivers # pacman -S nvidia nvidia-lts
Install SDDM Login Manager # pacman -S sddm
Install KDE Plasma (Desktop Environment) # pacman -S plasma-desktop
Install Konsole (Terminal) # pacman -S konsole
Install Dolphin (File Manager) # pacman -S dolphin
Enable SDDM Service # systemctl enable sddm.service

Exit Installation

Exit CHROOT Environment # exit
Unmount EVERYTHING # umount -a
IGNORE Errors "BUSY"
Remove/Eject <Installation Media>

Start Arch Linux (New Install)

Reboot Computer # reboot
If Arch Linux Boots Successfully SHAKE FIST IN GLORIOUS SUCCESS!
Otherwise... hang head in shameful defeat...