Skip to content

Instantly share code, notes, and snippets.

@txhammer68
Last active July 23, 2026 04:24
Show Gist options
  • Select an option

  • Save txhammer68/0ca6a6bef2823b7f37e65a33902ba667 to your computer and use it in GitHub Desktop.

Select an option

Save txhammer68/0ca6a6bef2823b7f37e65a33902ba667 to your computer and use it in GitHub Desktop.
Linux Optimizations

Useful tips for optimizing Linux CachyOs

For NVME SSD

For Linux systems using CachyOS and XFS, a 4K native (4Kn) NVMe sector size is generally superior to emulated 512-byte (512e) blocks. It reduces the overhead of firmware translation and aligns perfectly with the standard 4K filesystem blocks of XFS, which maximizes I/O bandwidth and minimizes latency.

  • Must perform this before installing/creating partitions/formatting w/ CachyOS installer

sudo pacman -S nvme-cli

  • Show options verify 4k blocks available
LBA Format  0 : Metadata Size: 0   bytes - Data Size: 512 bytes - Relative Performance: 0x1 Better (in use)
LBA Format  1 : Metadata Size: 0   bytes - Data Size: 4096 bytes - Relative Performance: 0 Best

sudo nvme format /dev/nvme0n1 --namespace-id=1 --lbaf=1

  • Crucial Step: Immediately reboot the live environment. If you do not reboot, the Linux kernel will preserve the old 512-byte structural layout in memory, and the installer will fail with partition errors.

  • nvme format (The Foundation): This tells the physical NVMe controller to change its internal grid system from 512-byte blocks to native 4K blocks. Once this finishes, the drive is completely blank—it has no partitions and no filesystem.

  • Install as usual

System Tuning

Before making changes to your system run these commands and take note of the info, then compare when finished
Check system log for errors or issues, try to resolve those first before proceeding
free -m
sudo hdparm -t --direct /dev/nvme0n1p2
systemd-analyze critical-chain
systemd-analyze --user blame

fstab

The fstab file configures the mounted drives/partitions Obtain UUID for each drive/partiton on system. ext4

lsblk -f

edit /etc/fstab

Root   UUID="" /               ext4    defaults,noatime,errors=remount-ro   0 1
Root   UUID="" /               xfs     defaults,noatime,logbsize=256k,noquota 0 0
Data   UUID="" /home/Data      ext4    defaults,noatime,errors=remount-ro   0 2
tmpfs         /tmp             tmpfs   defaults,rw,nosuid,nodev,size=50%,noatime,mode=1777 0 0
/swapfile     swap             swap    defaults   0 0
  • noatime - disable access time stamps

EXT4 options

Enable fast_commit journal option speed up FS writes

sudo tune2fs -O fast_commit /dev/nvme0n1p2
sudo tune2fs -O fast_commit /dev/sdc1

Verify

sudo tune2fs -l /dev/nvme0n1p2 | grep features

CPUFreqUtils Change CPU Governor and Frequencies

/etc/init.d/cpufrequtils

ENABLE="true"
GOVERNOR="performance"
MAX_SPEED="3600000"
MIN_SPEED="2000000"

Modprobe various driver settings

Disable power saving for audio device, remove pop sounds
Audio Device - create /etc/modprobe.d/audio.conf

options snd_hda_intel power_save=0 power_save_controller=N
vm.swappiness = 20
vm.vfs_cache_pressure = 50
vm.dirty_bytes = 268435456
vm.page-cluster = 1
vm.dirty_background_bytes = 67108864
vm.dirty_writeback_centisecs = 1500
kernel.nmi_watchdog = 0
kernel.printk = 3 3 3 3
net.core.netdev_max_backlog = 4096
fs.file-max = 2097152
net.ipv4.tcp_keepalive_time = 120
net.ipv4.tcp_keepalive_intvl=15
net.ipv4.tcp_keepalive_probes=4
net.ipv4.tcp_fastopen=3
net.core.default_qdisc=cake
net.ipv4.tcp_congestion_control=cubic
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv6.route.max_size = 16384
# Buffers scaled for 370 Mbps (approx 16MB - 32MB max)
net.core.rmem_max = 33554432
net.core.wmem_max = 33554432
net.core.rmem_default = 262144
net.core.wmem_default = 262144
# TCP Auto-Tuning Window (Min, Default, Max in bytes)
net.ipv4.tcp_rmem = 4096 87380 33554432
net.ipv4.tcp_wmem = 4096 65536 33554432
# Tweaks for Intel Gigabit NIC
net.ipv4.tcp_window_scaling = 1
net.core.netdev_max_backlog = 5000

