Optimize Boot time & Ram Usage
Original boot time before optimisation:
$ systemd-analyze
Startup finished in 8.540s (firmware) + 775ms (loader) + 4.861s (kernel) + 43.83
7s (userspace) = 58.015s
graphical.target reached after 42.165s in userspace$ systemd-analyze
Startup finished in 8.540s (firmware) + 775ms (loader) + 4.861s (kernel) + 43.83
7s (userspace) = 58.015s
graphical.target reached after 42.165s in userspaceDisabling Plymouth
This Plymouth boot screen is that boot screen you see when you are booting.
EFI stub
sudo kernelstub --delete-options "quiet systemd.show_status=false splash"sudo kernelstub --delete-options "quiet systemd.show_status=false splash"GRUB
- Edit grub config
sudo nano /etc/default/grubsudo nano /etc/default/grubFind the GRUB_CMDLINE_LINUX_DEFAULT line, and you will see:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"- To disable the boot screen, simply remove the word splash from this line, like so:
GRUB_CMDLINE_LINUX_DEFAULT="quiet"GRUB_CMDLINE_LINUX_DEFAULT="quiet"- In order to apply the config changes to the grub bootloader, run this command:
sudo update-grubsudo update-grubNow reboot your system!
Finally, uninstall the plymouth package from your system:
sudo pacman -Rns plymouthsudo pacman -Rns plymouthsudo apt purge plymouth && sudo apt autoremovesudo apt purge plymouth && sudo apt autoremovesudo dnf remove plymouthsudo dnf remove plymouthsudo apt purge plymouth && sudo apt autoremovesudo apt purge plymouth && sudo apt autoremovesudo xbps-remove plymouthsudo xbps-remove plymouth- Remove lingering config directories
sudo rm -rf /usr/share/plymouthsudo rm -rf /usr/share/plymouthAdjusting the Swappiness Property
This is required to adjust swap usage. If you have huge rams like 16GB ram then you can reduce this value to as low as 0. But if you have low ram devices like 1GB you should make this 90 or higher. Interactions with the swap file are costlier since swaps are slower than RAMs, and they can cause a reduction in performance.
Values according to me for Ram: Ratio should be as follows, 32:0, 16:10, 8:20, 4:50, 2:70 20 is just an example value, don't mindlessly use it
sudo sysctl vm.swappiness=20sudo sysctl vm.swappiness=20These values do not stick. To add them permanently. Add the above line to sysctl.conf.
sudo nano /etc/sysctl.confsudo nano /etc/sysctl.confAdjusting the Cache Pressure Setting
Another issue, the system stores cache about stuff that you frequently open & this makes the system faster, as if it opens again, rather than reloading the data it will use the cache. But, on a lower ram device, this is a bad option since this will seriously slow your system down. Adjust this like you adjusted swappiness property, values for RAM: Pressure should be as follows, 1:100, 2:90, 4:80, 8:60, 16:50.
sudo sysctl vm.vfs_cache_pressure=50sudo sysctl vm.vfs_cache_pressure=50Add the above line to sysctl.conf.
sudo nano /etc/sysctl.confsudo nano /etc/sysctl.confEarlyOOM
It is a cool new feature enabled in Fedora 33. What is it, you ask? In Layman terms, It frees memory when the ram or the swap gets close to full (over 90%). Making this a beneficial feature for heavy usage. This is a very important feature for old hardware. It only consumes 0.5 to 2 MB in the background.
To install it
sudo apt install earlyoomsudo apt install earlyoomTo check its status
systemctl status earlyoomsystemctl status earlyoomClearing buff/cache
The computer accumulates high buff/cache over time and makes the user force reboot. To clear buff cache, you can use this.
free -h && sudo sysctl -w vm.drop_caches=3 && sudo sync && echo 3 | sudo tee /proc/sys/vm/drop_caches && free -hfree -h && sudo sysctl -w vm.drop_caches=3 && sudo sync && echo 3 | sudo tee /proc/sys/vm/drop_caches && free -hOptimizing the boot
DANGER
PLEASE DO THIS AT YOUR OWN RISK. WHILE THIS IS SAFE TO DO YOU CAN STILL MESS UP YOUR SYSTEM SO, PLEASE READ THIS CAREFULLY AND UNDERSTAND EVERYTHING BEFORE YOU PROCEED.
- Network-dispatcher is a dispatcher daemon for systemd-networkd connection status changes.
sudo apt remove --purge networkd-dispatchersudo apt remove --purge networkd-dispatcher- ModemManager is a DBus-activated daemon that controls mobile broadband (2G/3G/4G) interfaces. If you do not have a mobile broadband interface, you do not need this.
sudo systemctl disable ModemManager.service
sudo systemctl mask ModemManager.servicesudo systemctl disable ModemManager.service
sudo systemctl mask ModemManager.service- fwupd is a simple daemon allowing you to update some devices' firmware, including UEFI for several machines Disable thunderbolt_power
sudo nano /etc/fwupd/daemon.confsudo nano /etc/fwupd/daemon.conf Edit the BlacklistPlugins line to
BlacklistPlugins=test;invalid;thunderbolt_powerBlacklistPlugins=test;invalid;thunderbolt_powerRemove fwupd from boot
sudo systemctl disable fwupd.service
sudo systemctl mask fwupd.servicesudo systemctl disable fwupd.service
sudo systemctl mask fwupd.service- Avahi-daemon is supposed to provide zero-configuration network discovery and make it super-easy to find printers and other hosts on your network. I always disable it and do not miss it.
sudo systemctl disable avahi-daemon.service
sudo systemctl mask avahi-daemon.servicesudo systemctl disable avahi-daemon.service
sudo systemctl mask avahi-daemon.service- Apport collects potentially sensitive data, such as core dumps, stack traces, and log files. They can contain passwords, credit card numbers, serial numbers, and other private material.
sudo systemctl disable apport.service
sudo systemctl mask apport.servicesudo systemctl disable apport.service
sudo systemctl mask apport.service- Saned is the SANE (Scanner Access Now Easy) daemon that allows remote clients to access image acquisition devices available on the localhost.
sudo systemctl disable saned.service
sudo systemctl mask saned.servicesudo systemctl disable saned.service
sudo systemctl mask saned.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.servicesudo systemctl disable gpu-manager.service
sudo systemctl mask gpu-manager.service- Apt-daily-upgrade solves long boot uptime with apt-daily-upgrade.
sudo systemctl disable apt-daily.service
sudo systemctl disable apt-daily.timer
sudo systemctl disable apt-daily-upgrade.timer
sudo systemctl disable apt-daily-upgrade.servicesudo systemctl disable apt-daily.service
sudo systemctl disable apt-daily.timer
sudo systemctl disable apt-daily-upgrade.timer
sudo systemctl disable apt-daily-upgrade.service- lvm2-monitor Only useful if you are using lvm.
sudo systemctl disable lvm2-monitor.service
sudo systemctl mask lvm2-monitor.servicesudo systemctl disable lvm2-monitor.service
sudo systemctl mask lvm2-monitor.service- Systemd-resolved [Restart Required] is a system service that provides network name resolution to local applications. It implements a caching and validating DNS/DNSSEC stub resolver.
Disable & Mask the systemd-resolved service
sudo systemctl stop systemd-resolved.service
sudo systemctl disable systemd-resolved.service
sudo systemctl mask systemd-resolved.servicesudo systemctl stop systemd-resolved.service
sudo systemctl disable systemd-resolved.service
sudo systemctl mask systemd-resolved.serviceThen put dns=default in the [main] section of
sudo nano /etc/NetworkManager/NetworkManager.confsudo nano /etc/NetworkManager/NetworkManager.confDelete the symlink /etc/resolv.conf
sudo rm /etc/resolv.confsudo rm /etc/resolv.confNow, Restart
DANGER
This might be extremely unsafe!
- Switcheroo-control [Required on Dual-GPU systems] is a D-Bus service to check the availability of dual-GPU. Keep this only if you have 2 GPUs.
sudo systemctl disable switcheroo-control.service
sudo systemctl mask switcheroo-control.servicesudo systemctl disable switcheroo-control.service
sudo systemctl mask switcheroo-control.service- System76-power [Required on laptops] Power Controls for lappy not required on a desktop PC.
sudo systemctl disable system76-power.service
sudo systemctl mask system76-power.servicesudo systemctl disable system76-power.service
sudo systemctl mask system76-power.service- Thermald [Might heatup system] daemon prevents machines from overheating and was introduced in the 14.04 Ubuntu Trusty LTS release. It monitors thermal sensors and will modify cooling controls to keep the hardware cool. If your system heats after removing this even a bit, add it back
sudo systemctl disable thermald.service
sudo systemctl mask thermald.servicesudo systemctl disable thermald.service
sudo systemctl mask thermald.serviceQ. How to enable this services?
Let's say the service name be xyz.service then to enable it -
sudo systemctl unmask xyz.service
sudo systemctl enable xyz.servicesudo systemctl unmask xyz.service
sudo systemctl enable xyz.serviceBoot-time after disabling those stuff
$ systemd-analyze
Startup finished in 3.862s (firmware) + 808ms (loader) + 5.171s (kernel) + 15.52
Os (userspace) = 25.363s
graphical.target reached after 15.507s in userspace$ systemd-analyze
Startup finished in 3.862s (firmware) + 808ms (loader) + 5.171s (kernel) + 15.52
Os (userspace) = 25.363s
graphical.target reached after 15.507s in userspaceCustom kernel
Custom Kernels are known and used by fewer people, but these kernels add a significant boost to performance and battery.
Xanmod is the more popular choice among intel based hardware. It provides a stable, responsive, and smooth desktop experience. To get Xanmod, go here
While installing this don't forget to add, Setting the FQ-PIE Queuing Discipline.Liquorix is a distro kernel replacement built using the best configuration and kernel sources for desktop, multimedia, and gaming workloads. Works better with AMD hardware. To get Liquorix, go here
Initial benchmarks on intel make Xanmod a winner whereas, AMD hardware generally goes better with Liquorix. Also, if you are having heating issues go for Liquorix for a better thermal response. I use Xanmod normal because long term release felt slow for me on both my PC & lappy.
- Reference of Xanmod being compared to Clear Linux
- Reference of Liquorix Kernel Benchmarks For AMD Ryzen
Final Boot time
$ systemd-analyze
Startup finished in 3.910s (firmware) + 863ms (loader) + 4.456s (kernel) + 11.81
6§ (userspace) = 21.046s
graphical.target reached after 11.805s in userspace$ systemd-analyze
Startup finished in 3.910s (firmware) + 863ms (loader) + 4.456s (kernel) + 11.81
6§ (userspace) = 21.046s
graphical.target reached after 11.805s in userspaceQ. How to remove a kernel?
Ans. These are the general steps to follow:
- Getting, name of the Kernel
uname -runame -r- Removing the Kernel
sudo apt remove <kernel name>sudo apt remove <kernel name>- Getting, remaining Kernel files
apt list --installed *kernel-name*apt list --installed *kernel-name*- Removing the remaining Kernel files
sudo apt remove <name of kernel files>sudo apt remove <name of kernel files>Q. How to I uninstall custom Kernel?
DANGER
IF YOU ARE A NEW USER AND DON'T KNOW WHAT YOU ARE DOING, PLEASE SEARCH SOME THREADS OR ASK SOMEONE BEFORE TAKING ANY ACTION. BECAUSE THIS IS A VERY RISKY STEP AND CAN POTENTIALLY KILL YOUR SYSTEM.
- Removing the Kernel apt modules
sudo apt autoremove --purge linux-xanmodsudo apt autoremove --purge linux-xanmodsudo apt autoremove --purge linux-image-liquorix-amd64 linux-headers-liquorix-amd64sudo apt autoremove --purge linux-image-liquorix-amd64 linux-headers-liquorix-amd64- Remove FQ-PIE Queue Discipline for systemd
sudo rm /etc/sysctl.d/90-override.confsudo rm /etc/sysctl.d/90-override.conf# Not required for Liquorix.# Not required for Liquorix.- Removing the Kernel Repos
sudo apt-key --keyring /etc/apt/trusted.gpg.d/xanmod-kernel.gpg del "Xanmod Kernel Signing Key"
sudo rm /etc/apt/sources.list.d/xanmod-kernel.listsudo apt-key --keyring /etc/apt/trusted.gpg.d/xanmod-kernel.gpg del "Xanmod Kernel Signing Key"
sudo rm /etc/apt/sources.list.d/xanmod-kernel.listsudo add-apt-repository ppa:damentz/liquorix -rsudo add-apt-repository ppa:damentz/liquorix -r