Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ansulev/96ba95ddebb2fa4fd96bb2fe702b38f1 to your computer and use it in GitHub Desktop.
Save ansulev/96ba95ddebb2fa4fd96bb2fe702b38f1 to your computer and use it in GitHub Desktop.
Set of optimizations, I use on my Artix Setup

Everything here is written according to runit in mind, please modify it according to your init(openrc/s6).

Index

1. Selecting the correct init

To select the correct init you should have the knowledge of different init's but if you don't, it might be a problem. But to get you a starting point here are some arrangements that I made.

Speed of Booting

s6-rc » openrc ≊ runit

Simplicity Of

Usage

runit ≥ openrc > s6-rc

Code

runit > openrc ≊ s6-rc

Ram Usage

runit = openrc » s6-rc
Note: Runit busybox is the more efficient than standard one.

Features

s6-rc ≥ openrc » runit

To summarize, every init has its own features and is designed for specific use cases, so you can choose one according to your preference. I am a simple man that's why I selected runit.

2. rEFInd

You can refind instead of grub. Refind has some features that my entice you like its is simpler to use, its more adaptive, its a eye candy, it supports Bios mode, and its faster. Not good for XFS users.

sudo pacman -S refind
sudo refind-install --usedefault /dev/sda

You can go here to know how to configure it and add pacman hooks to modify things according to it.

3. Silent GRUB

If you prefer grub then there are some optimisations you can try.
To hide all the grub output which is displayed during boot.
Copy these parameters to GRUB_CMDLINE_LINUX_DEFAULT, then update the grub

loglevel=0 console=tty2 udev.log_level=0 vt.global_cursor_default==0

But still, there are some messages that can be hidden like "Welcome to GRUB!" which can be removed by this. Also, you can hide booting messages by going to

sudo nano /boot/grub/grub.cfg

And here you can remove all the echo messages. This provides a clean-looking boot, which I prefer.

4. Turn off Mitigations

You can turn off CPU mitigations for the highest performance, but least security. If you run a lot of unknown code, then you should skip this. To learn how this affects your pc, go here. To know what kind of vulnerability might arise, you can go here
To enable this, add this to GRUB_CMDLINE_LINUX_DEFAULT, then update the grub

mitigations=off

5. Disable Watchdog

Watchdog is used to monitor if a system is running. It is supposed to automatically reboot hanged systems due to unrecoverable software errors. Personal computer users don’t need a watchdog, as they can reset the system manually. You can learn more about this from here
To enable this, add this to GRUB_CMDLINE_LINUX_DEFAULT, then update the grub

nowatchdog

6. Kernel Parameters

These are some kernel parameters that boost my computer, most of them optimizations are from Clear Linux. These basically disables some checks on boot time, making it faster.

intel_idle.max_cstate=1 cryptomgr.notests initcall_debug intel_iommu=igfx_off no_timer_check noreplace-smp page_alloc.shuffle=1 rcupdate.rcu_expedited=1 tsc=reliable

This is what my GRUB looks like after adding the parameters

#
# Configuration file for GRUB.
#
GRUB_DEFAULT=0
GRUB_TIMEOUT=0
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=0 console=tty2 udev.log_level=0 vt.global_cursor_default=0 mitigations=off nowatchdog msr.allow_writes=on pcie_aspm=force module.sig_unenforce intel_idle.max_cstate=1 cryptomgr.notests initcall_debug intel_iommu=igfx_off no_timer_check noreplace-smp page_alloc.shuffle=1 rcupdate.rcu_expedited=1 tsc=reliable resume=UUID=b6063c20-d091-4334-8726-55e0ee6b0aed"
GRUB_DISABLE_OS_PROBER=true
GRUB_DISABLE_RECOVERY=true
GRUB_DISABLE_SUBMENU=true

7. Remove Artix logo during boot

After hiding the grub, you would notice that the Artix logo is still being displayed. If you want to remove it you can do this.

sudo rm /etc/issue

8. Adding Arch and third party repos

Since everyone here has come from some other systemd distro and has used arch at the some point. And we know arch has huge set of software packages so you can add arch repo into artix by

sudo pacman -S artix-archlinux-support
sudo pacman-key --populate archlinux
sudo nano /etc/pacman.conf
#[testing]
#Include = /etc/pacman.d/mirrorlist-arch

