Low disk Space in Root Filesystem Error

The system gives me the following error:

The volume "Filesystem Root" has only 713.9 MB disk space remaining. You can free up disk space by removing unused programs or files, or moving files to another disk or partition.

My question is, which files and from where should I move? How to not get the error any more?

I purged an old kernel [3.13.0.45] some time back and now have two kernels [3.17 & 3.8]. I had to purge 3.13 because incidentally, the free space in the error as shown above had become 0 bytes and the shutting down process too could not happen properly.

Results of df -Th

Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/sda6      ext4       19G   17G  601M  97% /
none           tmpfs     4.0K     0  4.0K   0% /sys/fs/cgroup
udev           devtmpfs  1.9G  4.0K  1.9G   1% /dev
tmpfs          tmpfs     386M  1.2M  385M   1% /run 
none           tmpfs     5.0M     0  5.0M   0% /run/lock
none           tmpfs     1.9G  188K  1.9G   1% /run/shm
none           tmpfs     100M   76K  100M   1% /run/user
/dev/sda5      ext4      453M  193M  233M  46% /boot
/dev/sda7      ext4       92G  788M   87G   1% /home

Here is the disk Analysis:

--- /------------------------
12.7GiB /usr                     
2.7GiB  /lib
1.2GiB  /var
877.9MiB  /home
190.4MiB  /boot
12.4MiB  /etc
11.9MiB  /sbin
9.6MiB  /bin
1.3MiB  /run
324.0KiB  /root
20.0KiB  /tmp
16.0KiB  /lost+found
12.0KiB  /media
4.0KiB  /dev
4.0KiB  /lib64
4.0KiB  /srv
4.0KiB  /opt
4.0KiB  /mnt
4.0KiB  /cdrom
0.0  B  /proc
0.0  B  /sys
0.0  B  initrd.img.old
0.0  B  vmlinuz.old

In usr/:

10.1GiB /src
1.4GiB  /lib
1.0GiB  /share
100.6MiB  /bin
14.4MiB  /sbin
9.6MiB  /include
520.0KiB  /games
112.0KiB  /local

In src/:

9.9GiB  /linux-3.17.6
94.1MiB  /linux-headers-3.13.0-45
90.4MiB  /linux-headers-3.8.0-29
13.8MiB  /linux-headers-3.13.0-45-generic
12.1MiB  /linux-headers-3.8.0-29-generic

Please help.


Solution 1:

First, you should check what's using up all that space with the "Disk Usage Analyzer" tool that ships with Ubuntu.

From a terminal, run:

gksudo baobab /

That should give you an idea of what uses so much space. Then:

  • Check how much space /root uses. Usually it should be less than 1MB. If you have anything larger in there, move it to your /home.

  • Check how much space /tmp uses. If it is more than a few MB, reboot your system. /tmp is cleared on every reboot but can fill up over time.

  • Check other folders such as /opt, and check if you put any large files there or if there are any large files that do not belong to a package. Some installers will install stuff into /opt and never remove it. Be careful when doing this.

  • Run sudo apt-get clean. That should remove a lot of stuff in the package cache. On my system running apt-get clean got rid of about 1.5GB of old downloaded packages that are not needed.

  • Reduce the size of the reserved space on /dev/sdb6. Usually 5% are reserved for the root user in case you fill up the system and need to log in as root user in an emergency. The default of 5% means 1GB on your system, you can safely reduce that to 1% (200MB) using tune2fs:

    $ sudo tune2fs -m 1 /dev/sda6
    tune2fs 1.42.9 (4-Feb-2014)
    Setting reserved blocks percentage to 1%
    
  • Uninstall some packages using sudo apt-get remove. Small tip if you use LaTeX: One of the major space wasters is usually the texlive-full metapackage. It installs gigabytes worth of documentation and other stuff, although you usually don't need it all at once. Installing texlive instead will pull in just the minimum, and download the rest when it's needed.


If you are still running out of space, as an absolute last resort you can:

  • Resize the /dev/sda6 partition (make it bigger) and shrink the /dev/sda7 partition using a Live CD and GParted. This could take a while and it's very easy to destroy your data, so you absolutely need to make a full backup beforehand. See this question for more detail about resizing partitions.

I would recommend against this though, as 20GB should be plenty of space for most scenarios, and you there is a real chance of data loss when resizing partitions.