Arch Linux

Arch Linux

A x86-64 general-purpose Linux distribution that proves the latest stable version of most software by following a rolling release model.

Documentation: https://wiki.archlinux.org/title/Main_page
Repository: https://gitlab.archlinux.org/archlinux


Package Managers

Pacman

sudo pacman -Syu # update everything
sudo pacman -S <package> # install a package
sudo pacman -Ss <search-term> # search from remote packages
sudo pacman -Q # list all install packages
sudo pacman -Qs <search-term> # search from installed packages
sudo pacman -Qe # list expecitly installed packages
sudo pacman -R <package> # remove package
sudo pacman -Rns <package> # remove package and extra config/depenencies

# for searching, replace s with i in the command to get more information

Paru

# all pacman command work, just replace 'sudo pacman' with 'paru'
paru # update everything
paru <package> # search and install
paru -Sua # update AUR packages only
paru -Qua # print available updates

Flatpak

# alternative app store. containerizes and resticts apps
sudo pacman -S flatpak

# additional protection tool
flathub flatpak install flathub com.github.tchx84.Flatseal
flatpak run com.github.tchx84.Flatseal

Build Package Manually

# manually build package (reference)
# https://www.youtube.com/watch?v=tCDy54Zc2Cw

# first time steps
vim /etc/makekpkg.conf
# uncomment MAKEFLATS line and set value to cpu threads + 1
# ex. 20 threads cpu: MAKEFLAGS='-j21'
mkdir -p ~/downloads/packages

# read PKGBUILD files before running makepkg
# check dependencies, conflicts, and commands at the bottom

# --- from source code --- #
# download
cd ~/downloads/packages
git clone https://aur.archlinux.org/paru.git

# build 
cd paru
makepkg -si

# update
cd ~/downloads/packages
cd paru
git pull
makepkg -si

# --- from tar.zst --- #
# download
cd ~/downloads/packages
wget https://github.com/Morganamilo/paru/releases/download/v2.0.4/paru-v2.0.4-x86_64.tar.zst

# build
sudo pacman -U paru-v2.0.4-x86_64.tar.zst

Guides:

Install

  1. Download Arch ISO

  2. Mount Arch ISO onto a USB with either option below (Ventoy is easier).

    • Rufus
      1. Select the USB and ISO.
      2. Set partition scheme to MBR
      3. Set file system to FAT32
      4. Leave defaults for remaining.
    • Ventoy
      1. Install Ventoy on USB.

        sudo ventoy -i /dev/sdb1
        
      2. Copy ISO into USB.

  3. Disable secure boot in BIOS.

  4. Boot into USB with Arch ISO.

  5. Increase font size.

# medium
setfont ter-928n

# large
setfont ter-132b
  1. Connect to a WiFi network (skip for Ethernet).
# connect to network
iwctl --passphrase <password> station <device> connect <ssid>

If WiFi device and SSID are unknown use the following.

# enter network configuration
iwctl

# list avalible devices, use the correct device name for next steps as <device> ex. wlan0
device list

# connect to a network
station <device> scan
station <device> get-networks
station <device> connect <ssid>

# exit iwctl
exit
  1. Test network connection.
ping -c 5 ping.archlinux.org
  1. Set timezone.
# list timezones
timedatectl list-timezones
# type / to start searching

# set timezone, <timezone> ex. America/Toronto
timedatectl set-timezone <timezone>

# verify
timedatectl
  1. (optional) SSH into machine.
# set temporary passwd
passwd

systemctl start sshd

# note ip address
ip addr

Connect from a remote machine with ssh root@<lan-ip>.

  1. Partition the disks.

    1. Run cfdisk.
    2. Select GPT as label type.
    3. Identify desired OS drive and delete any partitions of needed (select Write after changes).
    4. Select Free Space, then select New to create the following partitions:
      1. 4G - EFI/Boot
      2. Remaining - Root filesystem
    5. Select the boot partition, then select Type and set to EFI System.
    6. Select Write, type yes, then select Quit.
  2. Identify created partitions.

