Skip to content

Instantly share code, notes, and snippets.

@ForumPlayer
Forked from kenielf/arch.md
Created April 4, 2023 23:42
Show Gist options
  • Save ForumPlayer/918b17186e1f06858ce93be150d747d8 to your computer and use it in GitHub Desktop.
Save ForumPlayer/918b17186e1f06858ce93be150d747d8 to your computer and use it in GitHub Desktop.
Full Arch Linux Installation Guide

1: Base Installation

1.1: Preparing

Connect to a network, load keymaps and check for efivars. Firstly, connect to a network using iwctl with these commands:

  • iwctl: Enter the iwctl utility;
  • device list: List the possible devices to connect with;
  • station DEVICE scan: Scan networks on DEVICE;
  • station DEVICE get-networks: List all networks on DEVICE;
  • station DEVICE connect SSID: Connect to SSID with DEVICE; Note: Don't forget to test if you're connected with ping 'https://archlinux.org/'

Load your specific keymap for future input:

loadkeys br-abnt2

Note: The same keymap used here will be permanently set later inside the chroot.

Check if system is UEFI, for bootloader compatibility:

ls /sys/firmware/efi/efivars

Note: If the output is empty, that means you're on BIOS, check motherboard manual!

1.2: Disk Formatting

Use fdisk to format the system to your preferences

  • (n): New partition;
  • (d): Delete partition;
  • (p): Print partition scheme;
  • (m): help Manual;
  • (g): create Gpt partition table;
  • (t): change partition Type:
    • 1: EFI System
    • 19: Linux swap
    • 20: Linux filesystem
  • (w): Write changes to disk;
  • (q): Quit without saving; Recommended layout (220GB Disk): partition:size:fs type: label: description /dev/sda1: 1G: FAT32: EFI: EFI Partition /dev/sda2: 4G: Swap: SWAP: Swap Partition /dev/sda3: 220G: Btrfs: ARCH: System partition

After the system is fully partitioned, create the necessary filesystems:
FAT32 EFI Partition

mkfs.fat -F32 -n "EFI" /dev/sda1

SWAP

mkswap -L "SWAP" /dev/sda2
swapon /dev/sda2

Btrfs System Partition

mkfs.btrfs -L "ARCH" /dev/sda3
mount /dev/sda3 /mnt
cd /mnt
btrfs subvolume create @
btrfs subvolume create @home
cd -
umount /mnt

Then, mount the partitions to their correct mountpoints, creating necessary dirs:

mount -o noatime,space_cache=v2,compress=zstd,ssd,discard=async,subvol=@ /dev/sda3 /mnt
mkdir -p /mnt/{boot/efi,home}
mount -o noatime,space_cache=v2,compress=zstd,ssd,discard=async,subvol=@home /dev/sda3 /mnt/home
mount /dev/sda1 /mnt/boot/efi

1.3: Pacstrap and Fstab

Install the base system with pacstrap, like so:

pacstrap /mnt linux-zen{,-{header,docs}} linux-firmware util-linux tlp intel-ucode base{,-devel} pacman-contrib xdg-user-dirs btrfs-progs polkit go wget curl git openssh man-db sudo nvim networkmanager refind efibootmgr

Then, generate the file system table by label to the new root:

genfstab -L /mnt >> /mnt/etc/fstab

1.4: Chroot

Change root to the new installation with:

arch-chroot /mnt

1.4.1: Pacman Configuration

Edit your pacman configuration

nvim /etc/pacman.conf

My personal settings are:

UseSyslog
Color
CheckSpace
VerbosePkgLists
ParallelDownloads = 8
ILoveCandy
Uncomment [multilib]

Don't forget to rebuild the database:

pacman -Syy

1.4.2: Time and Locale Settings

Symlink your timezone to your configuration:

ln -sf /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
timedatectl set-ntp true
hwclock --systohc

Note: timedatectl might complain about system not having been booted with the correct init system, if so try again after booting.

