Cleaning up and freeing disk space

oh wow.
Oregon Trail is already available online … but for some reason this got me itchy all over again.

(also mac+js … dirty dirty dirty. :laughing: )

What i mean to say, i install a program
Then i remove it
Then i run
pacman -Rns $(pacman -Qtdq)

Will there be any left over? Cause i really feel like i do. On ubuntu i remember uninstalling packages one by one cause commands i ran would not uninstall them.

But … thats weird.
You dont need to remove orphans after properly removing a package.
If you have no orphans, then do paman -Rns firefox … you still wont have any orphans afterwards.
Thats the whole point of s in that command … to recursively remove packages that are no longer required by anything else when you uninstall the item in the command.
It wont get things like what FF stored in ~/.cache

Furthermore … I heavily suggest not simply running that command.
Check for orphans preriodically if you like, sure (pacman -Qtdq) but dont just blindly remove.

This isnt ubuntu. One of the biggest reasons to use Arch over Ubuntu is the package management.

1 Like

So to follow up on the idea of finding big folders in your home (like seeing if your .cache is huge) then you can run this from your home directory:

du -sch .[!.]* * | sort -h | tail -n20

But … I had the impression you were talking about a new install being ‘bigger’.
In which case I also suggest using Architect and/or one of the minimal editions.
Thats what I would use … and then remove and add software according to my liking.
This will be the case for any system you install unless you tune/build/make/etc from the ground up.

1 Like

Ha ha …well how about this then. :stuck_out_tongue:

3 posts were split to a new topic: 13 Emojis per user post response

I applied some of the procedures recommended here but I am unsatisfied with the result :frowning:
maybe the only solution at this point is really Architect… I will tinker with it on a laptop, and then decide what to do.

Thanks all for the precious help!

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.