[extra]
Include = /etc/pacman.d/mirrorlist-arch

#[community-testing]
#Include = /etc/pacman.d/mirrorlist-arch

[community]
Include = /etc/pacman.d/mirrorlist-arch

#[multilib-testing]
#Include = /etc/pacman.d/mirrorlist-arch

#[multilib]
#Include = /etc/pacman.d/mirrorlist-arch

Adding third party repos helps out a lot, if you don't have a lot of stupid time building your own apps or a patato for a pc then you can add third party repos where people have build these apps. Now, there is a quiet a huge thing here you should not add any repo to your list because these apps might not be safe as a simple modification before a build they can add anything to it. So, only add repos that you trust and not anything you find.

I am using chaotic and andontie repos which are very useful.

To get Chaotic Repo do this

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'

Put this in your pacman.conf

[chaotic-aur]
Include = /etc/pacman.d/chaotic-mirrorlist 

To get Andontie Repo do this

sudo pacman-key --recv-key B545E9B7CD906FE3 
sudo pacman-key --lsign-key B545E9B7CD906FE3

Put this in your pacman.conf

[andontie-aur]
Server = https://aur.andontie.net/$arch

9. Custom Kernel

There are many custom kernels(cacule, zen, tkg, hardened, liquorix, xanmod) in the AUR you have to choose according to your requirements.

sudo pacman -S linux-tkg-bmq-generic_v3 linux-tkg-bmq-generic_v3-headers bbswitch-dkms #bbswitch-dkms for optimus-manager

This might not work since I get this from Chaotic Aur
I have played around with a lot of custom kernels, probably all the ones listed here are the ones that I have messed with. But linux-tkg-bmq-generic_v3 fit my requirements best. You probably also have to mess with a few kernels before choosing one.

10. Xorg Config(iGPU)

While using your pc you might find screen tears or graphical bugs, to fix them you need to create a config file

sudo nano /usr/share/X11/xorg.conf.d/20-intel.conf

Place this inside it

Section "Device"
 Identifier "Intel Graphics"
 Driver "Intel"
 Option "AccelMethod" "sna"
 Option "TearFree" "True"
 Option "Tiling" "True"
 Option "SwapbuffersWait" "True"
 Option "DRI" "3"
EndSection

Note: Please crosscheck this before you use it because this may not be correct for you & might make your Xorg crash.
Note: If your Xorg crashed try commenting some lines under Option & that might fix your issue but if it doesn't just remove the file.

11. Intel Graphic Parameters

These are specific parameters that I use on my setup to boost my intel graphic card, these were picked from the arch wiki according to my hardware specs. You need to go through the wiki to check if the same or other parameters apply to you.

sudo nano /etc/modprobe.d/i915.conf

Place this inside it

options i915 enable_guc=2 enable_dc=4 enable_hangcheck=0 error_capture=0 enable_dp_mst=0 fastboot=1 #parameters may differ

You need to reconfigure your kernel according to these changes.

sudo mkinitcpio -p linux-tkg-bmq-generic_v3

Change the linux-xxx according to the kernel you are using. Note: Please be sure of what you do because this is risky & might give you a complete OS crash.

12. NVIDIA

Way to install NVIDIA Drivers

sudo pacman -S nvidia

Note: This varies according to your kernel since you might require the dkms version.
There is also a nvidia version with some optimizations for performance you can install it instead of nvidia to get some extra fps on games.

yay -S nvidia-dkms-performance

13. Universe Repo

Universe repo from Artix, contains some services which might be useful to you, for example - optimus-manager-runit.
Add this to your pacman.conf

[universe]
Server = https://universe.artixlinux.org/$arch

14. Optimus Manager (Multiple GPUs)

If you have multiple GPU's, then turning both on at all times is unnecessary & just might consume more power or cause your system to heat up. So, Optimus Manager turns your secondary GPU off when not you are not using it, depending on the mechanism(bbswitch, acpi_call...) you choose.

sudo pacman -S optimus-manager-git optimus-manager-runit bbswitch lightdm-optimus-runit

You may choose something else if bbswitch doesn't work for you
You have to change the lightdm to the display manager you are using
Then configure the optimus-manager config