lsblk -f
  1. Format boot partition.
# <boot-partition> ex. nvme0n1p1
mkfs.fat -F 32 -n boot /dev/<boot-partition>
  1. Setup one of the following filesystems.

BTRFS

# <root-partition> ex. nvme0n1p2, <partition-label> ex. nvme-os
mkfs.btrfs -L <partition-label> /dev/<root-partition>

# create subvolumes
mount /dev/<root-partition> /mnt
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@log
btrfs subvolume create /mnt/@cache
umount /mnt

# mount subvolumes
mount --mkdir -o compress=zstd,noatime,subvol=@ /dev/<root-partition> /mnt
mount --mkdir -o compress=zstd,noatime,subvol=@home /dev/<root-partition> /mnt/home
mount --mkdir -o compress=zstd,noatime,subvol=@log  /dev/<root-partition> /mnt/var/log
mount --mkdir -o compress=zstd,noatime,subvol=@cache  /dev/<root-partition> /mnt/var/cache

# mount boot partition
mount --mkdir /dev/<boot-partition> /mnt/boot

EXT4

# <root-partition> ex. nvme0n1p2, <partition-label> ex. nvme-os
mkfs.ext4 -L <partition-label> /dev/<root-partition>

mount --mkdir /dev/<root-partition> /mnt
mount --mkdir /dev/<boot-partition> /mnt/boot
  1. Install Linux and base packages.
# base linux linux-firmware linux-headers     standard system packages
# intel-ucode or amd-ucode                    cpu
# base-devel                                  package build tools
# network manager                             network
# helix or vim                                editor
# btrfs-progs                                 (if needed) btrfs user utilites
# limine efibootmgr                           bootloader
# man-db man-pages                            manuals
# git curl wget rsync zip unzip               basic network and file tools
pacstrap /mnt base linux linux-firmware linux-headers intel-ucode base-devel networkmanager helix btrfs-progs limine efibootmgr man-db man-pages git curl wget rsync zip unzip

# fetch the disk mounting points
genfstab -U /mnt >> /mnt/etc/fstab

# verify that it matches step 10
cat /mnt/etc/fstab

# move to system
arch-chroot /mnt
  1. Setup timezone and locale.
# set timezone and sync hardware clock, <region>/<city> ex. America/Toronto
ln -sf /usr/share/zoneinfo/<region>/<city> /etc/localtime
hwclock --systohc

# set language, search for correct UTF-8 locale inside /etc/locale.gen if using another
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "KEYMAP=us" > /etc/vconsole.conf
  1. Setup Hostname and User.
# set hostname ex. <hostname> jimbo
echo "<hostname>" > /etc/hostname

# create host file entries, add following lines
echo "127.0.1.1 <hostname> <hostname>.local" >> /etc/hosts

# set root password
passwd

# add new user with sudo permissions ex. <user>: bimbo
useradd -mG wheel <user>
passwd <user>

# uncomment line saying 'allow members of group wheel to execute any command'
EDITOR=vim visido
  1. Setup Limeline bootloader.
mkinitcpio -P

mkdir -p /boot/EFI/limine
cp /usr/share/limine/BOOTX64.EFI /boot/EFI/limine/

# create bootloader entry in NVRAM, <boot-disk> ex. nvme0n1, <boot-partition-num> ex. 1
efibootmgr --create --disk /dev/<boot-disk> --part <boot-partition-num> --label "Arch Linux Limine Bootloader" --loader '\EFI\limine\BOOTX64.EFI' --unicode

# add UUID and machine id to limine config file, delete it later
blkid -o value -s UUID /dev/<root-partition> >> /boot/limine.conf
cat /etc/machine-id >> /boot/limine.conf

Edit /boot/limine.conf:

timeout: 5
default_entry: 2

comment: machine-id=<machine-id>
/+Arch Linux

  //Linux
  protocol: linux
  path: boot():/vmlinuz-linux
  module_path: boot():/initramfs-linux.img
  cmdline: root=UUID=<uuid> rw rootflags=subvol=@ quiet splash
	
  //Snapshots
  1. Finish Up.
