Overview | |
---|---|
Skill level | Advanced |
Difficulty | ★★★★★ |
Type | Scripting |
I’m using Manjaro since February 2019, and I never had the necessity to downgrade packages from cache.
So, finally, I decided to move the package’s cache in /tmp
.
Also for the benefit of the SSD, eg, to reduce the WAI (Wear Acceleration Index).
IMPORTANT: this method is for experienced users which know what they are doing.
Furthermore:
- Suitable for users with ample RAM and zswap or zram to prevent OOM (out-of-memory) issues when upgrading or installing a large number of packages while running multiple other processes at the same time (but is recommended to performs the updates by logging out of the session and performs the update in TTY).
- Eg, if you have plenty of RAM, I suggest to increase the available size of
/tmp
; this can be done in/etc/fstab
:
tmpfs /tmp tmpfs mode=1777,noatime,nosuid,nodev,size=10G,inode64 0 0
-
Reinstalling or downgrading packages won’t be possible without an internet connection once the cache is cleared (e.g., while traveling offline or if laptop lacks a WiFi driver, etc …).
-
Ideal for users who have a good internet speed and don’t mind re-downloading packages after the cache is cleared.
Proceed:
For pacman/pamac is simply. in the file /etc/pacman.conf
, change/edit:
CacheDir = /tmp/pacman-pkg/
But for AUR and YAY, there is the necessity to create every time after boot, the folders (linked from /tmp
to the disk), so I’ve made these bash scripts, executed on boot (I’m on Xfce, so I’ve set them in the preflet “Session and Startup”).
The scripts are the following:
AUR cache 1:
#!/bin/bash
tmpcachefolder="/tmp/pamac-build-dave"
if [ -d "$tmpcachefolder" ]; then
echo "Aur's cache folder already created"
else
## SET AUR'S CACHE ON /TMP
rm -fr /var/tmp/pamac-build-dave
mkdir -p /tmp/pamac-build-dave
ln -s /tmp/pamac-build-dave /var/tmp/pamac-build-dave
fi
exit 0
AUR cache 2:
tmpcachefolder2="/tmp/aur-dave"
if [ -d "$tmpcachefolder2" ]; then
echo "Aur's cache folder already created"
else
## ON THE FIRST BOOT, /var/tmp/pamac/aur-dave DOESN'T EXISTS, SO CREATE IT
mkdir -p /var/tmp/pamac/aur-dave
## SET AUR'S CACHE ON /TMP
rm -fr /var/tmp/pamac/aur-dave
mkdir -p /tmp/aur-dave
ln -sf /tmp/aur-dave /var/tmp/pamac/aur-dave
fi
exit 0
YAY cache:
#!/bin/bash
tmpcachefolder="/tmp/yay"
if [ -d "$tmpcachefolder" ]; then
echo "Yay's cache folder already created"
else
## SET YAY'S CACHE ON /TMP
rm -fr /home/dave/.cache/yay
mkdir -p /tmp/yay
ln -s /tmp/yay /home/dave/.cache/yay
fi
exit 0
Obviously, you have to change “dave” with your username.