Skip to content

Instantly share code, notes, and snippets.

@folliehiyuki
Last active February 2, 2023 10:06
Show Gist options
  • Save folliehiyuki/8fd8e88310c809b4b7452ec38e3eb53e to your computer and use it in GitHub Desktop.
Save folliehiyuki/8fd8e88310c809b4b7452ec38e3eb53e to your computer and use it in GitHub Desktop.
Notes for my Linux installation

Configurations

Kernel modules

# /etc/modprobe.d/blacklist.conf
blacklist radeon # nvidia, i915, depends on hardware specs
blacklist iTCO_wdt # who wants watchdog on desktop tbh? (except shutdown might not work properly xD)
blacklist iTCO_vendor_support # watchdog

Boot options

loglevel=4 apparmor=1 security=apparmor nmi_watchdog=0

Swap

  • swapfile: see ArchWiki for Btrfs notes

    # dd if=/dev/zero of=/swapfile bs=1M count=2048 status=progress
    # chmod 600 /swapfile
    # mkswap /swapfile
    # swapon /swapfile
    # echo "/swapfile none swap defaults 0 0" >> /etc/fstab
  • zram (see more here)

    # echo "options zram num_devices=2" > /etc/modprobe.d/zram.conf
    • systemd: see ArchWiki
    • openrc: see GentooWiki
    • runit:
      # /etc/runit/core-services/03-zram.sh
      
      # ensure zram is ready
      modprobe zram
      
      # set compression algorithm
      echo zstd > /sys/block/zram0/comp_algorithm
      echo zstd > /sys/block/zram1/comp_algorithm
      
      # set disksize
      echo 2G > /sys/block/zram0/disksize
      echo 2G > /sys/block/zram1/disksize
      
      # set memory limit
      echo 2G > /sys/block/zram0/mem_limit
      echo 2G > /sys/block/zram1/mem_limit
      
      # activate swaps
      mkswap --label zram0 /dev/zram0
      mkswap --label zram1 /dev/zram1
      
      # swapon
      swapon /dev/zram0
      swapon /dev/zram1
  • encrypted swap

Typical /etc/fstab

  • ext4: some programs (like pyenv, Doom Emacs, ...) need stuff to be executable in /tmp
UUID=...  /      ext4  rw,relatime             0  1
UUID=...  /home  ext4  rw,relatime             0  2
UUID=...  /media ext4  rw,relatime,nofail      0  2
tmpfs     /tmp   tmpfs rw,nosuid,nodev         0  0
tmpfs     /run   tmpfs rw,nosuid,nodev,noexec  0  0
  • btrfs: nested subvolumes for performance: @/var/cache/xbps, @/var/tmp, @/tmp, @/srv
# Separated subvolume for /var/log is nice for troubleshooting
UUID=...	/		        btrfs	rw,noatime,compress=zstd,ssd,space_cache,commit=120,subvol=@	        0 1
UUID=...	/home		    btrfs	rw,noatime,compress=zstd,ssd,space_cache,commit=120,subvol=@home	    0 2
UUID=...	/var/log	  btrfs	rw,noatime,compress=zstd,ssd,space_cache,commit=120,subvol=@log	      0 2
UUID=...	/.snapshots btrfs	rw,noatime,compress=zstd,ssd,space_cache,commit=120,subvol=@snapshots	0 2

UUID=...	/media		        btrfs	rw,noatime,compress=zstd,space_cache,autodefrag,commit=120,subvol=@media     0 2
UUID=...	/media/.snapshots	btrfs	rw,noatime,compress=zstd,space_cache,autodefrag,commit=120,subvol=@snapshots 0 2

# This is useful for disk overview
UUID=...	/mnt/defvol-root  btrfs rw,noatime,compress=zstd,ssd,space_cache,commit=120,subvol=/        0 2
UUID=...	/mnt/defvol-media btrfs rw,noatime,compress=zstd,space_cache,autodefrag,commit=120,subvol=/ 0 2

UUID=...	/boot		    vfat	rw,noatime,...					0 2
tmpfs     /tmp        tmpfs rw,nosuid,nodev         0 0
  • voidvault has a more detailed filesystem structures.

Btrfs maintenance

  • /etc/cron.weekly/btrfs-scrub (do the same with btrfs balance if using RAID)
#!/bin/sh

btrfs scrub start /

# Scrub 1 disk at a time
while btrfs scrub status / | grep running; do
	sleep 20
done

btrfs scrub start /media
  • /etc/cron.weekly/fstrim
#!/bin/sh

fstrim /
  • Use snapper for cron snapshots is a no-brainer
  • Use btrbk for incrementally sending snapshots

Dependencies (some distros don't ship them by default or mark them as optional)

  • vifm needs python3-dbus for mounting usb devices
  • ranger needs python3-Pillow and ImageMagick for ueberzug and kitty image preview methods
  • mpDris2 requires python3-mutagen for displaying music covers
  • luakit need gst-libav, gst-plugins-base, gst-plugins-good for video playbacks.
  • qutebrowser needs pdf.js (Void) / pdfjs (Arch) to open pdf files in the browser (enable c.content.pdfjs = True in config file)

Other notes

Small fixes for things

  • Alacritty might not display italic fonts correctly in terminal apps (eg. neovim). See #1977.
# Clone the alacritty repo
git clone https://github.com/alacritty/alacritty.git
cd alacritty/

# Re-compile the terminfo as normal user
tic -xe alacritty,alacritty-direct extra/alacritty.info

# Double check the result
infocmp alacritty
  • Libreoffice might hang on startup because of OpenCL. Run it the 1st time with SAL_DISABLE_OPENCL=1 libreoffice then go to Tools -> OpenCL to turn it off.

Some notes for Bedrock Linux

  • build all kernels' initramfs manually (since default hook will not be triggered) with dracut/mkinitcpio/... from the strata that installs grub/systemd-boot/... (for less headache)
  • things to be installed on each strata
    • same fonts
    • cursor themes (set /usr/share/icons/default/index.theme for each strata too)

Knowledge from other people

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