Then, modify locale.gen, generate locale and set tty keymap:

nvim /etc/locale.gen

My locales are:

 en_US.UTF-8 UTF-8
 pt_BR.UTF-8 UTF-8
 ja_JP.UTF-8 UTF-8
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "KEYMAP=br-abnt2" >> /etc/vconsole.conf

1.4.3: Initcpio

Edit /etc/mkinitcpio.conf and:

  • Add btrfs i915 to MODULES=();
  • Run mkinitcpio -P to regenerate initramfs;
    Note: Later, install mkinitcpio-firmware from the AUR to suppress warnings about missing firmware.

1.4.4: Sudo

Edit sudo configuration with:

EDITOR=nvim visudo

Note: Remove the # from # wheel ALL=ALL (ALL)

and then, increase the tries and lower timeout from /etc/security/faillock.conf:

nvim /etc/security/faillock.conf
deny = 10
fail_interval = 120
unlock_time = 120

1.4.5: Hostname and Networking

Create your machine hostname by echoing it to /etc/hostname:

echo "arx" > /etc/hostname

Then, modify /etc/hosts:

echo -e "127.0.0.1\tlocaldomain\n::1\t\tlocaldomain\n127.0.1.1\tarx.localdomain\tarx" >> /etc/hosts

And enable network manager for after rebooting.

systemctl enable NetworkManager

1.4.6: Users and AUR

Create a main user and add it to its proper groups:

useradd -m kenielf
usermod -aG wheel,audio,video,optical,storage,games,users,input kenielf

Now change both the newly created user and the root users' passwords:

passwd kenielf
passwd

Log in as the user and create their directories:

mkdir -p /usr/share/wallpapers
chown kenielf:kenilef /usr/share/wallpapers
su kenielf
mkdir -p ~/{Documents,Downloads,Games,Music,Other{,/Books,/Desktop,/Japanese,/Share,/Templates},Pictures{,/Screenshots},Projects{,/Programming},Videos{,/Animes,/OBS},.secrets,.builds}
ln -sfT /usr/share/wallpapers $HOME/Pictures/Wallpapers
xdg-user-dirs-update --set DESKTOP ~/Other/Desktop
xdg-user-dirs-update --set DOCUMENTS ~/Documents
xdg-user-dirs-update --set DOWNLOAD ~/Downloads
xdg-user-dirs-update --set MUSIC ~/Music
xdg-user-dirs-update --set PICTURES ~/Pictures
xdg-user-dirs-update --set PUBLICSHARE ~/Other/Share
xdg-user-dirs-update --set TEMPLATES ~/Other/Templates
xdg-user-dirs-update --set VIDEOS ~/Videos
xdg-user-dirs-update --set PROGRAMMING ~/Projects/Programming
xdg-user-dirs-update --set GAMES ~/Games

Now clone yay and install it:

git clone "https://aur.archlinux.org/yay-git.git" ~/.builds/yay
cd ~/.builds/yay
makepkg -si
cd -
rm -rf ~/.builds/yay
yay --sudoloop --save

While you're still logged in as a regular user, install mkinitcpio-firmware through yay:

yay --noconfirm -S mkinitcpio-firmware

Finally, exit with exit.

1.4.7: Services

Enable some important services with:

systemctl enable sshd
systemctl enable fstrim.timer
systemctl enable tlp
system mask systemd-networkd-wait-online

1.4.8: ZRAM

Create a compressed block in RAM for fast swapping

echo 0 > /sys/module/zswap/parameters/enabled
echo "zram" > /etc/modules-load.d/zram.conf
echo "options zram num_devices=2" > /etc/modprobe.d/zram.conf
echo 'KERNEL=="zram0", ATTR{disksize}="1G" RUN="/usr/bin/mkswap /dev/zram0", TAG+="systemd"\nKERNEL=="zram1", ATTR{disksize}="1G" RUN="/usr/bin/mkswap /dev/zram1", TAG+="systemd"' > /etc/udev/rules.d/99-zram.rules
echo -e "\n#ZRAM\n/dev/zram0 none swap defaults,pri=5000 0 0\n/dev/zram1 none swap defaults,pri=5000 0 0" >> /etc/fstab
sysctl -w vm.swappiness=100

