Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Latest commit

 

History

History
682 lines (448 loc) · 15.7 KB

README.md

File metadata and controls

682 lines (448 loc) · 15.7 KB

Arch Linux on Razer Book 13 (RZ09-0357) in Hyprland

These are my personal notes setting up Razer Book 13 with Arch Linux using Hyprland as window manager. Iam using full disk encryption, and btrfs as filesystem.

Main usage is for Kubernetes/Virtualization/DevOps Stuff and some gaming. Configs for localisations are for german, so adjust for your needs.

A big THANK to SOL for getting me into hyprland. Most of the Hyprland config is from his repo. Kudos!

desk

[TOC]

Basic Install

Prepare and Booting ISO

Boot into BIOS and change your Harwareclock to UTC. Now booting Arch Linux, using a prepared Usbstick

Change Keyboard and Font

Change keyboard layout with loadkeys de-latin1-nodeadkeys

I also change the font to much bigger size to be better readable on this 13" screen with setfont sun12x22

Networking

For Network i use wireless, if you need wired please check the Arch WiKi.

Launch iwctl and connect to your AP station wlan0 connect YOURSSID Type exit to leave.

Update System clock with timedatectl set-ntp true

Format Disk

  • My Disk is nvme0n1, check with lsblk

  • Partition disk using gdisk /dev/nvme0n1 with this simple layout:

  • o for new partition table

  • n,1,<ENTER>,+1024M,ef00 for EFI Boot

  • n,2,<ENTER>,+16384M,8200 for swap partition

  • n,3,<ENTER>,<ENTER>,8300 for system partition

  • w to save layout

Format the EFI Partition

mkfs.vfat -F 32 /dev/nvme0n1p1

Create encrypted filesystem

cryptsetup luksFormat /dev/nvme0n1p3
cryptsetup open /dev/nvme0n1p3 cryptsys

Create and Mount btrfs Subvolumes

Create btrfs filesystem for root partition. mkfs.btrfs -f /dev/mapper/cryptsys

Mount Partitions und create Subvol for btrfs.

mount /dev/mapper/cryptsys /mnt
btrfs sub create /mnt/@
btrfs sub create /mnt/@home

Remount with btrfs subvols

Just unmount with umount /mnt and remount with subvolumes:

mount -o noatime,compress=zstd,commit=120,ssd,discard=async,subvol=@ /dev/mapper/cryptsys /mnt
mkdir -p /mnt/boot
mkdir -p /mnt/home
mount -o noatime,compress=zstd,commit=120,ssd,discard=async,subvol=@home /dev/mapper/cryptsys /mnt/home
mount /dev/nvme0n1p1 /mnt/boot/

Check mountmoints with df -Th

Install the base system

Just install a base system with some tools for first boot:

pacstrap /mnt base base-devel linux linux-firmware btrfs-progs \
  intel-ucode networkmanager zsh git git-lfs curl wget reflector nano-syntax-highlighting

After this, generate the filesystem table using genfstab -p /mnt >> /mnt/etc/fstab

Add some zsh configs for a nicer experience

cp /etc/zsh/zprofile /mnt/root/.zprofile && \
cp /etc/zsh/zshrc /mnt/root/.zshrc

Chroot into the new system and create initial settings

arch-chroot /mnt /bin/zsh
echo {MYHOSTNAME} > /etc/hostname
echo LANG=de_DE.UTF-8 > /etc/locale.conf
echo LANGUAGE=de_DE >> /etc/locale.conf
echo KEYMAP=de-latin1-nodeadkeys > /etc/vconsole.conf
echo FONT=sun12x22 >> /etc/vconsole.conf
ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime

Modify nano /etc/hosts with these entries. For static IPs, remove 127.0.1.1

127.0.0.1 localhost
::1 localhost
127.0.1.1 {MYHOSTNAME}.localdomain {MYHOSTNAME}

nano /etc/locale.gen to uncomment the following lines. Change it to your locale and keep en_US cause some tools may need it.

de_DE.UTF-8 UTF-8
de_DE ISO-8859-1
de_DE@euro ISO-8859-15
en_US.UTF-8