sudo nano /etc/optimus-manager/optimus-manager.conf

Then paste this inside your file

[optimus]
switching=bbswitch
pci_power_control=no
pci_remove=no
pci_reset=no

On next boot, check if it's off

cat /proc/acpi/bbswitch #Should output OFF

Note: If bbswitch reports ON then something might be breaking it like powertop. So you might have to fix it or use something else as a replacement.
Note: bbswitch breaks on tkg kernels, so you have to switch to bbswitch-dkms

15. Backlight

The brightness value does not get saved when the system reboots, to fix that you have to install brightness-runit & enable it.

PSD is a service that symlinks & syncs browser profile directories to RAM, thus reducing HDD/SSD calls & speeding up browsers.
You can get it from here. This helps Firefox, Librewolf & Chromium reduce ram usage.

yay -S profile-sync-daemon
git clone https://github.com/madand/runit-services
cd runit-services
sudo mv psd /etc/runit/sv
sudo ln -sfv /etc/runit/sv/psd /run/runit/service
sudo sv start psd

Note: rsync should also be enabled.

17. Colord

Colord is a system service that makes it easy to manage, install & generate color profiles to accurately color manage input & output devices. You can install it with colord-runit & enable it.

18. EarlyOOM (OOM-killer)

EarlyOOM checks the amount of available memory & swap periodically & kills memory according to the set pre-configured value. You can install it with earlyoom-runit.
To set values, do this

sudo nano /etc/default/earlyoom

Set the EARLYOOM_ARGS to this value

EARLYOOM_ARGS=" -m 96,92 -s 99,99 -r 5 -n --avoid '(^|/)(runit|Xorg|sshd)$'" #change the runit according to your init

You can also experiment with this, I have set this according to my personal preference.

Thermald is a Linux daemon used to prevent the overheating of platforms. This daemon monitors temperature & applies compensation using available cooling methods. You only need this if your pc heats and can't manage its heating internally. You can install it with thermald-runit & enable it.

20. Ananicy-CPP

Ananicy is a simple daemon written in Bash to manage processes' I/O & CPU priorities, with a crowdsourced rule set for popular applications. Fixing bugs for apps & thus reducing chances of crash or lags. Ananicy CPP is Ananicy rewritten in C++ for much lower CPU and memory usage.You can install it with ananicy-cpp-runit & enable it.

Preload is an ‘Adaptive read-ahead Damon’ which effectively what it does speeds up application load time by monitoring the software that is loaded & used day-to-day, the software used most often, & cache them in memory. This is only useful for HDD(s). You can get it from
Currently, while writing this there didn't exist a preload-runit service so the best way to use it is to get it from the AUR then

sudo nano /etc/rc.local

Put "preload" inside it.

22. Powersaving

1. TLP

TLP is a feature-rich command line utility for Linux, saving laptop battery power without the need to delve deeper into technical details. You can get it from

sudo xbps-install tlp
sudo ln -sfv /etc/sv/tlp /var/service/

To configure it do this

sudo nano /etc/tlp.conf

It's pretty simple to configure. You can leave it as is and you would get a amazing battery life.

PowerTop is a software utility designed to measure, explain & minimize a computer's electrical power consumption. You can also use powertop instead of TLP or with it, which won't have much significant impact if you use powertop with it. This is a alternative to TLP. So, I use this to add stuff from it in my rc.local of the stuff which isn't optimised by tlp. You can get it from

sudo xbps-install powertop

then enable it with (instead of tlp)

powertop --auto-tune

inside /etc/rc.local
Note: If you use powertop or scripts, you also have to use

echo 60000 > /sys/bus/usb/devices/2-1.5/power/autosuspend_delay_ms
echo 60000 > /sys/bus/usb/devices/2-1.6/power/autosuspend_delay_ms
echo 60000 > /sys/bus/usb/devices/3-1.5/power/autosuspend_delay_ms
echo 60000 > /sys/bus/usb/devices/3-1.6/power/autosuspend_delay_ms
echo 60000 > /sys/bus/usb/devices/4-1.5/power/autosuspend_delay_ms
echo 60000 > /sys/bus/usb/devices/4-1.6/power/autosuspend_delay_ms

The auto suspend timer needs to higher or your external mouse/keyboard may go to sleep again & again which is very annoying adding this line increases the auto suspend counter.