Disable some uneeded system services

Disable ModemManager If you do not have a mobile broadband interface.

sudo systemctl disable ModemManager.service
sudo systemctl mask ModemManager.service

fwupd is a daemon allowing you to update some devices' firmware, including UEFI for several machines.
Remove fwupd from boot, newer hardware may want to leave this enabled for future updates...

sudo systemctl disable fwupd.service
sudo systemctl mask fwupd.service

GPU-Manager is software that creates a xorg.conf for you. So running this in every boot is just overkill. You only need to run this if you change your GPU.

sudo systemctl disable gpu-manager.service
sudo systemctl mask gpu-manager.service

Logical Volume Manager (LVM) is a device mapper framework that provides logical volume management.
Disable LVM

sudo systemctl disable lvm2-monitor.service
sudo systemctl mask lvm2-monitor.service

Disable Wait for Network online service, slows down boot

sudo systemctl disable NetworkManager-wait-online.service
sudo systemctl mask NetworkManager-wait-online.service

Disable plymouth boot spash, slows down boot; disable and mask

plymouth-halt.service
plymouth-kexec.service
plymouth-poweroff.service
plymouth-quit.service
plymouth-quit-wait.service
plymouth-read-write.service
plymouth-reboot.service
plymouth-start.service
plymouth-switch-root.service
plymouth-switch-root-initramfs.service

Minimize logging

  • journald logging
    Change log retention and logging settings, check logs first for errors
    /etc/systemd/journald.conf
MaxRetentionSec=3month
MaxFileSec=1month
MaxLevelStore=err
MaxLevelSyslog=err
MaxLevelKMsg=err
MaxLevelConsole=err
MaxLevelWall=emerg

Set fsck check interval

50 boot-ups or 1 month, change devices for your system

sudo tune2fs -c 50 -i 1m /dev/nvme0n1p2
sudo tune2fs -c 50 -i 1m /dev/sdb1

Fix volume resets

pactl get-sink-volume @DEFAULT_SINK@ pactl set-sink-volume @DEFAULT_SINK@ 65536

Used for HTPC connected to HDTV, when switching monitor outputs

/etc/pipewire/pipewire-pulse.conf.d/switch-on-connect.conf (or ~/.config/pipewire/pipewire-pulse.conf.d/switch-on-connect.conf)

override for pipewire-pulse.conf file

pulse.cmd = [
    { cmd = "load-module" args = "module-always-sink" flags = [ ] }
    { cmd = "load-module" args = "module-switch-on-connect" }
]

Better PipeWire Settings

mkdir -p ~/.config/pipewire/
cp /usr/share/pipewire/pipewire-pulse.conf ~/.config/pipewire/
nano ~/.config/pipewire/pipewire-pulse.conf

monitor.alsa.properties = {
    # Block WirePlumber from triggering node suspension during quiet periods
    session.suspend-on-idle = false
}

pulse.properties = {
    # Force high-quality SOXR resampling instead of low-CPU draft methods
    resample.quality      = 10
    
    # Lock in optimal bit-depth overhead
    default.sample.format = float32le
    
    # Establish strict, stutter-free real-time audio scheduling limits
    pulse.min.req         = 128/48000     # 2.6ms minimum buffer request
    pulse.min.quantum     = 128/48000     # 2.6ms minimum hardware slice
}
context.properties = {
    default.clock.rate=48000
    # Allow automatic switching to high-fidelity integer multiples if needed
    default.clock.allowed-rates = [ 44100 48000 96000 ]

    # Set the ideal default hardware processing slice (5.3ms latency)
    default.clock.quantum       = 256
    default.clock.min-quantum   = 128
    default.clock.max-quantum   = 1024
}

Networking

systemd-resolved