Note: When configuring your bootloader don't forget to append zswap.enabled=0 to the kernel parameters.

1.4.9: Bootloader

Install refind to the EFI partition previously created

refind-install --alldrivers --usedefault /dev/sda1

Then, configure your /boot/refind_linux.conf like such for a minimal configuration:

"Boot with tuned options"	"root=LABEL=ARCH rw add_efi_menmap rootflags=subvol=@ initrd=@\boot\intel-ucode.img initrd=@\boot\initramfs-%v.img zswap.enabled=0 sysrq_always_enabled=1 ec_sys.write_support=1 quiet log-priority=3 rd.udev.log-priority=3 splash nowatchdog nmi_watchdog=0 module_blacklist=iTCO_wdt nomce mitigations=off i915.mitigations=off i915.enable_fbc=1 i915.fastboot=1"

"Boot to standard options"	"root=LABEL=ARCH rw add_efi_menmap rootflags=subvol=@ initrd=@\boot\intel-ucode.img initrd=@\boot\initramfs-%v.img zswap.enabled=0 sysrq_always_enabled=1 ec_sys.write_support=1 quiet log-priority=3 rd.udev.log-priority=3 splash nowatchdog nmi_watchdog=0 module_blacklist=iTCO_wdt"

"Boot to single-user mode"	"root=LABEL=ARCH rw add_efi_menmap rootflags=subvol=@ initrd=@\boot\intel-ucode.img initrd=@\boot\initramfs-%v.img single"

"Boot with minimal options"	"root=LABEL=ARCH rw add_efi_menmap rootflags=subvol=@ initrd=@\boot\intel-ucode.img initrd=@\boot\initramfs-%v.img"

Do not forget to configure the bootloader to be capable of finding the kernels on arch linux:

timeout 5
use_nvram false
screensaver 30
hideui singleuser,safemode,arrows,hints
resolution max
use_graphics_for linux
showtools shell,memtest,about,hidden_tags,shutdown,reboot,firmware
scan_all_linux_kernels true
fold_linux_kernels false
extra_kernel_version_strings linux-zen,linux

1.5: Finishing Base Install

Exit the chroot with exit and unmount all disks with umount -a and swapoff /dev/sda2.
Finally, reboot the system.


2: Minimal Installation

Boot the system and login as a regular user, now install a minimalistic environment by following this section of the guide.

2.1: Xorg

The xorg group contains all the necessary packages relating to Xorg that will be used, install it with:

sudo pacman --noconfirm -S xorg

2.1.1: Backlight Configuration

Since this build is focused towards an intel cpu with integrated gpu machine, you should use the modesetting driver and because of that, you need to make the backlight file readable and writable to as a regular user.

[ ! -d /etc/udev/rules.d ] && sudo mkdir -p /etc/udev/rules.d
echo -e "RUN+=\"/usr/bin/chgrp video /sys/class/backlight/intel_backlight/brightness\"\nRUN+=\"/usr/bin/chmod g+w /sys/class/backlight/intel_backlight/brightness\"" | sudo tee /etc/udev/rules.d/20-backlight.rules

Along with that, install a backlight utility:

sudo pacman --noconfirm -S brightnessctl

2.1.2: Xorg Tools

Install other tools as well that might be helpful to you, such as numlockx

2.2: Session Management

2.2.1: LightDM

Install lightdm and a theme:

yay --noconfirm -S lightdm{,-{settings,slick-greeter}}

Configure its settings on /etc/lightdm, it will be revisited later on repeatedly.

2.2.2: Keyring

Install the necessary packages to set up a keyring