Intel-Undervolt is a tool for undervolting & throttling limits alteration for Intel CPUs. So, we reduce some of the power that is going to our cpu/gpu/cpu-cache.... which results in less battery consumption & less heating, but you have to be sure that it's not too less because otherwise, your system will crash since it's not getting enough power to work. This is not bad for hardware, but you should be sure about what you are doing. You can install it with intel-undervolt-runit & enable it.
You can configure it by

sudo nano /etc/intel-undervolt.conf
sudo intel-undervolt apply

Note: This is very dangerous and might cause system crash. If it is unbootable at some point you can go to a live system and remove execute permission from intel-undervolt/run file. My current under volt config is here.

24. Fstab Modification

Disable File System Check(FSCK)

In Linux, when a file system is mounted for certain times, or its last fsck was more than certain days ago, the system will perform fsck on it when the server reboots. The fsck process can take a few minutes to hours to finish, depending on the file system size. This is more useful on a server machine than a personal computer.
To remove the checks

sudo nano /etc/fstab 

Example:

UUID=f634ad84-2283-4c62-b1ab-d57718e64cbb swap swap sw 0 0
UUID=5c24bcde-e284-457d-b1e1-5845e0e77fb8 / xfs defaults 0 0
UUID=C61D-2685 /boot vfat umask=0077 0 0
tmpfs /tmp tmpfs defaults,nosuid 0 0

The 2 at the end of the first line and 1 at the end of the last line will disable checks for my /boot and my / partition.

Use Noatime instead of Defaults

Turning off atime is a small but effective way to improve system performance. One tweak is atime, which is one of the three timestamps on every file on Linux (more on that later). Since atime is updated every time the file is accessed, my understanding was that it had a significant impact on system performance.
So, get rid of defaults for noatime

sudo nano /etc/fstab 

Example:

UUID=45bfdbc4-dfa3-4307-91d7-57284b93489b swap swap sw 0 0
UUID=5A68-E64A /boot vfat noatime 0 0
UUID=57f97d04-4d32-4e24-9b43-5f77c0b4ad29 / xfs noatime 0 0
tmpfs /tmp tmpfs noatime,mode=1777 0 0

25. Removing unnecessary services

The services you don't use can be unlinked/stopped/uninstalled according to your choices, but be careful in removing anything because it may break your system.

So, at installation it comes with lot of things, now it is recommended not to remove agetty services because they create the multiple terminal but I only truely require 2 that's why I get rid of the rest.

sudo rm /run/runit/service/agetty-tty3 /run/runit/service/agetty-tty4 /run/runit/service/agetty-tty5 /run/runit/service/agetty-tty6 /run/runit/service/cupsd /run/runit/service/cronie /run/runit/service/syslog-ng

Ideally you should first use sv to stop it but in case of runit I just remove it and reboot.

Now, you can get rid of the services. Remember to remove the specific init services before hand and unlinking them or you would have lot of broken systemlinks (which isn't actually a big deal).

sudo pacman -Rscn memtest86+ amd-ucode os-prober artix-gtk-presets artix-qt-presets artix-grub-theme grub artix-branding-base syslog-ng-runit rsync-runit rpcbind-runit openssh-runit ntp-runit nfs-utils-runit mdadm-runit lvm2-runit haveged-runit dhcpcd-runit device-mapper-runit cups-runit cryptsetup-runit cronie-runit alsa-utils-runit

Note: I don't have an AMD pc nor do I need to test my memory since I already have that functionality on my hp diagnostics.

26. Remove Fallback Image (Not Recommended)

The fallback image is in case you kernel image doesn't contain everything for you to boot and fails in which case you can use your fallback image. But, I don't really need it also I have never found the use for it. Also my efi partition is pretty small.

To remove it

sudo rm /boot/*fallback*

So, that it doesn't regenerate change your kernel .preset like (not exactly this)

ALL_config="/etc/mkinitcpio.conf"
ALL_kver="/boot/vmlinuz-linux-tkg-bmq-generic_v3"

PRESETS=('default')

#default_config="/etc/mkinitcpio.conf"
default_image="/boot/initramfs-linux-tkg-bmq-generic_v3.img"
#default_options=""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment