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 withping '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!
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 (Accounting bootloader customization): partition:size:fs type: label: description /dev/sda1: 1G: FAT32: EFI: EFI Partition /dev/sda3: : Btrfs: ARCH: System partition
After the system is fully partitioned, create the necessary filesystems:
FAT32 EFI Partition
mkfs.fat -F32 -n "EFI" /dev/sda1
Btrfs System Partition
mkfs.btrfs -L "ARCH" /dev/sda2
mount /dev/sda2 /mnt
cd /mnt
btrfs subvolume create @
btrfs subvolume create @home
btrfs subvolume create @var
btrfs subvolume create @snapshots
cd -
umount /mnt
Then, mount the partitions to their correct mountpoints, creating necessary dirs:
mount -o noatime,space_cache=v2,compress=zstd:5,ssd,discard=async,subvol=@ /dev/sda2 /mnt
mkdir -p /mnt/{boot,efi,home,var,snapshots}
mount -o noatime,space_cache=v2,compress=zstd:5,ssd,discard=async,subvol=@home /dev/sda2 /mnt/home
mount -o noatime,space_cache=v2,compress=zstd:5,ssd,discard=async,subvol=@var /dev/sda2 /mnt/var
mount -o noatime,space_cache=v2,compress=zstd:5,ssd,discard=async,subvol=@snapshots /dev/sda2 /mnt/snapshots
mount /dev/sda1 /mnt/efi
Install the base system with pacstrap
, like so:
pacstrap /mnt linux-zen{,-{headers,docs}} linux-firmware util-linux tlp tlp-rdw intel-ucode base{,-devel} pacman-contrib archlinux-contrib xdg-user-dirs btrfs-progs polkit go wget curl git openssh man-db sudo networkmanager network-manager-applet refind efibootmgr gvfs{,-{afc,goa,mtp,nfs,smb,google,gphoto2}} yt-dlp fzf ufw gufw htop imagemagick ffmpeg mediainfo neofetch openssh qt5-tools reflector ripgrep schedtool shellcheck tumbler ufw ytfzf ueberzug screen tmux vim nano firefox keepassxc lightdm{,-slick-greeter} xorg{,-{xwininfo,xbacklight}} brightnessctl xfce4{,-goodies} thunar{,-archive-plugin,-media-tags-plugin,-volman} docker pipewire{,-{alsa,docs,jack,pulse,audio}} wireplumber realtime-privileges helvum noto-fonts{,-{cjk,emoji,extra}} bluez{,-utils} blueman fcitx5-{im,lua} xclip mpv vlc webp-pixbuf-loader libwebp mtpfs libgsf kvantum lxappearance ttf-liberation gimp
Then, generate the file system table by label to the new root:
genfstab -L /mnt >> /mnt/etc/fstab
Change root to the new installation with:
arch-chroot /mnt
Edit your pacman configuration
vim /etc/pacman.conf
My personal settings are:
UseSyslog
Color
CheckSpace
VerbosePkgLists
ParallelDownloads = 4
ILoveCandy
Uncomment [multilib]
Don't forget to rebuild the database:
pacman --noconfirm -Syy archlinux-keyring
Symlink your timezone to your configuration:
ln -sf /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
hwclock --systohc
Note: after rebooting, run timedatectl set-ntp true
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
locale-gen
echo -e "LANG=en_US.UTF-8\nLC_COLLATE=C\nLC_MEASUREMENT=pt_BR.UTF-8\nLC_MONETARY=pt_BR.UTF-8\nLC_NUMERIC=pt_BR.UTF-8" > /etc/locale.conf
echo "KEYMAP=br-abnt2" >> /etc/vconsole.conf
Edit /etc/mkinitcpio.conf
and:
- Add
btrfs
toMODULES=()
; - Run
mkinitcpio -P
to regenerate initramfs;
Note: Later, installmkinitcpio-firmware
from the AUR to suppress warnings about missing firmware.
Edit sudo configuration with:
EDITOR=vim visudo
Note: Remove the #
from # wheel ALL=ALL (ALL)
and then, increase the tries and lower timeout from /etc/security/faillock.conf
:
vim /etc/security/faillock.conf
deny = 10
fail_interval = 120
unlock_time = 120
Create your machine hostname by echoing it to /etc/hostname
:
echo "insparch" > /etc/hostname
Then, modify /etc/hosts
:
echo -e "127.0.0.1\tlocaldomain\n::1\t\tlocaldomain\n127.0.1.1\tinsparch.localdomain\tinsparch" >> /etc/hosts
And enable network manager for after rebooting.
systemctl enable NetworkManager
Create a main user and add it to its proper groups:
useradd -m adaatii
usermod -aG wheel,audio,video,optical,storage,games,users,input,docker adaatii
passwd
passwd adaatii
Log in as the user and create their directories:
mkdir -p /usr/share/wallpapers
chown adaatii /usr/share/wallpapers
su adaatii
mkdir -p ~/{Documents,Downloads,Games,Music,Other{,/{Books,Desktop,Share,Templates}},Pictures{,/Screenshots},Projects,Videos,.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 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
and other aur packages through yay:
yay --noconfirm -S mkinitcpio-firmware ttf-ms-fonts downgrade drawio-desktop-bin informant modprobed-db raw-thumbnailer units lightdm-settings
Then, enable and configure some services with:
systemctl --user enable pipewire
systemctl --user enable modprobed-db
sudo usermod -aG informant adaatii
mkdir -p ~/.config
echo -e 'DBPATH="/home/adaatii/.config"\nCOLORS=dark\nIGNORE=(nvidia nvidia_drm nvidia_modeset nvidia_uvm vboxdrv vboxnetadp vboxnetflt vboxpci)'
Finally, exit with exit
.
Enable some important services with:
systemctl enable sshd
systemctl enable fstrim.timer
systemctl enable tlp
systemctl enable docker
usermod -aG lp adaatii
systemctl enable bluetooth
systemctl enable lightdm
systemctl enable ufw
systemctl mask systemd-networkd-wait-online
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.
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"
"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:
vim /efi/EFI/BOOT/refind.conf
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
Open with your editor the file /etc/lightdm/Xsession
,
and before the exec $@
line add the following:
# Input
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export SDL_IM_MODULE=fcitx
export GLFW_IM_MODULE=ibus
export XMODIFIERS=@im=fcitx
setxkbmap br
fcitx5 -d &
# Theming
#export QT_QPA_PLATFORMTHEME=kvantum
export QT_STYLE_OVERRIDE=kvantum
export QT_QPA_PLATFORMTHEME=qt5ct
#export GTK_THEME=Dracula:dark
In /etc/lightdm/lightdm.conf
, make sure the following lines are uncommented:
[LightDM]
run-directory=/run/lightdm
[Seat:*]
greeter-session=lightdm-slick-greeter
session-wrapper=/etc/lightdm/Xsession
and in /etc/lightdm/slick-greeter.conf
must have at least:
[Greeter]
clock-format=%H:%M:%S
Exit the chroot with exit
and unmount all disks with umount -a
.
Finally, reboot the system.
sudo ufw enable
sudo ufw default deny
sudo ufw allow from 192.168.0.0/24
sudo ufw allow qBittorrent
sudo ufw limit ssh
sudo timedatectl set-ntp true