Ubuntu – Root drive is running out of disk space. How to free up space

disk-usage

I'm using Ubuntu 11.04 and I want to free up some space in my root directory, which is overloaded. I especially want to change the path used for installing applications (they are getting installed directly to the root drive).

Another consideration is that I'm working on a MySQL database server. The server is installed in the root directory itself, so I don't want to risk losing any data.

Please give me some tips to help sort out this problem.

Best Answer

I successfully cleared 3.5 GB by removing old headers and images.

Please note on some systems this also attempts to remove the current kernel which is not a great idea - see comments below for how to check.

I used the following command:

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge

You can check what packages will be purged executing the first part of the command:

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'

Reference

Related Question