Analyze Disk Usage on Raspberry Pi with Ncdu


Ncdu (NCurses Disk Usage) is a curses-based version of the well-known 'du', and provides a fast way to see what directories are using your disk space using command line. A disk usage analyzer with an ncurses interface, aimed to be run on a remote server where you don't have an entire graphical setup, but have to do with a simple SSH connection to Raspberry Pi.

It provides an interface to display the information in a more intuitive way like columns for how much disk space used in megabytes, gigabytes and graphical bar usage, file/directory names, Tree view with sizes,

Preview

[su_spoiler title="Screenshot on Raspberry Pi's SSH" icon="caret" open="yes"] [/su_spoiler]

Install Ncdu

In order for the Raspberry Pi to analyze disk usage from command line you need to install packages on the Raspberry. You are going to need the following packages
  • Ncdu Ncdu is an ncurses-based du viewer. It provides a fast and easy-to-use interface through famous du utility. It allows one to browse through the directories and show percentages of disk usage with ncurses library.
By default ncdu already installed on Raspbian otherwise you can install the ncdu packages, run following command :
sudo apt-get update
sudo apt-get install ncdu

Usage for Ncdu

To use ncdu it's easy as you using ls -l, just enter a directory you want to analyze then run ncdu to analyze the directory or disk usage.

To analyze root directory
sudo ncdu /
To analyze /home/pi directory
ncdu /home/pi

References

  1. Ncurses Disk Usage
  2. ncdu package - Debian's Wiki
  3. Image - Seagate Hard Drive by Robert Scoble / CC BY 2.0

Comments