Execute locale-gen to create the locales now

Set root password and shell

passwd && \
chsh -s /bin/zsh

Add hooks to initramfs

Edit the configuration with nano /etc/mkinitcpio.conf and add i915 to the MODULES section.

I use systemd init style, so add sd-vconsole and sd-encrypt to hooks between block/filesystems like:

HOOKS="base systemd keyboard autodetect modconf kms block sd-vconsole sd-encrypt filesystems fsck"

create Initramfs using mkinitcpio -p linux

Install Systemd Bootloader

bootctl --path=/boot install installs bootloader

nano /boot/loader/loader.conf delete anything and add these few lines and save

default arch.conf
timeout 1
editor 0

nano /boot/loader/entries/arch.conf with these lines and save.

title Arch Linux
linux /vmlinuz-linux
initrd /intel-ucode.img
initrd /initramfs-linux.img

Append boot options with this command:

echo "options rd.luks.name=$(blkid -s UUID -o value /dev/nvme0n1p3)=cryptsys \
  rd.luks.options=password-echo=no root=/dev/mapper/cryptsys \
  rootflags=subvol=@ rw" >> /boot/loader/entries/arch.conf

Add Swap Partition

I dont use suspend-to-disk, so i add the swap partition to crypttab und add the swap entry to fstab. To /etc/crypttab add this line

cryptswap  /dev/nvme0n1p2  /dev/urandom  swap,cipher=aes-xts-plain64,size=256

And in /etc/fstab add to end of file

/dev/mapper/cryptswap  none  swap  defaults  0 0

Update Mirrorlist

reflector --country 'Germany' --latest 10 --sort score --protocol https --save /etc/pacman.d/mirrorlist

Leave Chroot and Reboot

Type exit to exit chroot

umount -R /mnt/ to unmount all volumes

Now its time to reboot into the new system!

After first Reboot

Enable Wireless Network using NetworkManager

Enable networkmanager on boot

systemctl enable --now NetworkManager
nmcli device wifi connect "{YOURSSID}" password "{SSIDPASSWORD}"

WLAN Powersave

I want to disable all kind of WLAN powersaving, cause i had issues

For NetworkManager

# /etc/NetworkManager/conf.d/wifi-powersave-off.conf
[connection]
wifi.powersave = 2

And also for kernel module

# /etc/modprobe.d/iwlwifi.conf
options iwlwifi power_save=0
options iwlwifi uapsd_disable=0
options iwlmvm power_scheme=1

Enable NTP Timeservice

systemctl enable --now systemd-timesyncd

(You may look at /etc/systemd/timesyncd.conf for default values and change if necessary)

Create a new user

Create a new local user and point to zsh

useradd -m -g users -G wheel,lp,power,audio -s /bin/zsh {MYUSERNAME}
passwd {MYUSERNAME}

Execute EDITOR=nano visudo and uncomment %wheel ALL=(ALL) ALL

Now exit and relogin with the new {MYUSERNAME}

Add syntax highlighting to nano

Change to your homedirectory and

mkdir -p .config/nano
cp /etc/nanorc ~/.config/nano/nanorc

Edit nanorc and add this line

include "/usr/share/nano-syntax-highlighting/*.nanorc"

Fix a bug in the 2020.10.10-1 realease of the package with

sed -i 's/icolor brightnormal/icolor normal/g' /usr/share/nano-syntax-highlighting/nanorc.nanorc

Prevent debug packages to build