# enable network manager
systemctl enable NetworkManager
ping -c 5 ping.archlinux.org

# exit and reboot
exit
umount -R /mnt
reboot
  1. Login to created user and enable time sync.
timedatectl set-ntp true

Post-Install


Network

  1. Connect to WiFi.
nmcli device wifi list # list networks
nmcli device wifi connect <ssid> password <password> # connect to network
  1. (optional) Use correct WiFi regulations for potentially better speed.
sudo pacman -S wireless-regdb
# uncomment one country code line in `/etc/conf.d/wireless-regdom`

Package Managers

  1. Update Mirrors.
sudo pacman -S reflector
sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
sudo reflector --verbose --latest 10 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
  1. Edit these lines in /etc/pacman.conf.

    1. Uncomment color.
    2. Change ParellelDownloads to 20.
    3. Add ILoveCandy.
    4. Uncomment [multilib] and following line.
  2. Update System.

sudo pacman -Syu
  1. Install Paru.
sudo pacman -S --needed rustup base-devel git && rustup default stable && git clone https://aur.archlinux.org/paru.git && cd paru && makepkg -si && cd .. && rm -rf paru
  1. Uncomment BottomUp from /etc/paru.conf.
  2. Install CachyOS packages https://wiki.cachyos.org/features/optimized_repos/.
curl https://mirror.cachyos.org/cachyos-repo.tar.xz -o cachyos-repo.tar.xz
tar xvf cachyos-repo.tar.xz && cd cachyos-repo
sudo ./cachyos-repo.sh

SSH

sudo pacman -S openssh
sudo systemctl enable --now sshd

See more in SSH to configure keys and hardening.


Firewall

sudo pacman -S ufw
sudo systemctl enable --now ufw

# allow ssh and enable
sudo ufw limit ssh
sudo ufw enable

Snapper and Limine

  1. Install requirements.
# snapper                   better btrfs snapshot utility
# snap-pac                  auto-generate snapshots for pacman    
# btrfs-assistant           gui for btrfs
# limine-snapper-sync       auto-generate snapshot boot entries
# limine-mkinitcpio-hook    auto-regenerate bootloader
sudo pacman -S snapper snap-pac btrfs-assistant
paru -S limine-snapper-sync limine-mkinitcpio-hook
  1. Edit snapper default template /usr/share/snapper/config-templates/default.

    1. Set NUMBER_MIN_AGE to 1800.
    2. Set TIMELINE_CLEANUP_AGE to 1800.
    3. Set EMPTY_PRE_POST_MIN_AGE to 1800.
    4. Set Timeline limits:
      1. Hourly: 12
      2. Daily: 7
      3. all others: 0
  2. Create snapper configs.

sudo snapper -c root create-config /
sudo snapper -c home create-config /home
  1. Edit limine snapper sync config /etc/limine-snapper-sync.conf.

    1. Set EXCLUDE_SNAPSHOT_TYPES to "pre, post".
    2. Set MAX_SNAPSHOT_ENTRIES to 21.
    3. Set SNAPSHOT_FORMAT_CHOICE to 8.

Edit /etc/default/limine:

ESP_PATH="/boot"
KERNEL_CMDLINE[default]+="quiet nowatchdog splash rw rootflags=subvol=/@ root=UUID=<uuid>"
BOOT_ORDER="*, *lts, *fallback, Snapshots"

Remove the original non-autogenerated entry from boot/limine.conf.


Swap

sudo pacman -S zram-generator
echo -e "[zram0]\nzram-size = ram" | sudo tee /etc/systemd/zram-generator.conf
systemctl daemon-reload
systemctl start systemd-zram-setup@zram0

Audio

# sof-firmware         firmware for some soundcards
# pipwire and others   audio utils
# wiremix              TUI for audio controls
sudo pacman -S sof-firmware pipewire wireplumber alsa-utils pipewire-alsa pipewire-pulse pipewire-jack wiremix