systemd-resolved provides a system-level DNS cache that can substantially improve performance for applications that do not cache their own DNS results. DNS queries and responses have traditionally been unencrypted, but more and more resolvers now support DNS over an encrypted TLS connection (DNS over TLS.) TLS can help ensure that no parties between the DNS server and the resolver can see or modify the DNS responses.

CTRL Blog
Linux Insider
Blog
Check Status

resolvectl status

Edit /etc/systemd/resolved.conf
Add, change DNS to your preferred DNS server

DNS=1.1.1.1 2606:4700:4700::1111
FallbackDNS=8.8.8.8 2001:4860:4860::8888
Domains=~.
DNSSEC=allow-downgrade
DNSOverTLS=yes
Cache=yes

Change Network Manager
/etc/NetworkManager/NetworkManager.conf

[main]
dns=systemd-resolved

Edit /etc/gai.conf Uncomment line for sites which prefer IPv4

precedence ::ffff:0:0/96  100
systemctl restart NetworkManager systemd-resolved

if not running then

systemctl enable systemd-resolved.service
systemctl start systemd-resolved.service

Verify Status
Test cli tc -s qdisc show dev enp0s31f6

resolvectl status

Some useful sites to verify internet security connection
No firewall needed as most of us are behind an ISP router that has a built in firewall
Test your connection
IP Leak Test
Cloudfare Test

systemd-boot and Unified Kernel Images

  • Replace grub, speeds up boot time, this is the future of Linux startup

  • A Unified Kernel Image (UKI) is a combination of a UEFI boot stub program, a Linux kernel image, an initramfs, and further resources in a single UEFI PE file (device tree, cpu µcode, splash screen, secure boot sig/key, ...). This file can either be directly invoked by the UEFI firmware or through a boot loader.

  • systemd-boot loader - grub replacement

  • UKI

  • different script using kernel cmdline options

    Create /etc/kernel/install.conf

    layout=uki
    uki_generator=ukify
    BOOT_ROOT=/boot/efi
    

    Create /etc/kernel/uki.conf

    Cmdline=@/etc/kernel/cmdline
    OSRelease=@/etc/os-release
    Splash=/boot/bootSplash.bmp
    

    edit /etc/kernel/cmdline
    Check /etc/default/grub for boot options of your system, add them here to cmdline

quiet mitigations=off raid=noautodetect nowatchdog nosgx preempt=full i915.mitigations=off i915.enable_guc=3 i915.enable_psr=0 loglevel=3 rd.udev.log-priority=3 udev.log_priority=3 vt.global_cursor_default=0 plymouth.enable=0 disablehooks=plymouth systemd.show_status=no bgrt_disable zswap.enabled=0 systemd.zram=0 rw root=UUID=
  • preempt=full A fully-preemptible kernel is most suitable for low-latency workloads - such as gaming, live-streaming, multimedia, etc.
  • nowatchdog

edit /etc/mkinitcpio.d add boot splash image

default_uki="/boot/EFI/Linux/cachyos-linux.efi"
default_options="--splash /boot/bootSplash.bmp"
fallback_uki="/boot/EFI/Linux/arch-linux-cachyos-fallback.efi"
  • Run when finished w/ UKI setup sudo mkinitcpio -P
  • Reboot verify UKI loading
  • Remove GRUB
  • Reboot again, verify steps at beginning to see the difference in boot times, free memory, drive speeds

Other Misc

Firefox Extensions

Firefox Config options

Disable Qt Logging, add to /etc/environment or .bashrc

QT_LOGGING_RULES="*.debug=false;qt*.debug=false;qt5.debug=false;*.warning=false;*.critical=false;qt.qpa.xcb.xcberror.warning=false;qt.qpa.xcb.xcberror.error=false;qt.qpa.xcb.warning=false;qt.qpa.xcb.error=false;qt.qpa.xcb=false"

Allow xmlrequest for loading json files
Add to /etc/environment or .bashrc
QML_XHR_ALLOW_FILE_READ="1"
kdebugdialog5 - kde debugging settings
Remove extra fonts, check Noto Sans/Serif extra language fonts, unnecessary for most cases
Run this after, clean font cache
fc-cache -f -v

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