Free up Disk Space
Remove Unused Packages
To check for such unused dependencies run:
sudo pacman -Qtdq
To remove the above packages run:
sudo pacman -Rns $(pacman -Qtdq)
Clean the package cache
Pacman stores its downloaded packages in /var/cache/pacman/pkg/ and does not remove old or uninstalled versions automatically. You can either remove old packages manually or use a script.
Manually Remove
Check the packages that exist in the pacman cache:
ls /var/cache/pacman/pkg/ | less
or
ls /var/cache/pacman/pkg/
Remove all cached packages except from those that are installed:
sudo pacman -Sc
If you want to remove all cached packages:
sudo pacman -Scc
Using paccache
An alternative to the manual removal of packages is paccache; a script that deletes all cached versions of installed and uninstalled packages, except for the most recent three, by default.
First install paccache:
sudo pacman -S pacman-contrib
Check which packages can be removed:
paccache -d
Delete the packages:
paccache -r
Remove the cache of all uninstalled packages:
paccache -ruk0
Run paccache automatically
You can also enable and start the paccache.timer service to automatically remove unused packages weekly:
sudo systemctl enable paccache.timer
sudo systemctl start paccache.timer
If paccache.timer is not available then create manually.
Create systemd timer file:
sudo nano /etc/systemd/system/paccache.timer
Add this following contents:
[Unit]
Description=Clean-up old pacman pkg cache
[Timer]
OnCalendar=monthly
Persistent=true
[Install]
WantedBy=multi-user.target
And enable paccache.timer service.
Clean home directory cache
Your applications will use the .cache directory in your home directory to store cached data. Usually it's safe to remove files from here as applications will recreate any needed data. Proceed with caution though.
You can use the following command to check which directories are taking up most of the space
du --max-depth=1 ~/.cache | sort -hr
Alternatively you can use the ndcu tool, a disk analyzer with an ncurses interface.
Find and remove duplicate files
rmlint is a handy tool that scans your filesystem to find duplicate files and directories.
rmlint will also detect empty directories and broken symbolic links. While they don't take any meaningful disk space, they still clutter your system.
Install rmlint using:
sudo pacman -S rmlint
and run it:
rmlint -g [directory]
After it completes, rmlint will create a rmlint.sh script in the directory where it was executed. You can inspect the script to check what is going to be deleted, manually remove any files you want to keep, and finally execute the script.
Config Files
Config file is located in
~/.config