sudo pacman --noconfirm -S libsecret xdg-desktop-portal{,-gnome} lxsession seahorse

Edit /etc/pam.d/login:

#%PAM-1.0

auth       required     pam_securetty.so
auth       requisite    pam_nologin.so
auth       include      system-local-login
auth       optional     pam_gnome_keyring.so
account    include      system-local-login
session    include      system-local-login
session    optional     pam_gnome_keyring.so auto_start

Note: pay extra attention, only add the ones mentioning pam_gnome_keyring!

Now on your Xsession, add the following two lines:

lxsession &
dbus-update-activation-environment --all
gnome-keyring-daemon --start --components=secrets

2.2 Audio

2.2.1: PipeWire + Wireplumber

Install pipewire and enable it on userspace

sudo pacman --noconfirm -S pipewire{,-{alsa,jack,pulse,docs,audio}} wireplumber{,-docs} realtime-privileges
sudo usermod -aG realtime kenielf
systemctl --user enable pipewire.service

2.2.2: Audio Tools

To tweak the audio settings, install a few audio utilities:

sudo pacman --noconfirm -S alsa-{utils,tools} pavucontrol helvum

2.2.3: Configure Audio Ports

On Asus' X510UA, the internal microphone gets disabled whenever inserting a headphone with microphone support, so in order to disable that from happening, open hdajackretask:

  • 1: Select the codec conexant generic;
  • 2: On Black Mic, Right Side click override
  • 3: Set the override as Not connected
  • 4: Save it by clicking Apply now and Install boot override

2.2.4: Music Server

Install the Music Player Daemon and a few players:

sudo pacman -S mpd mpc ncmpcpp timidity++

Create the config directory and copy the default config:

mkdir -p ~/.config/mpd
cp /usr/share/doc/mpd/mpdconf.example ~/.config/mpd/mpd.conf
sudo systemctl enable mpd

Open ~/.config/mpd/mpd.conf and:

  • Configure files accordingly:
    music_directory "~/Music"
    playlist_directory "~/.config/mpd/playlists"
    db_file "~/.config/mpd/database.db"
    log_file "~/.config/mpd/log"
    pid_file "~/.config/mpd/pid"
    sticker_file "~/.config/mpd/sticker.sql"
    bind_to_address "127.0.0.1"
    port "6600"
    auto_update "yes"
    
  • Set audio input:
    input {
            plugin "curl"
    }
    
  • Configure Audio Outputs:
    audio_output {
        type            "pipewire"
        name            "PipeWire Sound Server"
    }
    audio_output {
    type                    "fifo"
    name                    "FIFO"
    path                    "/tmp/mpd.fifo"
    format                  "44100:16:2"
    }
    

