Ubuntu – How to clean up the harddrive

cleanupfilesystemhard drive

Not to long ago I was using only 35% of my HD. Just recently it shot up to 54% and my diskspace is 16gb so that's more then 3gigs that have been taken.

From what I remember I failed to build mysql, I installed gitolite which required me to build git from source which had a tons of dependencies (I think it was for building docs, I think I saw latex and other packages but I was drowsy when I was installing). I suspect that is what is taking the diskspace.

Anyways so far I deleted source folders I know I had and ran these commands. What else can I do? (3gigs is mighty)

sudo apt-get autoclean
sudo deborphan | xargs sudo apt-get -y remove --purge

After doing the above i did ncdu and found that

  1. Git itself was actually using 502mb in 152 files all in '/usr/local/libexec/git-core'. Who knew. I found it strange that most of those files are 4.6mb each…

  2. MySql was taking up 1+gb in my /tmp folder

  3. I accidentally made a copy of my mono src folder which has two builds of mono and is 1.7gb together.

After deleting the copy of src and an extra mono build (thats 2.6gb together) + the mysql in my temp folder df now reports 28% instead of 54% which makes me feel a lot better.

I'm still surprised git uses 502mb. On windows it uses 57mb (thats about 10xless). And the equivalent folder (C:\Program Files (x86)\Git\libexec\git-core) has all those apps as shortcuts to git. and git is only 1.2mb (not 4.6). Also i checked if the linux git-core folder were all links, i know they arent softlinks (i used the cmd find . -maxdepth 1 -type l -print0 | xargs -0 ls -ld) I tried stat git, stat git-add and saw they had the same innode. So most of these files are hardlinks (i assume) of git. So git doesnt actually take up that amount of space.

Best Answer

My two favorite tools are for finding and visualizing filesystem bloat are gdmap and fslint. Summarized from apt-cache:

apt-cache show gdmap
apt-cache show fslint

gdmap: "GdMap is a tool which allows to visualize disk space. Ever wondered why your hard disk is full or what directory and files take up most of the space? With GdMap these questions can be answered quickly. To display directory structures cushion treemaps are used which visualize a complete folder or even the whole hard drive with one picture."

fslint : "has an interface for uninstalling packages, and it can find things like: .

- Duplicate files
- Problematic filenames
- Temporary files
- Bad symlinks
- Empty directories
- Nonstripped binaries"

OK, and here's an ncurses based one, which will print hash marks to show relative size if you want it:

ncdu
Description: ncurses disk usage viewer
    Ncdu is a ncurses-based du viewer. It provides a fast and easy-to-use interface through famous du utility. It allows to browse through the directories and show
    percentages of disk usage with ncurses library.

And two more text-based applications from my system repos, which are more involved:

gt5
durep
Related Question