ThinkPad L13 Yoga Arch Linux with Hibernation, ZRAM and PipeWire

-YouTube Walk-thru Video-

In a previous post, we discussed how to get Arch Linux installed on the 2020 ThinkPad L13 Yoga. It works well enough, but let's see if we can introduce some additional performance optimizations in the form of a "zram plus swap partition hybrid configuration" and also migrate the base installation to PipeWire for improved, low latency handling of audio and video. The following steps demonstrate one way to make this possible with a choice of Cinnamon, KDE, and Gnome desktops - as always, you are encouraged to experiment!

  1Substitute $HOSTNAME and $USER for your hostname and username respectively
  2
  3timedatectl set-ntp true
  4reflector --country US --age 6 --protocol https --latest 5 --sort rate --save /etc/pacman.d/mirrorlist
  5pacman -Syy
  6
  7gdisk for 3 partitions: 300M EFI, RAM+1GB for swap hibernate, rest Arch (zram hybrid config)
  8
  9[adjust according to your installation target drive device e.g /dev/sda etc]
 10mkfs.vfat /dev/nvme0n1p1
 11mkswap /dev/nvme0n1p2
 12swapon /dev/nvme0n1p2
 13mkfs.btrfs -L arch /dev/nvme0n1p3
 14mount /dev/nvme0n1p3 /mnt
 15cd /mnt
 16
 17btrfs subvolume create @
 18btrfs subvolume create @home
 19btrfs subvolume create @var
 20btrfs subvolume create @data
 21cd
 22umount /mnt
 23
 24mount -o noatime,compress=zstd,space_cache,discard=async,subvol=@ /dev/nvme0n1p3 /mnt
 25mkdir -p /mnt/{boot/efi,home,var,data}
 26mount -o noatime,compress=zstd,space_cache,discard=async,subvol=@home /dev/nvme0n1p3 /mnt/home
 27mount -o noatime,compress=zstd,space_cache,discard=async,subvol=@var /dev/nvme0n1p3 /mnt/var
 28mount -o noatime,compress=zstd,space_cache,discard=async,subvol=@data /dev/nvme0n1p3 /mnt/data
 29mount /dev/nvme0n1p1 /mnt/boot/efi
 30
 31pacstrap /mnt base base-devel linux-lts linux-firmware intel-ucode sysfsutils btrfs-progs cryptsetup device-mapper dhcpcd dialog e2fsprogs grml-zsh-config grub gptfdisk less lvm2 mkinitcpio nano neofetch netctl nvme-cli os-prober vim zsh
 32
 33genfstab -U /mnt >> /mnt/etc/fstab
 34arch-chroot /mnt
 35
 36nano /etc/fstab and add pri=10 to the swap options since zram needs to have higher priority
 37
 38ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
 39hwclock --systohc
 40sed -i 's/#en_US.UTF-8/en_US.UTF-8/' /etc/locale.gen && locale-gen
 41echo "LANG=en_US.UTF-8" >> /etc/locale.conf
 42echo "$HOSTNAME" >> /etc/hostname
 43echo "127.0.0.1 localhost" >> /etc/hosts
 44echo "::1       localhost" >> /etc/hosts
 45echo "127.0.1.1 $HOSTNAME.localdomain $HOSTNAME" >> /etc/hosts
 46passwd
 47
 48pacman -S grub efibootmgr networkmanager network-manager-applet networkmanager-openvpn wpa_supplicant mtools dialog dosfstools reflector linux-lts-headers avahi xdg-user-dirs xdg-utils gvfs gvfs-smb nfs-utils inetutils dnsutils bluez bluez-utils cups hplip system-config-printer foomatic-db foomatic-db-engine gutenprint simple-scan cups-pdf cups-filters cups-pk-helper ghostscript gsfonts python-pillow python-pyqt5 python-pip python-reportlab alsa-utils pipewire pipewire-alsa pipewire-pulse pipewire-jack bash-completion openssh rsync reflector htop acpi tlp virt-manager qemu qemu-arch-extra edk2-ovmf bridge-utils dnsmasq vde2 openbsd-netcat iptables-nft ipset flatpak sof-firmware nss-mdns acpid os-prober ntfs-3g git
 49
 50grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ArchLinux
 51after adding resume partition to parameters in /etc/default/grub ("resume="):
 52grub-mkconfig -o /boot/grub/grub.cfg
 53
 54systemctl enable acpid
 55systemctl enable avahi-daemon
 56systemctl enable bluetooth
 57systemctl enable cups.service
 58systemctl enable fstrim.timer
 59systemctl enable libvirtd
 60systemctl enable NetworkManager
 61systemctl enable reflector.timer
 62systemctl enable sshd
 63systemctl enable tlp
 64
 65nano /etc/bluetooth/main.conf
 66    under [Policy] AutoEnable=true
 67
 68useradd -mU -s /bin/zsh -G sys,log,network,floppy,scanner,power,rfkill,users,video,storage,optical,lp,audio,wheel,adm,libvirt $USER
 69
 70passwd $USER
 71
 72EDITOR=nano visudo
 73    uncomment %wheel ALL=(ALL) ALL
 74
 75nano /etc/mkinitcpio.conf and add "i915" to MODULES, "resume" to HOOKS list
 76mkinitcpio -p linux-lts
 77
 78cd /etc/xdg/reflector
 79mv reflector.conf reflector.conf.orig
 80nano reflector.conf
 81--country US
 82--age 6
 83--protocol https
 84--latest 5
 85--sort rate
 86--save /etc/pacman.d/mirrorlist
 87
 88systemctl enable reflector.service
 89
 90mkdir /etc/pacman.d/hooks
 91nano /etc/pacman.d/hooks/50-bootbackup.hook
 92
 93[Trigger]
 94Operation = Upgrade
 95Operation = Install
 96Operation = Remove
 97Type = Path
 98Target = usr/lib/modules/*/vmlinuz
 99
100[Action]
101Depends = rsync
102Description = Backing up /boot...
103When = PreTransaction
104Exec = /usr/bin/rsync -a --delete /boot /boot-backup
105
106exit
107umount -a
108reboot
109
110[Use nmtui as root to get networking running again if needed, ssh back in as your *regular* $USER and carry on]
111
112git clone https://aur.archlinux.org/yay
113cd yay
114makepkg -si PKGBUILD
115cd ..
116rm -fr yay
117
118yay -S zramd
119sudo systemctl enable --now zramd.service
120free -h to check if all the memory is available
121
122sudo pacman -S xorg xorg-apps xorg-server xorg-drivers xorg-xkill xorg-xinit xterm mesa
123sudo pacman -R xf86-video-intel xf86-input-synaptics [keep the synaptics package if you have the actual hardware]
124
125[Choose from the following desktops:]
126
127[CINNAMON Desktop]
128
129sudo pacman -S cinnamon cinnamon-translations blueberry gnome-terminal firefox thunderbird adwaita-icon-theme adapta-gtk-theme arc-gtk-theme arc-icon-theme papirus-icon-theme gtk-engine-murrine gnome-keyring nemo nemo-share xed file-roller nemo-fileroller tmux tldr transmission-gtk brasero asunder quodlibet gnome-disk-utility polkit-gnome gnome-packagekit evince viewnior lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice dconf-editor metacity ttf-bitstream-vera ttf-dejavu ttf-droid gnu-free-fonts ttf-liberation ttf-linux-libertine noto-fonts ttf-roboto ttf-ubuntu-font-family ttf-cascadia-code ttf-hack ttf-inconsolata ttf-jetbrains-mono adobe-source-code-pro-fonts cantarell-fonts ttf-opensans noto-fonts-emoji libva-utils intel-media-driver
130
131sudo systemctl enable lightdm.service
132sudo nano /etc/lightdm/lightdm.conf and enable logind-check-graphical=true
133[END CINNAMON]
134
135[GNOME Desktop]
136sudo pacman -S gdm gnome gnome-extra gnome-builder gnome-shell-extensions dconf-editor firefox thunderbird transmission-gtk gnome-tweaks arc-gtk-theme arc-icon-theme adapta-gtk-theme adwaita-icon-theme materia-gtk-theme gnome-icon-theme papirus-icon-theme gtk-engine-murrine gnome-keyring vlc celluloid ttf-bitstream-vera ttf-dejavu ttf-droid gnu-free-fonts ttf-liberation ttf-linux-libertine noto-fonts ttf-roboto ttf-ubuntu-font-family ttf-cascadia-code ttf-hack ttf-inconsolata ttf-jetbrains-mono adobe-source-code-pro-fonts cantarell-fonts ttf-opensans noto-fonts-emoji libva-utils intel-media-driver
137
138sudo systemctl enable gdm
139[END GNOME]
140
141[KDE Desktop]
142sudo pacman -S plasma firefox thunderbird breeze-icons kwrite qbittorrent pavucontrol-qt quodlibet print-manager sweeper dolphin k3b ark konsole gwenview okular kcalc packagekit-qt5 discover cryfs encfs gocryptfs sddm sddm-kcm ttf-bitstream-vera ttf-dejavu ttf-droid gnu-free-fonts ttf-liberation ttf-linux-libertine noto-fonts ttf-roboto ttf-ubuntu-font-family ttf-cascadia-code ttf-hack ttf-inconsolata ttf-jetbrains-mono adobe-source-code-pro-fonts cantarell-fonts ttf-opensans noto-fonts-emoji libva-utils intel-media-driver
143
144sudo systemctl enable sddm
145[END KDE]
146
147sudo flatpak install -y kdenlive
148[put the rest of your flatpaks here]
149
150
151yay -S timeshift-bin timeshift-autosnap
152yay -S ttf-ms-fonts pamac-all gufw tlpui
153
154sudo pacman -S acpi_call-dkms xf86-input-wacom
155sudo pacman -S iio-sensor-proxy
156[for non-Wayland only: yay -S screenrotator-git ]
157
158su -
159ufw default deny
160ufw allow from 10.1.10.0/24 [change according to your own local network]
161ufw allow Transmission
162ufw limit ssh
163ufw enable
164
165[DONE, ready to reboot]