Now to be able to use mpd, configure ncmpcpp at `~/.config/ncmpcpp/config:

mpd_host "127.0.0.1"
mpd_port "6600"
mpd_music_dir "~/Music"

audio_output {
	type		"fifo"
	name		"my_fifo"
	path		"/tmp/mpd.fifo"
	format		"44100:16:2"
}

visualizer_data_source = "/tmp/mpd.fifo"
visualizer_output_name = "my_fifo"
visualizer_in_stereo = "yes"
visualizer_type = "spectrum"
visualizer_look = "+|"

2.3: Bluetooth

To configure bluetooth, firstly install the necessary tools:

sudo pacman --noconfirm -S bluez{,-utils} blueman

Load its module and add your user to the lp group:

sudo modprobe btusb
sudo usermod -aG lp kenielf
sudo systemctl enable bluetooth

2.4: Input

This section is specifically about the X environment!

2.4.1: X11 Keymap

Add to the Xsession the following line:

setxkbmap -layout br &
numlockx &

2.4.2: Fcitx5

Install fcitx5 and the extra languages you might want:

sudo pacman --noconfirm -S fcitx5-{im,lua,mozc} qt5-tools

Now add to your Xsession the following lines:

GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
SDL_IM_MODULE=fcitx
GLFW_IM_MODULE=ibus
XMODIFIERS=@im=fcitx
fcitx5 -d &

2.4.3: Clipboard

Fcitx already has support for clipboard, but for scripting install xclip

2.4.4: LibInput

Install libinput if it isn't installed, do note though that if you're using Xorg it's already installed

sudo pacman --needed --noconfirm -S libinput

Now to enable tap to click, edit /etc/X11/xorg.conf.d/30-touchpad.conf and add:

Section "InputClass"
    Identifier "touchpad"
    Driver "libinput"
    MatchIsTouchpad "on"
    Option "Tapping" "on"
    Option "TappingButtonMap" "lmr"
EndSection

Now, install libinput-gestures and configure it accordingly:

yay --noconfirm -S libinput-gestures wmctrl xdotool
libinput-gestures-setup autostart start
nvim ~/.config/libinput-gestures.conf

Then, edit your configuration, this is what I use:

gesture swipe up	/usr/bin/i3-msg -t command workspace next
gesture swipe down  /usr/bin/i3-msg -t command workspace prev

timeout 1.5

2.5: Shell

2.5.1: ZSH

Install zsh and apply it to all users:

sudo pacman -S zsh
which zsh
sudo chsh kenielf
sudo chsh

Open a new shell or run zsh and configure it to your liking.

2.6: Window Management

2.6.1: i3wm

Install i3-gaps over i3 for future customization:

sudo pacman --noconfirm -S i3-gaps i3status

2.6.2: WM Tools

Now in order to have a full working environment, you'll need a few gui programs:

  • Status Bar: polybar;
  • Launcher/Powermenu: rofi;
  • Lockscreen: i3lock-color;
  • Terminal: kitty;
  • Notifications: dunst;
  • File Manager: thunar;
  • Compressed Files: engrampa
  • Image Viewer: eog;
  • Calculator: mate-calc;
  • Media Player: mpv vlc;
  • PDF Viewer: zathura
  • GUI Editor: mousepad
  • Sticky Notes: xpad
  • Background Color/Wallpaper: hsetroot feh
  • Browser: firefox
  • Compositor: picom
  • Screenshots: scrot

Install them all by using this huge command:

yay --noconfirm -S polybar rofi i3lock-color kitty{,-terminfo,-shell-integration}-git dunst thunar{,-archive-plugin,-media-tags-plugin,-volman} gvfs{,-nfs,-smb,-afc,-google,-mtp,-goa,-gphoto2} mtpfs libgsf libwebp raw-thumbnailer tumbler ffmpegthumbnailer webp-pixbuf-loader engrampa eog{,-docs,-plugins} mate-calc mpv{,-mpris} vlc zathura{,-{cb,djvu,pdf-mupdf,ps}} mousepad xpad hsetroot feh firefox picom scrot

2.7: Theming

Install kvantum and lxappearance to change GTK and QT themes.
On your Xsession file, add:

# Theming
export QT_STYLE_OVERRIDE=kvantum
export QT_QPA_PLATFORMTHEME=kvantum
export GTK_THEME=Dracula:dark

Note: the dracula theme is used here as an example.

2.7.1: Fonts

I use various different fonts, in this order:

  • Main font: ttc-iosevka: Iosevka Term 10
  • Japanese font: ttf-sarasa-gothic: Sarasa Term TC 10
  • Emojis: ttf-symbola: Symbola 10
  • Main font fallback: ttf-jetbrains-mono: JetBrains Mono 10
  • Glyphs and other language fallbacks: ttf-sourcecodepro-nerd: SauceCodePro Nerd Font 10

Other fonts that I require for writing documents and other packages are:

  • ttf-liberation;
  • ttf-ms-fonts;

2.7.2: Colorscheme

My actual colorscheme is Dracula, install some packages that have this theme:

dracula{-gtk-theme,-{icons,cursors}-git} ant-dracula-kvantum-theme-git

The rest of the supported applications can be found here

2.8: Keys and Passwords and Other Securities

2.8.1: SSH Keys

Your ssh keys are stored in ~/.ssh, copy them to a backup folder and when reapplying them, don't forget to follow this pattern:

chmod 600 id_edXXXXX
chmod 644 id_edXXXXX.pub

This will make it so that your keys will be -rw------- and -rw-r--r-- respectively, following requirement.

2.8.2: GPG Keys

GPG Keys are a bit more complex and require much more caution.
Export them as follows:

gpg --list-secret-keys user@example.com
gpg --export-secret-keys YOUR_ID_HERE > private.key

And to import them:

gpg --import private.key
gpg --edit-key user@example.com
gpg> trust
gpg> 5
gpg> save

2.8.3: Git Configuration

Configure your git as follows:

git config --global user.name "username"
git config --global user.email "user@example.com"
git config --global init.defaultBranch "main"
git config --global --unset gpg.format
git config --global user.signingkey HUGEKEYGOESHERE
git config --global commit.gpgsign true

And add clone and push url aliases to ~/.gitconfig:

[url "https://github.com/"]
	insteadOf = gh:
[url "git@github.com:"]
	pushInsteadOf = "gh:"

[url "https://gitlab.com/"]
	insteadOf = gl:
[url "git@gitlab.com:"]
	pushInsteadOf = "gl:"

[url "https://aur.archlinux.org/"]
	insteadOf = aur:
[url "aur@aur.archlinux.org:"]
	pushInsteadOf = "aur:"

2.8.4: KeePassXC

Install KeePassXC:

sudo pacman --noconfirm -S keepassxc

2.8.5: FireWall

Install the Uncomplicated FireWall and configure it:

sudo pacman --noconfirm -S ufw {,g}ufw
sudo systemctl enable ufw
sudo ufw enable
sudo ufw default deny
sudo ufw allow from 192.168.0.0/24
sudo ufw allow qBittorrent
sudo ufw limit ssh

2.9: CLI/TUI Tools

Batch install tools that will be used

yay --noconfirm --needed -S htop tree fzf ffmpeg imagemagick bat autopep8 clang shellcheck nodejs npm yt-dlp android-tools scrpcy

2.10: GUI Tools

Install other GUI applications

Yay --noconfirm --needed -S discord teams gimp audacity kdenlive czkawka-gui-bin libreoffice-still obs-studio drawio-desktop code

3: Gaming

Steam, Drivers, Wine and Proton

4: Performance

4.1: CCache

Install ccache and prepare its directories:

sudo pacman --noconfirm -S ccache
sudo mkdir -p /var/cache/ccache
sudo chown kenielf:kenielf /var/cache/ccache

Now create the config file at /etc/ccache.conf:

cache_dir = /var/cache/ccache
max_size = 16.0G
compression_level = 6

Change BUILDENV in /etc/makepkg.conf:

BUILDENV=(!distcc color ccache check !sign)

Change ccache's sloppiness when comparing files:

sudo ccache --set-config=sloppiness=locale,time_macros

4.2: Configuring modprobed-db

Install modprobed-db:

yay --noconfirm -S modprobed-db
modprobed-db
modprobed-db store

Optionally, if you'd like:

systemctl enable --user modprobed-db

4.3: Custom Kernel Configuration

4.3.1: Linux-TKG

Download the repository, create the .config folder to store your configuration

git clone "https://github.com/frogging-family/linux-tkg" ~/.builds/linux-tkg
cd ~/.builds/linux-tkg
mkdir ~/.config/frogminer

For this kernel, specifically, I recommend creating the configuration file with the following naming convention: ~/.config/frogminer/linux-tkg-$scheduler.cfg And symlinking it with -sfT to linux-tkg.cfg.

If you don't have a configuration, copy it from the file customization.cfg in the repository's root.

To actually compile it, after configuring:

makepkg -sfC
makepkg -i

Don't forget to add it to your preferred bootloader!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment