Dhiren Audich Software Developer | Apprentice Polymath | Data Science Enthusiast

Cleaning up Linux Filesystem

I am currently dual booting LMDE with Windows 7 on my laptop. Since I am using Windows 7 primarily for gaming purposes, I have allocated most of my HDD space to it and about 120GB to the linux partition. I have a second HDD (250 GB) with all of my personal data on it for linux only.

However, since all of the linux packages reside in root directory, everything goes to the tiny 120GB partition; causing it to "fill up" every now and then. This gives rise to the following error:

Error message for low disk space

To combat this linux has an in-built cron task that clears up the log data and other clutter on a daily basis. For whatever reason this sometimes just stops working!?

Until I am able to debug why, here are a few steps that I take to clear some disk space:

Note: These steps should work for all Debian and Debian based systems including Ubuntu, Linux Mint and LMDE.

  1. Cleaning up old and unnecessary package files.
  2. sudo apt-get autoclean
    sudo apt-get autoremove
    
  3. Once that is done another thing to do is to manually run the cron task and then delete the tarballed files:
  4. sudo /etc/cron.daily/logrotate
    
    Note: the logrotate takes a while to run, so don't panic if your TTY hasn't returned.

    Once that is done, you can easily remove the unnecessary log files:
    sudo rm /var/log/*.tar.gz.1
    sudo rm /var/log/*.log.1
    
  5. Okay, this one is obvious, clean up your Trash bin.

Additionally:

  • You might also want to clear your browser cache, cookies, temp files and history.
  • Unnecessary downloaded files (if you have a default Downloads directory set) also tend to take up too much place.

Et voila! Just doing the above steps have, in the past, saved me over 70GB sometimes. Depends on the duration between the logratates.

Happy disk saving!

Leave a Comment

All comments are held for moderation; basic HTML formatting accepted.