My Custom Arch Linux with i3-gaps, btrfs and zram
-
Dowload Arch Linux from its website
https://archlinux.org/download/ -
Download balena etcher for making bootable USB.
https://www.balena.io/etcher/ -
Insert USB and flash the arch linux iso to the USB
-
After flashing, reboot the machine and select the boot device as USB. For HP devices F9 key is used for selecting boot devices.
-
Connect to wired network if possible.
-
Boot into live iso.
-
Set your keyboard type. Search using localectl list-keymaps | grep 'type'
-
Mine is US keyboard so,
# loadkeys us -
If you don't have wired connection but wireless connection. Connect to your wireless connection using iwctl
# iwctl # station your-wireless-interface connect SSID -
After that it will ask for wireless network password. Enter the password and check if you have the internet connection by pinging.
-
Use command lsblk to get the information of disk we currently have.
-
Use cfdisk command to make parition.
# cfdisk /dev/sda -
Create at least minimum 300 MB partition size for efi and reset for btrfs partition.
-
Now we created parition, we need to format it. For efi partition we format it to fat32 file system
# mkfs.vfat /dev/sda1 -
For btrfs partition,
# mkfs.btrfs /dev/sda2 -
Unlike ext4, in btrfs we need to create sub volumes for root, home and var directory.
-
First mount the sda2 to /mnt
# mount /dev/sda2 /mnt -
Now create sub volumes,
# btrfs subvolume create /mnt/@ # btrfs subvolume create /mnt/@home # btrfs subvolume create /mnt/@var # btrfs subvolume create /mnt/@opt # btrfs subvolume create /mnt/@tmp -
Now unmount the sda ,
# umount /mnt -
Now mounting root, home and var.
# mount -o noatime,compress=zstd,ssd,discard=async,space_cache=v2,subvol=@ /dev/sda2 /mnt -
Creating efi,home and var directory in /mnt
# mkdir -p /mnt/{boot/efi,home,var,opt,tmp} -
Mounting home, var and efi.
# mount -o noatime,compress=zstd,ssd,discard=async,space_cache=v2,subvol=@home /dev/sda2 /mnt/home # mount -o noatime,compress=zstd,ssd,discard=async,space_cache=v2,subvol=@opt /dev/sda2 /mnt/opt # mount -o noatime,compress=zstd,ssd,discard=async,space_cache=v2,subvol=@tmp /dev/sda2 /mnt/tmp # mount -o subvol=@var /dev/sda2 /mnt/var # mount /dev/sda1 /mnt/boot/efi -
Now installing base packages
# pacstrap /mnt base linux linux-firmware git vim btrfs-progs amd-ucode -
Now generating file system table,
# genfstab -U /mnt >> /mnt/etc/fstab -
Now go to our installed directory or the root directory,
# arch-chroot /mnt -
You can view the fstab using cat command.
-
Now setting time zone,
# ln -sf /usr/share/zoneinfo/Asia/Kathmandu /etc/localtime -
Synchronize hardware clock to the system clock
# hwclock --systohc -
Now editing /etc/locale.gen and uncomment your locale. My locale is en_US.UTF-8 UTF-8
-
Now generating locale by
# locale-gen -
Putting the locale into /etc/locale.conf file using echo command,
# echo "LANG=en_US.UTF-8" >> /etc/locale.conf -
Setting hostname archNepal using echo command,
# echo "archNepal" >> /etc/hostname -
Now configuring /etc/hosts for networks
127.0.0.1 localhost ::1 localhost 127.0.1.1 archNepal.localdomain archNepal -
Set root password,
# passwd -
Installing base packages, Network and Audio
# pacman -S grub efibootmgr network-manager-applet dialog wpa_supplicant mtools dosfstools base-devel linux-headers bluez bluez-utils cups xdg-user-dirs pipewire pipewire-alsa pipewire-jack pipewire-pulse alsa-utils gvfs -
Install Bootloader. Since I am UEFI mode,
# grub-install --target=x86_64-efi efi-directory=/boot/efi --bootloader-id=GRUB -
Create config file for GRUB
# grub-mkconfig -o /boot/grub/grub.cfg -
Enabling Services at boot,
# systemctl enable NetworkManager.service # systemctl enable bluetooth # systemctl enable cups.service # systemctl enable fstrim.timer -
Creating a New User and add password to it.
# useradd -m username # passwd username -
Add groups to user.
# usermod -aG wheel,video,audio,power,lp username -
Add user to sudoers by command visudo. Uncomment ```wheel ALL=(ALL) ALL
-
Add btrfs modules in /etc/mkinitcpio.conf
MODULES=(btrfs) -
Recompile the kernel.
# mkinitcpio -P -
Now exit the arch-chroot and reboot.
-
Well arch linux is installed. Now the customization remains
-
After machine boot up, login with user and password.
-
To connect to a wireless network, use command nmtui and activate a connection. Choose a SSID and enter the password.
-
Update the system.
$ sudo pacman -Syu -
Set NTP to true.
$ sudo timedatectl set-ntp true -
Now installing display server, display manager and window manager.
$ sudo pacman -S xorg lightdm lightdm-slick-greeter i3 dmenu lxappearance nitrogen archlinux-wallpaper alacritty picom firefox -
Enable display manager.
$ sudo systemctl enable lightdm.service -
Add replace the value of greeter-session in /etc/lightdm/lightdm.conf to lightdm-slick-greeter
-
Adding arcolinux repository, clone the arcolinux spices.
$ git clone https://github.com/arcolinux/arcolinux-spices.git $ sudo ./arcolinux-spices/usr/share/arcolinux-spices/scripts/[get-the-keys-and-repos.sh -
Add chaotic repository (key may change),
$ sudo pacman-key --recv-key FBA220DFC880C036 --keyserver keyserver.ubuntu.com $ sudo pacman-key --lsign-key FBA220DFC880C036 $ sudo pacman -U 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst' 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst' -
Append chaotic mirror repo in /etc/pacman.conf
[chaotic-aur] Include = /etc/pacman.d/chaotic-mirrorlist -
Increase the maximum number of parallel downloads by uncommenting max_parallel_downloads in /etc/pacman.conf
-
Now update the system using
$ sudo pacman -Syu -
Install Paru using
$ sudo pacman -S paru -
Install timeshift, timeshift-autosnap zramd lightdm-settings.
$ paru -S timeshift timeshift-autosnap zramd lightdm-settings -
Install grub-btrfs using
$ sudo pacman -S grub-btrfs -
Enabling zram using
$ sudo systemctl enable --now zramd -
Running lsblk command we can see extra swap.
-
Now reboot, we are boot into lightdm login screen.
-
Setup git.
$ git config --global user.name 'Your Username' $ git config --global user.email 'Your Email' -
Setup ssh keys.
$ ssh-keygen -t ed25519 -C 'Your Email' -
Install i3status-rust, rofi, thunar, brightnessctl and font-awesome
$ sudo pacman -S i3status-rust rofi awesome-terminal-fonts ttf-font-awesome brightnessctl -
Login and open terminal. Clone this repo.
$ git clone https://github.com/ishanshre/archlinux-setup.git -
Copy the config files to .config directory
$ cp -r My-Arch-Linux-Setup-and-Customization/config/i3 ~/.config/ $ cp -r My-Arch-Linux-Setup-and-Customization/config/rofi ~/.config/ -
Copy the rofi theme from the cloned directory to themes of rofi.
$ sudo cp My-Arch-Linux-Setup-and-Customization/config/rofi/catppuccin-mocha.rasi /usr/share/rofi/themes/ -
Clone rofi-power-menu from git repo
$ git clone https://github.com/jluttine/rofi-power-menu.git -
Now copy rofi-power-menu to
~/.locals/bin -
Install firewall.
$ sudo pacman -S ufw $ systemctl enable -now ufw -
Tweaking performance. Chaotic Repo must be enabled
$ sudo pacman -S cfs-zen-tweaks nohang ananicy preload $ sudo systemctl enable --now preload $ sudo systemctl enable --now ananicy $ sudo systemctl enable --now nohang -
Install jdk, google chrome, vscode and ntfs
$ sudo pacman -S ntfs-3g jdk google-chrome code -
Install sweet-nova theme and candy icons
$ sudo pacman -S candy-icons-git sweet-cursor-theme -
Install lts kernel
$ sudo pacman -S linux-lt linux-lts-headers linux-firmware -
Install Docker
$ sudo pacman -S docker docker-compose docker-scan docker-buildx docker-machine -
Install Fish Shell and Oh-My-Fish
$ sudo pacman -S fish $ curl https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | fish $ omf update $ chsh -s /usr/bin/fish $USER $ omf install budspencer $ set -U budspencer_nogreeting -
Installing and Configuring Tor (Taken from Arch Wiki)
-
Install tor and nyx package and start tor
$ sudo pacman -S tor nyx $ sudo systemctl start tor -
Open Tor control port and set control cookie
$ sudo nano /etc/tor/torrec ControlPort 9051 CookieAuthentication 1 CookieAuthFile /var/lib/tor/control_auth_cookie CookieAuthFileGroupReadable 1 DataDirectoryGroupReadable 1 -
Add tor to user group and restart tor
$ sudo usermod -aG tor $USER $ newgrp tor $ sudo systemctl restart tor -
Check if user has access to tor cookie file. Result should display 750 and 640
$ stat -c%a /var/lib/tor /var/lib/tor/control_auth_cookie -
Set a Tor control password (Must disable histroy for security purpose when creating password
$ sudo set +o history # unset bash history $ sudo tor --hashed-password <your password> $ sudo set -o history -
Add hashed password to torrec file
$ sudo nano /etc/tor/torrec HashedControlPassword <your hashed password> -
Open Tor Control Socket (Append to torrec file)
$ sudo nano /etc/tor/torre ControlSocket /var/lib/tor/control_socket ControlSocketsGroupWritable 1 DataDirectoryGroupReadable 1 CacheDirectoryGroupReadable 1 -
Restart tor and verify status of control socket. Test should return 750 and 660
$ sudo systemctl restart tor $ sudo stat -c%a /var/lib/tor /var/lib/tor/control_socket -
Testing tor control using netcat and socat
$ sudo pacman -S netcat socat $ echo -e 'PROTOCOLINFO\r\n' | nc 127.0.0.1 9051 $ echo -e 'PROTOCOLINFO\r\n' | sudo -u $USER socat - UNIX-CLIENT:/var/lib/tor/control_socket Result 250-PROTOCOLINFO 1 250-AUTH METHODS=COOKIE,SAFECOOKIE,HASHEDPASSWORD COOKIEFILE="/var/lib/tor/control_auth_cookie" 250-VERSION Tor="0.4.7.10" 250 OK 514 Authentication required. -
Installing Tor browser
$ sudo pacman -S torbrowser-launcher -
Launch torbrowser-launcher to configure and install tor browser
-
Enable autotitling windows in i3wm
$ sudo pacman -S autotiling python-i3ipc -
Install Clamav. Clamav is an opensource antivirus engine
$ sudo pacman -S clamav $ sudo freshclam $ sudo systemctl enable --now clamav-freshclam.service $ sudo systemctl enable --now clamav-daemon.service $ sudo pacman -S clamtk $ git clone https://github.com/dave-theunsub/thunar-sendto-clamtk.git $ cd thunar-sendto-clamtk $ cp thunar-sendto-clamtk.desktop ~/.local/share/Thunar/sendto/ -
Set the limit for memory and cpu for clamav. By default clamav loads its database to memory. Usually it occupies at least 1 GB RAM. So add the following lines to the service section in file
/usr/lib/systemd/system/clamav-daemon.serviceIOSchedulingPriority = 7 CPUSchedulingPolicy = 5 MemoryLimit=256M CPUQuota=10% Nice = 19 -
Samples
- Install Paru
$ git clone https://aur.archlinux.org/paru.git
$ cd paru
$ makepkg -si
- Install necessary packages for hyprland
paru -S hyprland-git polkit-kde-agent dunst grimblast rofi rofi-emoji wl-clipboard wf-recorder \ wlogout grimblast-git hyprpicker-git hyprpaper-git xdg-desktop-portal-hyprland-git \
ffmpegthumbnailer tumbler wtype colord imagemagick swaylock-effects qt5-wayland qt6-wayland \
ripgrep waybar-hyprland-git catppuccin-gtk-theme-mocha catppuccin-cursors-mocha \ catppuccin-mocha-grub-theme-git nwg-look cava pavucontrol ranger zsh starship neovim viewnior \ noise-suppression-for-voice thunar thunar-archive-plugin file-roller sddm-git
- Start hyprland at start
$ touch .autostart
$ nano .autostart
#!/bin/bash
sleep 1
killall xdg-desktop-portal-hyprland
killall xdg-desktop-portal-wlr
killall xdg-desktop-portal
/usr/libexec/xdg-desktop-portal-hyprland &
sleep 2
/usr/lib/xdg-desktop-portal &
- Enable sddm at start
# systemctl enable sddm.service

