Cleaning up and freeing disk space

wait wait something is fishy here. Upon further inspection I located two very large directories:

Blockquote
var = 8Gb
– cache 3Gb
– log 2.7 Gb
– lib 1.9 Gb

now, using the “paccache -r” command, returns “no candidate package for pruning”.
I want to free those 8Gb of space… what can I do?

for log ( journal )

journalctl --disk-usage
sudo journalctl --vacuum-size=500M

for cache

sudo pacman -Sc
sudo pacman -Qdt
4 Likes

okay now those commands freed a good 5Gb of space, and that makes me happy, thanks.
Inspecting /var/cache/pacman/pkg
and simply issuing ls reveals that it is still full, should I consider this as normal, I mean, is there any absolute need to keep all those files there?

you have just last version in cache ,
if you update , and need to downgrade ,
it’ in the cache for downgrade

what about orphans ?

I use find ~/.cache/ -type f -atime +100 -delete

to delete files in ~/.cache directory that are have not been accessed in 100 days (it won’t work if noatime option set in fstab file)

3 Likes

ah yes, done that too, freed more 500Mb :slight_smile:
well I guess this is all I can squeeze with conventional methods

thanks for the big help!

Please don’t forget to mark a solution like this:
Solution
so that the next person that has the exact same problem you just had will benefit from your post as well.

:innocent:

1 Like

Run the following commands in sequence:

Blockquote
sudo pacman -Sc
sudo pacman -Qdt
sudo pacman -Rns $(pacman -Qtdq)
sudo journalctl --vacuum-size=50M

2 Likes

On top of what you did I also have:

#Remove orphaned libraries
pamac remove --orphans
#clean cache
pamac clean --build-files
# Clean kioexec cache
rm --recursive ~/.cache/kioexec/krun/*
6 Likes

So then you werent talking about the size of the newly installed system.
You were talking about your own accumulated junk.
All that is is cleaning pacman cache, removing orphans, and cleaning journal.
This is all covered in
https://wiki.manjaro.org/index.php?title=System_Maintenance

(PS - I edited the title to reflect your intention)

1 Like

Using -mtime does:

find ~/.cache -depth -type f -mtime +100 -delete

While we’re at it, here’s my housekeeping stuff. I keep it in a shell script that can be run all at once for convenience, but it’s also around for reference if I only want to perform a specific task.

# Vacuum journals
sudo journalctl --vacuum-size=500M && sudo journalctl --vacuum-time=7d

# Remove all uninstalled packages
sudo paccache -rvuk0

# Remove old installed packages, leave 3
sudo paccache -rvk3

# Clean yay cache
yay -Sc -a

# Clean pamac build cache
pamac clean -bv

# Clean temporary build files
rm -rf ~/{.bundle,.cargo,.cmake,.dotnet,.electron,.electron-gyp,.gem,.gradle,.lazarus,.node-gyp,.npm,.nuget,.nvm,.racket,.rustup,.stack,.yarn} || true
rm -rf ~/.cache/{electron,electron-builder,go-build,node-gyp,pip,yarn} || true
sudo rm -rf ~/go || true

# Find files not owned by any package
sudo lostfiles

I have a Pacman hook for detecting orphans:

/etc/pacman.d/hooks/orphans.hook
[Trigger]
Operation = Install
Operation = Upgrade
Operation = Remove
Type = Package
Target = *

[Action]
Description = Checking for orphaned packages...
When = PostTransaction
Exec = /usr/bin/bash -c "/usr/bin/pacman -Qtd || /usr/bin/echo '=> No orphans found.'"
10 Likes

Very interesting this thread

While I update manjaro only from terminal, I use graphical pamac for one-off actions, including dealing with orphans in a conservative manner.

Once in a while I open pamac and examine one by one the packages marked as orphans. I read the details, check on dependencies and dependents.

If it looks ok, I remove the particular package using pamac. Otherwise I leave them alone for the moment if I’m not sure.

It’s probably unnecessary to be that cautious, but it’s served me well.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.