In /etc/makepkg.conf search the line for OPTIONS=(strip .... and change debug to !debug

Install Desktop Environment

YAY

I want to use YAY for managing packets

git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si --noconfirm

Add some color tweaks to pacman, add this to /etc/pacman.conf misc options

colors
ILoveCandy

Hyprland and other Tools

This tools, i found usefull, will be installed:

  • hyprland: this is the compositor

  • alacritty: my default terminal

  • waybar: wayland bar with hyprland support

  • firefox-developer-edition: my default browser

  • swww: used to set a desktop background image

  • swaylock-effects: allows for the locking of the desktop its a fork that adds some editional visual effects

  • wofi: application launcher menu

  • mako: graphical notification daemon

  • xdg-desktop-portal-hyprland: xdg-desktop-portal backend for hyprland

  • thunar: graphical file manager

  • mc: midnight commander, a terminal file manager

  • polkit-gnome: to get superuser access on some graphical application

  • brightnessctl: control monitor and keyboard bright level

  • bluez: bluetooth service

  • bluez-utils: command line utilities to interact with bluettoth devices

  • blueman: bluetooth manager

  • network-manager-applet: managing network connection

  • gvfs: automount usb drives, etc

  • thunar-archive-plugin: front ent for thunar to work with compressed files

  • file-roller: tools for working with compressed files

  • btop: terminal resource monitor

  • pacman-contrib: adds additional tools for pacman. needed for showing system updates in the waybar

  • xsensors: GTK app for hardware temperature

  • gnome-power-manager: app for power management

  • ttf-jetbrains-mono-nerd: the main font

  • noto-fonts-emoji: emoji fonts

  • cantarell-fonts: nice fonts

  • ttf-dejavu: also nice fonts

  • lxappearance: set GTK theme

  • xfce4-settings: needed to set GTK theme

  • pipewire: audio server

  • sof-firmware, alsa-firmware and alsa-ucm-settings are needed for this Razer Book

yay -Sy hyprland alacritty waybar firefox-developer-edition-i18n-de \
  swww swaylock-effects wofi mako xdg-desktop-portal-hyprland \
  brightnessctl mc thunar polkit-gnome pipewire-alsa pipewire-jack xsensors \
  bluez bluez-utils blueman network-manager-applet gvfs gnome-power-manager \
  thunar-archive-plugin file-roller btop pacman-contrib power-profiles-daemon \
  ttf-jetbrains-mono-nerd noto-fonts-emoji cantarell-fonts ttf-dejavu \
  lxappearance xfce4-settings sof-firmware alsa-firmware alsa-ucm-conf

Enable bluetooth and remove some might installed desktop portals

sudo systemctl enable bluetooth
yay -R --noconfirm xdg-desktop-portal-gnome xdg-desktop-portal-gtk

Enable Wayland for Firefox

#/etc/environment

MOZ_ENABLE_WAYLAND=1

Theming

Copy the dotfiles to their locations and edit them as needed..

Apply a system-wide dark theme and statusbar/launcher based on Catppuccin (mocha)

ln -sf ~/.config/waybar/style/style-dark.css ~/.config/waybar/style.css
ln -sf ~/.config/wofi/style/style-dark.css ~/.config/wofi/style.css
xfconf-query -c xsettings -p /Net/ThemeName -s "Adwaita-dark"
xfconf-query -c xsettings -p /Net/IconThemeName -s "Adwaita-dark"
gsettings set org.gnome.desktop.interface gtk-theme "Adwaita-dark"
gsettings set org.gnome.desktop.interface icon-theme "Adwaita-dark"
gsettings set org.gnome.desktop.interface color-scheme "prefer-dark"

Oh-My-ZSH

I like to use oh-my-zsh with powerlevel10k theme

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

See example zshrc config in my repo

Install Screnshot Tools

For screenshots i use the swappy

sudo pacman -Sy grim slurp jq otf-font-awesome swappy

DevOps Tools

Apps and tools i use for devops tasks

VS Code

Iam using VSCode binary and install it from AUR using

yay -S visual-studio-code-bin

Python, Ansible and Terraform

I use pyenv to switch between python versions and pip for installing ansible.

Add export PATH=$HOME/.local/bin/:$PATH to the PATH variable in .zshrc

sudo pacman -Sy pyenv terraform

Add this to .zshrc

if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi

List avaiable version using pyenv install --list and install the desired version with

pyenv install 3.9.16
pyenv global 3.9.16

Install Ansible using pip

python -m pip install --upgrade pip
python -m pip install --user ansible ansible-lint

Virtualization using QEMU and Libvirt

I go for QEMU/KVM as my hypervisor

sudo pacman -S qemu virt-manager virt-viewer dnsmasq vde2 \
  bridge-utils openbsd-netcat libguestfs dmidecode

sudo systemctl enable --now libvirtd

Enable normal user access by editing /etc/libvirt/libvirtd.conf and enable this lines:

unix_sock_group = "libvirt"
unix_sock_rw_perms = "0770"

Add your user to the group libvirt

sudo usermod -a -G libvirt $(whoami)

Enable nested virtualization

echo "options kvm-intel nested=1" | sudo tee /etc/modprobe.d/kvm-intel.conf

Kubernetes

Minikube and stuff

 sudo pacman -S minikube kubectl helm go k9s kubeone

Set kvm2 as default driver for minikube

minikube config set driver kvm2

For Openlens use the repo from AUR

yay -S openlens-bin

For k8s configs i use context switching (each config is in its own directory to keep it clean) and set some code in my zshrc:

## Kubectl Context Config
# Set the default kube context if present
DEFAULT_KUBE_CONTEXTS="$HOME/.kube/config"
if test -f "${DEFAULT_KUBE_CONTEXTS}"
then
  export KUBECONFIG="$DEFAULT_KUBE_CONTEXTS"
fi
# Additional contexts should be in ~/.kube/configs/XXXX-XXX-XX/xxx.yml/pem/..
KUBE_CONTEXTS="$HOME/.kube/configs"
mkdir -p "${KUBE_CONTEXTS}"

OIFS="$IFS"
IFS=$'\n'
for contextFile in `find "${KUBE_CONTEXTS}" -type f -name "*.yml" -or -name "*.json"`
do
    export KUBECONFIG="$contextFile:$KUBECONFIG"
done
IFS="$OIFS"

Tweaks

Autologin

Create a directory named [email protected]/ inside the systemd system unit files directory like:

sudo mkdir -p /etc/systemd/system/[email protected]/

Create a file in this folder called override.conf with the following content:

# /etc/systemd/system/[email protected]/override.conf

[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --autologin {MYUSERNAME} --noclear %I $TERM

Now reload systemd and enable getty@tty1 like:

sudo systemctl daemon-reload
sudo systemctl enable getty@tty1

To my zshrc i add theese lines at the end to autostart the hyprland desktop (script in my dotfiles):

if [ -z $DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
  exec Hyprland
fi

After reboot you will be booted straight into hyprland desktop

Keyboard Lightning

Install openrazer driver and polychromatic frontend from AUR

yay -Sy openrazer-meta
sudo gpasswd -a $USER plugdev

yay -Sy polychromatic.git

WIP: Yubikey

Using FIDO 2 (Yubikey) with luks partition and systemd

I would also like to use yubikey to unlock the luks partition. Install the needed FIDO lib and add yubikey to luks partition headers

sudo pacman -Sy libfido2

systemd-cryptenroll --fido2-device=auto /dev/nvme0n1p3

Now edit this line to cryptab:

cryptsys /dev/nvme0n1p3 - fido2-device=auto

Change kernel boot parameters to use fido2. Edit /boot/loader/entries/arch.conf and edit the rd.luks.options to:

options .. rd.luks.options=fido2-device=auto root=..

Now after reboot, yubikey is required to unluck luks partion

Gaming

Enable 32-Bit Lib

Comment out [multilib] section in /etc/pacman.conf

[multilib]
Include = /etc/pacman.d/mirrorlist

Install Vulkan Driver and Libs

sudo pacman -Sy lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-loader \
  lib32-vulkan-icd-loader lib32-systemd ttf-liberation

Reboot your book and start installing the steam client

Steam Client

Install the client from arh repos using

sudo pacman -Sy steam

Many Games just runs, few of them needs special launch parameters. The Arch Linux Wiki is good place to start.

Some games come bundled with old versions of SDL, which do not support Wayland and might break entirely if you set SDL_VIDEODRIVER=wayland which you normaly do under:

Go to the Game, Properties and Launch options:

SDL_VIDEODRIVER=wayland %command%

You can also set it via terminal in your current session with:

set -x SDL_VIDEODRIVER 'wayland'

This way, SDL_VIDEODRIVER can also set to x11