systemctl --user --now enable pipewire pipewire-pulse wireplumber 

Bluetooth

sudo pacman -S bluez bluez-utils
auso systemctl enable --now bluetooth

GPU Drivers

NVIDIA

  1. Install drivers.
sudo pacman -S nvidia-open nvidia-settings nvidia-utils lib32-nvidia-utils libva-nvidia-driver
  1. Add modules to /etc/mkinitcpio.conf.
MODULES=(... nvidia nvidia_modeset nvidia_uvm nvidia_drm)
  1. Regenerate initramfs.
sudo mkinitcpio -P

Splash Screen

  1. Install plymouth.
sudo pacman -S plymouth
  1. Add plymouth hook after systemd to /etc/mkinitcpio.conf.
MODULES=(.. systemd plymouth ...)
  1. Regenerate initramfs.
sudo mkinitcpio -P
  1. Set theme.
paru -S plymouth-theme-lone-git
sudo plymouth-set-default-theme -R lone

Find more themes: https://github.com/adi1090x/plymouth-themes.


XDG

sudo pacman -S xdg-user-dirs

Modify user directories ~/.config/user-dirs.dirs

XDG_DESKTOP_DIR="$HOME/.local/Desktop"
XDG_DOCUMENTS_DIR="$HOME/Storage"
XDG_DOWNLOAD_DIR="$HOME/Downloads"
XDG_MUSIC_DIR="$HOME/"
XDG_PICTURES_DIR="$HOME/"
XDG_PROJECTS_DIR="$HOME/Projects"
XDG_PUBLICSHARE_DIR="$HOME/"
XDG_TEMPLATES_DIR="$HOME/"
XDG_VIDEOS_DIR="$HOME/"

Fonts

sudo pacman -S noto-fonts noto-fonts-emoji ttf-iosevka-nerd

Desktop Environment

Hyperland (WM)

# hyprland and other         hyprland
# kitty                      terminal emulator
# nautilus                   file manger
# waybar pacman-contrib      status bar
# swaync                     notifications
# hyprlock                   lockscreen
# hypridle                   auto lock
# hyprshot                   screenshot
# hyprsunset                 blue light filter
# awww                       wallpaper
# nwg-look                   gtk-theming
# gnome-keyring seahorse    authentication
# vicinae                    launcher
sudo pacman -S hyprland xdg-desktop-portal-hyprland xdg-desktop-portal-gtk hyprpolkitagent kitty nautilus waybar pacmand-contrib swaync hyprlock hypridle hyprshot hyprsunset awww nwg-look gnome-keyring seahorse
paru -S vicinae-bin

Greeter

sudo pacman -S greetd greetd-tuigreet
sudo systemctl enable greetd

Edit /etc/greetd/config.toml:``

  1. Change [default_session] command to "tuigreet --cmd start-hyprland".
  2. For autologin, add following lines, replace <user>.
[initial_session]
command = "start-hyprland"
user = "jay"

Final Config

[terminal]
vt = 1

[default_session]
command = "tuigreet --cmd start-hyprland"
user = "greeter"

[initial_session]
command = "start-hyprland"
user = "jay"

Gaming

# steam
# mangohud           detailed fps and system overlay
# protonup-qt-bin    proton version manager
sudo pacman -S steam mangohud protonup-qt-bin
  1. Install Proton GE with protonup.
  2. Enable compatibility and use Proton GE in steam.
  3. Set launch arguments below for each game.
    • LD_PRELOAD=“” - fixes stuttering in game.
    • other are for HDR.
LD_PRELOAD=“” PROTON_ENABLE_HDR=1 PROTON_ENABLE_WAYLAND=1 %command%

Gamescope

LD_PRELOAD=“” gamescope -w 3440 -h 1440 --fullscreen -r 165 --hdr-enabled --hdr-debug-force-output -- env ENABLE_GAMESCOPE_WSI=1 DXVK_HDR=1 %command%
Powered by Forestry.md