Skip to content

Analyze occupied disk space on your Linux

Published: at 12:00 AM
Disk Image
photo by: Benjamin Lehman

To know how much disk space is occupied on each disk you might run df -h in the terminal. The -h means --human-readable :)

Example output:

Filesystem      Size  Used Avail Use% Mounted on
dev              16G     0   16G   0% /dev
run              16G  2.0M   16G   1% /run
/dev/nvme0n1p2   59G   37G   20G  66% /
tmpfs            16G  202M   16G   2% /dev/shm
tmpfs            16G   41M   16G   1% /tmp
/dev/nvme0n1p3  175G   91G   76G  55% /home
tmpfs           3.2G   88K  3.2G   1% /run/user/1000

In my example, I see my Linux root is occupied up to 66% and only 20G is available. Now I need to see what takes the most space on the root disk. I have a couple of options to check that out. Graphical or TUI :) In this article, we explore two of the best options.

Filelight - Graphical disk-usage information

Since I want to check out the result on my root directory I have to run Filelight with root privileges.

sudo filelight

In the opened window I go for the Scan Root Folder option.

filelight options

In the output, I see Docker has occupied a large amount of space on my disk. About 17G!

filelight output

NCDU - Disk usage analyzer with an ncurses interface

For those who work with a Linux server via ssh and do not have a graphical interface an application with TUI; a terminal user interface; can be very helpful. After installing ncdu just run it on whatever path you need. In my case, I run it on my root directory.

sudo ncdu /

You can easily navigate to each directory using arrow keys.

Now that I found out Docker has occupied a large amount of space on my root disk. I have to transfer its file to a new location without breaking it. In my upcoming article, I will explain how to do it.