Check and Clear Disk Space on Ubuntu

Feb 3, 2019

Check disk space by drive

df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            2.0G  4.0K  2.0G   1% /dev
tmpfs           396M  1.7M  394M   1% /run
/dev/sda5        14G   13G  601M  96% /
/dev/sdb1       5.8G  5.1G  462M  92% /media/disk02

Check disk space usage per directory

The best tool to check for disk space usage is ncdu.

sudo apt-get install ncdusudo ncdu

NOTE: run with sudo to make sure you can access all the files.

Sample output.

    1.1 GiB [##########] /vue                                                   
    1.0 GiB [######### ] /google-cloud-sdk
  429.6 MiB [###       ] /python
  283.7 MiB [##        ] /node
  220.8 MiB [##        ] /google_appengine
  203.9 MiB [#         ] /php
  182.0 MiB [#         ] /hugo
  138.4 MiB [#         ] /webpack
  135.6 MiB [#         ] /cache
   81.0 MiB [          ] /data

Remove old linux kernel images

Each version of linux kernel is about 200-300MB, refer to How To Remove Old Linux Kernel Images.

Inode Problem

It’s possible to bump into Error: no space left on device while there are still plenty of space. One possibility is you run out of inode. Refer to check free inode.

❀️ Is this article helpful?

Buy me a coffee β˜• or support my work via PayPal to keep this space πŸ–– and ad-free.

Do send some πŸ’– to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

πŸ‘Ά Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.