[how-to] Keep Linux closer to the size on the day you installed it

rado84

Active Member
Credits
95
As we know installing new programs inevitably increases the size of your Linux distro but unlike Windows 10, it doesn't have to reach 100 GB in less than a month.
I found a way to keep my distro (Arch) as close as possible to the size it was on the day I installed it, which was 15.0 GB. I won't bother you with the details how I found it, I'll just mention that the reason for the increased size over time is the package manager at fault. In Arch case - pacman. IDK why but pacman wasn't made to remove its cache and with time your Arch installation could grow significantly. In my case it had become 60 GB - 12 GB of mods for ETS2 (Euro Truck Simulator 2), 15 GB the operating system itself and the rest was just unnecessary packages in the pacman's cache (33 GB).
Unlike Windows, on Linux you can delete all the cache without corrupting the entire OS.

On Windows if you delete a directory named "winsxs" or something similar, within the next 5 minutes it begins to act strangely and eventually gets badly corrupted. This directory is the reason why Virus 10 (in particular, but it also applies to the rest before Virus 10) becomes 100 GB or even more in less than a month - Virus 10 keeps there copies of entire programs to check their versions and update if needed. So if you have a large program (like Visual Studio which can be 30 GB), it will in fact take 60 GB on your hard drive.
Linux doesn't do that and checks version in another manner, altough I'm not sure what it is yet.

Anyway...

For Arch you need to clear the contents of this directory:

Code:
/var/cache/pacman/pkg
Or, if you're too lazy to clear it every time, you can use an alias, like me:

Code:
#deleting pacman cache
alias pacc="sudo rm -rv /var/cache/pacman/pkg/*"
This alias removes every single file inside the "pkg" directory and shows a report for it, like this:
Code:
[[email protected]]: ~>$ pacc
„'/var/cache/pacman/pkg/lib32-libdrm-2.4.102-1-x86_64.pkg.tar.zst'“ was removed
„'/var/cache/pacman/pkg/lib32-sqlite-3.32.1-1-x86_64.pkg.tar.zst'“ was removed
„'/var/cache/pacman/pkg/libdrm-2.4.102-1-x86_64.pkg.tar.zst'“ was removed
„'/var/cache/pacman/pkg/sqlite-3.32.1-1-x86_64.pkg.tar.zst'“ was removed
Now, using this alias my Arch installation is 27 GB with all the programs I use plus the 12 GB of mods for ETS2 which makes the OS itself to be just 15 GB.

I have no idea what the directory would be for other distros such as Debian or Ubuntu which use Aptitude instead of pacman. It's possible to be something like "/var/cache/apt/pkg" but you'll have to check that for yourselves. Whether the path is the same or not depends on the developers of your distro.
 
Last edited:


jglen490

Active Member
Credits
656
Code:
sudo apt autoremove
sudo apt autoclean
sudo apt clean
And done, for Debian-based ...
 

rado84

Active Member
Credits
95
Code:
sudo apt autoremove
sudo apt autoclean
sudo apt clean
And done, for Debian-based ...
These commands probably don't remove everything.
 

Condobloke

Well-Known Member
Credits
476
On Windows, leftover registries get accumulated and slow down the system. On Linux, the worst that can happen is you have a bunch of tiny files that take up a trivial amount of space.
 

jglen490

Active Member
Credits
656
These commands probably don't remove everything.
And you are probably right. What is important is whether you want the installed distro to remain totally inert, or you just want to ensure that the only reason for growth is that it continues to do what you want it to do - functionality and in performance.

None of mine have ever stayed perfectly sized at some level. What has happened is that the installed distro does what I am expecting it to do, performing as I expect it to do, and when it grows it does so based on what I want to add, or it grows because of known factors.

I submit, if an installed distro does not grow, it is completely inert and may not be as functional or perform as it once did.

It's your decision what you want and what you expect.
 

rado84

Active Member
Credits
95
And you are probably right. What is important is whether you want the installed distro to remain totally inert, or you just want to ensure that the only reason for growth is that it continues to do what you want it to do - functionality and in performance.

None of mine have ever stayed perfectly sized at some level. What has happened is that the installed distro does what I am expecting it to do, performing as I expect it to do, and when it grows it does so based on what I want to add, or it grows because of known factors.

I submit, if an installed distro does not grow, it is completely inert and may not be as functional or perform as it once did.

It's your decision what you want and what you expect.
If you remove every single package your package manager has ever downloaded (in the package manager cache folder), the system won't become slow or irresponsive. The only downside (to some it may be downside but not to me) is that if you need to reinstall a package, you'll have to wait for it to be downloaded again.

On Windows, leftover registries get accumulated and slow down the system. On Linux, the worst that can happen is you have a bunch of tiny files that take up a trivial amount of space.
We're not talking about registry here.
 

jglen490

Active Member
Credits
656
Can't say anything about Arch, but the presence or absence of package cache has never been an issue in the 12+ years I've used Kubuntu. The cleanups that I use do nothing but clear out some space for a while.
 


Members online


Top