Files - How To Clean Up A Linux System To Free Up Disk Space - Unix & Linux Stack Exchange
Files - How To Clean Up A Linux System To Free Up Disk Space - Unix & Linux Stack Exchange
What are some generic ways to free up lots of storage space without deleting personal files?
I'm doing a distro upgrade (Debian11->12) and it needs lots of disk space on the root partition /
1
which doesn't have a large size and I'd like to keep all user files on that partition with few
exceptions if needed. A prior upgrade failed in the middle of it because of the error No space
left on device and required more disk space than what was displayed when running for
example sudo apt-get full-upgrade . Running step-wise distro upgrades that each require less
disk space is not yet possible.
Generic ways would be deleting caches and old logs rather than moving or deleting user files
such as media files. Please include explanations what these things delete.
Share Improve this question Follow edited Apr 13 at 17:03 asked Apr 9 at 18:13
mYnDstrEAm
4,388 14 60 122
run ncdu under various folders on the root partition to understand where the space is being used up.
Then decide accordingly, for example {if you were on redhat} and your /var/cache/yum/ folder was
huge then removal of whatever is the equivalent in debian would be a start. – ron Apr 9 at 19:09
https://unix.stackexchange.com/questions/774199/how-to-clean-up-a-linux-system-to-free-up-disk-space 1/2
7/11/24, 4:07 PM files - How to clean up a Linux system to free up disk space? - Unix & Linux Stack Exchange
Deleting files from the trashbin trash:/ and checking if there's any large files that could be
deleted in /tmp: find /tmp -type f -size +50M -exec du -h {} \; | sort -n
Identifying largest files with a command like sudo find / -mount -type f -size +100M -exec
du -h {} \; | sort -n (a few more are here and here) or with a GUI like gdmap (Graphical
Disk Map) and then either moving/deleting them or creating symbolic links.
For example, to create a symbolic link for the relatively large daily.cld file of ClamTk one
could run sudo mv /var/lib/clamav/daily.cld /home/username/Software/daily.cld then
sudo ln -s "/home/username/Software/daily.cld" "/var/lib/clamav/daily.cld" so this
also works for files used by software that expect the file to be in a specific location.
Directories where one can commonly find large files include /opt/ .
Another thing one can do is deduplicating things media by replacing duplicates with
symlinks but I don't know of a command or tool that does that (or helps you do that)
If, like me, you had your system crash or not be able to run the desktop environment (such as
KDE Plasma) because of too little disk space, you could run the CLI commands from a TTY to
delete files from there to free up enough disk space. You can switch to a virtual terminal (TTY)
and back with Ctrl+Alt+F1 (or F2,F3,..). Once you have freed up enough disk space you can switch
back using these shortcuts and restart the desktop environment (for KDE that's kstart5
plasmashell ).
If you have this problem because you need more disk space for a distro upgrade, I suggested a
stepwise upgrade as a solution that would make this redundant and avoid upgrade interruptions
due to No disk space left. There devs brought up some alternatives:
Running the command with the cache directory elsewhere, for example: apt upgrade -o
dir::cache::archives=/media/apt-archives
untested: while sudo apt -s upgrade | grep '^Inst' | head -1 | awk '{print $2}' | xargs
apt install; do sudo apt clean; done ("Use head -10 or whatever fits for more/less
packages")
Share Improve this answer Follow edited Apr 14 at 15:00 answered Apr 9 at 18:13
mYnDstrEAm
4,388 14 60 122
https://unix.stackexchange.com/questions/774199/how-to-clean-up-a-linux-system-to-free-up-disk-space 2/2