Skip to content

Instantly share code, notes, and snippets.

@sahal
Last active April 11, 2025 01:46
Show Gist options
  • Select an option

  • Save sahal/ce7bd608d877aa52fa99a8429ecb89ab to your computer and use it in GitHub Desktop.

Select an option

Save sahal/ce7bd608d877aa52fa99a8429ecb89ab to your computer and use it in GitHub Desktop.
My strategies to free up disk space on Arch Linux

My / (i.e. root directory) on my system is 25GB and I intend to keep it only 70% full.

Here are some strategies to do that. Some of the strategies might be useful on other distributions too.

Avoid using / for cache

Package Cache

Keep your pacman/AUR helper cache outside of the root disk

# for pacman.conf
CacheDir    = /mnt/different/disk/cache/paccache/pkg/
  • side note: use paccache to keep only a few old versions of packages, otherwise pacman -- and/or your AUR helper -- will keep many.

  • side note2: you need to keep at least a single old version of the package because, in general, arch package mirrors only keep one version. You'll be SOL if the a new package version breaks your system and you don't have a copy of the previous version backed up locally

Config files in your home directory

Keep your XDG directories outside of your home directory. Many (but not all) applications will honor your XDG_ env vars.

# set these in one of your bash config files
XDG_DATA_HOME=/mnt/different/disk/cache/xdg/local/share/sahal
XDG_CONFIG_HOME=/mnt/different/disk/cache/xdg/config/sahal
XDG_CACHE_HOME=/mnt/different/disk/cache/xdg/cache/sahal
XDG_STATE_HOME=/mnt/different/disk/cache/xdg/local/state/sahal
  • If you use docker (or podman) keep your cache directory on a different disk

localepurge - remove unused locales

If you're not regularly using a non-english language on your system, you can remove unneeded locales.

Ensure that the following file contains the locales you do want to keep:

$ cat /etc/locale.nopurge|grep -v ^#|tr -s '\n'

MANDELETE
SHOWFREEDSPACE
VERBOSE
en
en_GB
en_GB.UTF-8
en_US
en_US.UTF-8
zh
zh_CN
zh_CN.Hans
zh_CN.Hant
zh_CN.UTF-8
zh_HK
zh_TW
de_DE

Systemd Journal

Clean up journal cache.

sudo journalctl --vacuum-time=30m

Use qdirstat

This will help you find large directories. Spend most of your time on the big directories.

Removing Packages

Check to see if any files were kept even after removing a package. Not all the results here can or should be deleted. Use your judgement.

PACKAGENAME=flatpack
for file in $(pacman -Fl "${PACKAGENAME:-flatpak}" | \
  awk '{print "/"$2}'); do  
  
  stat $file >/dev/null  2>&1 && echo $file exists
done

Lost files

Use lostfiles to find files that are not owned by any package in system. This has yet to be helpful, but it might be in the future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment