Arch Setup

Just a place to put notes about how I configure my Arch Linux setup, particularly preferences and optimizations.

Parallel package building

When building packages, particularly through the Arch User Repositories (AUR), the process may take a fair bit of time, depending on what is being packaged. Changing a few flags can allow for parallel compiling and compression. In the /etc/makepkg.conf file, these changes can be made:

MAKEFLAGS="-j10"

COMPRESSGZ=(pigz -c -f -n)

COMPRESSXZ=(xz -c -z - --threads=0)

COMPRESSZST=(zstd -c -z -q -T0 -)

These changes (in bold) configure the make processes to work with multiple threads. In the case of the makeflags, I hard coded it to 10 threads, 2 less than my system total. This can equally be set to $(nproc) to dynamically set it to the number of available virtual CPUs. From my experience, this causes system hangs, and I don’t recommend it. The others allow for compression of packages using any number of threads, for various compression methods.

bashrc

There are a few preferences, and aliases that I’ve added to this (~/.bashrc), for convenience and personal usage. The main of which is to add automatic colouring to applications like the following:

ls, grep (and variances), pacman

I’ve also set an alias to redirect vi to vim, since 3 characters are too exhausting to enter, whereas 2 is much more conservative on energy. I’ve also set my default editor by exporting VISUAL=’vim’.

Finally, to avoid overlapping issues when a line surpasses the width of the terminal, the following is also set:

shopt -s checkwinsize

pacman mirror list organization

One change I recently discovered was how to organize mirrors in the list by connection speed. This made a significant improvement to my package download times, and the change was fairly simple to do. The rankmirrors command will automatically test available mirrors, and can output them to a new file organized. More details about this are available on the Arch Wiki.

I’ve also set a bashrc alias to automatically perform this task, limiting the testing mirrors to United States and Canada, in order to reduce the testing duration:

alias updatemirrors=”su -c  $’cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup; sed -i \’/.*\(Canada\|United States\)/,/^$/ s/^#//p\’ /etc/pacman.d/mirrorlist.backup; rankmirrors -n 6 /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist'”

TLP

TLP is an advanced linux power manager, which is particularly useful for those using laptop computers. Its default configuration is generally useful, however sometimes it’s worth tweaking settings found in /etc/default/tlp. The following are some of the changes I’ve made to my own, for a more particular use case.

I disabled the following settings, as I do not have an AMD GPU:

#RADEON_POWER_PROFILE_ON_AC=high
#RADEON_POWER_PROFILE_ON_BAT=low

#RADEON_DPM_STATE_ON_AC=performance
#RADEON_DPM_STATE_ON_BAT=battery

#RADEON_DPM_PERF_LEVEL_ON_AC=auto
#RADEON_DPM_PERF_LEVEL_ON_BAT=auto

I also disable bluetooth all together, since I never use it:

DEVICES_TO_DISABLE_ON_STARTUP=”bluetooth”

Swap

I’ve had instances where I end up maxing out my memory, or nearly, and by default the system moves pages to swap. The problem with this, is once memory is freed later, the swap isn’t cleared, and applications become slow. To avoid this, setting the swappiness as described on the wiki page does the trick. Creating the file /etc/sysctl.d/99-sysctl.conf and adding the following line:

vm.swappiness=10

I have also configured zswap on my system, which will allocate a portion of memory as compressed space, where swapping will occur first. This further reduces the likelihood that swap space on disk is used, as it is much slower.

Configuration Saving

There have been a few instances where I inadvertently erased or make mistakes in configuration files found under /etc, which can have various side-effects, including the inability to properly boot the system. To help recover from such scenarios, I am now using a tool called etckeeper, which turns the directory into a repository (git by default). This allows for all changes to be recorded, and easily restored.