I’ve always knew about Arch Linux, and always felt that to use this distro, I would have always problems and troubles. So I never switched… Until now. I’m 1 month deep in this experience and the only thing I can think is that i love it. The complete control over my system is what I’ve always wanted from my PC.
To use this Linux distribution you have to be already familiar with Linux, or you’ll need a lot of time to configure everything, but anyway the ArchWiki is arguably the best source of information and troubleshooting for Arch, with many topics applying to other distributions too: it is well written, (almost) complete and continuously updating. Following the install instructions from there was painless.
But now it’s time to get to the real topic: optimization. I’ll describe my steps based on my installation and setup, which is:
- GRUB (by mistake)
- systemd (standard for Arch Linux)
- AMD processor (minor changes for Intel’s ones)
From now on I’ll write instructions and link scripts to get the system fast and improve power consumption, which is great for battery life on a laptop. I’ll assume that you have Arch already installed with GNOME DE.
Switch to systemd-boot
Since you already have systemd, why use grub and not systemd-boot? Assuming your Efi System Partition is mounted to
bootctl --path=/boot install bootctl update
/boot/loader/loader.conf and make it look like:
# Doesn't matter if something is commented # timeout 4 default arch
Install the microcode for your processor, which is
amd-ucode for AMD, and
intel-ucode for Intel:
pacman -S amd-ucode # or intel-ucode
Now look in
.conf file should be present because auto-generated, rename it to
arch.conf and make it look like this:
title Arch Linux linux /vmlinuz-linux initrd /amd-ucode.img initrd /initramfs-linux.img options root=(autogenerated 'UUID=your-disk-uuid') quiet splash nowatchdog rw
To prevent, instead of repair, I’ve also installed the LTS version of the Linux kernel:
pacman -S linux-lts
And made another boot entry
title Arch Linux LTS linux /vmlinuz-linux-lts initrd /amd-ucode.img initrd /initramfs-linux-lts.img options root=(autogenerated 'UUID=your-disk-uuid') quiet splash nowatchdog rw
Now do your checks, and if everything works fine remove
grub, delete its configuration files and stuff from
/boot, then manage boot entries with
efibootmgr to make some cleaning.
For further reading or troubleshooting refer to the ArchWiki’s systemd-boot page.
There are some services and features that on a Linux desktop don’t make a lot of sense. For example, the journal, which is used to store systemd logs, can get really heavy and slow down the boot process, and if you don’t need a network connection to log in, why would you wait for it?
If you have the same opinion run this script of mine:
sh -c "curl -fsSL https://tinyurl.com/ucdkzwh" # or sh -c "wget -O- https://tinyurl.com/ucdkzwh"
Other than that, disable or mask services that aren’t useful undeniably increases battery life on a laptop. Check for your enabled services with:
systemctl list-unit-files --state=enabled
Check which services take more time to load at startup:
Pay attention when you disable a service and be sure that you know what you’re doing!
For further reading or troubleshooting refer to the ArchWiki’s systemd page.
CPU frequency scaling
You should have
cpufreq, or something else, already installed. I wrote a script that allows you to set a CPU governor and frequency, and allows you to turn off CPU cores to save battery. Download my script with:
wget -O cpu-profile.sh "https://tinyurl.com/sbfyajq" # or curl -fsSL "https://tinyurl.com/sbfyajq" > cpu-profile.sh
Drivers and firmware
Make sure to install the correct video drivers… For this one, just follow the instructions here.
For firmware specific to your particular hardware, you might find interesting software provided directly by OEMs. To check if it is the case, you have to install
fwupd and run:
fupdfmgr get-devices fupdfmgr refresh fupdfmgr get-updates fupdfmgr update
For more information go to the LVFS website.
Remove unneeded packages
Pacman is a great package manager, and I’m not an expert of it, but every time I have a doubt, there’s an ArchWiki’s page with a solution!
To keep the system relatively clean, when removing packages, I run:
pacman -Rns package
-s option is to “remove a package and its dependencies which are not required by any other installed package”, the
-n option is to “prevent the creation of (configuration) backup files”.
Once in a while I remove every orphan package:
pacman -Rns $(pacman -Qtdq)
And clean the cache (of old version of packages that are not needed):