HowTo: Raspberry Pi – Get an overview of the available storage with NCDU

If you often work with large or many files on the Raspberry Pi, sooner or later you will face the problem that the available memory is running out. At least that’s what happened to me.

Especially when there are several distributed files, it is not so easy to get an overview of which files and folders are using how much memory. Without additional tools, you have to switch to each folder individually, list the file content including the file size in order to get an overview of the largest files. Pretty cumbersome.

A tool that makes this process much easier is called “ncdu”. How you install this tool and how you can use it is described in the following article.


Safety instructions

I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/en/sicherheitshinweise/

Affiliate links / advertising links

The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and shop via this link, Nerdiy.de receives a commission from the online shop or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support Nerdiy.de in being able to offer further useful projects in the future. 🙂


Requirements

Helpful articles:
Before you start this article, you should have prepared a Raspberry Pi so that it can be reached via the network and controlled via SSH.

The following articles describe what needs to be done to prepare the Raspberry Pi.

In the following lists you will find all the parts you need to implement this article.

Required tool:

NumberLink
1xSchraubendreher Set  Bei Amazon kaufen
1xSD Kartenleser  Bei Amazon kaufen

Required material:

NumberLink
1x Raspberry Pi  Bei Amazon kaufen
1x Raspberry Pi Netzteil  Bei Amazon kaufen
1x Raspberry Pi Gehäuse  Bei Amazon kaufen
1x Micro SD Karte 64GB  Bei Amazon kaufen


Log in via SSH on the RaspberryPi

To get started, you first need to log in to RasPi with SSH on Putty. How to do it is described in the article

After entering your username and password you can start to enter the first commands.

Update package management

The package management in Linux is a "central point" over which various software packages can be installed. For this to work reliably, the lists and sources of package management should be updated before installing any new packages.

To start the package management update you have to enter the following command.
sudo apt-get update && sudo apt-get upgrade
Depending on how long your last update of the package management is, this process can take some time. First, the lists are updated in which the individual repositories are referenced.
Then the packages themselves are updated. As this additional memory is occupied, you will again asked for your consent. You have to confirm this with a "J"(in German) or a "Y" and "Enter".
When the update is complete, you will see a small summary of the duration and scope of the update.

Install NCDU

In order to be able to use NCDU, you must of course install it first.

To do this, simply run the following command.

sudo apt update && sudo apt install ncdu -y


Use NCDU to view memory usage for each folder and file

After installation, you can use NCDU without further configuration.

To start NCDU, simply enter the following command into the console of your Raspberry PI.

ncdu

NCDU starts on it and scans all directories starting from the directory in which it was started. So if you have previously changed to the base directory with “cd /”, NCDU will show you an overview of the complete base directory.

After the scan is completed, you will be shown an overview of the memory consumption of the folders in this folder level.

You can now use the up and down arrow keys to select a folder. As soon as you press the Enter key, NCDU changes to this selected folder and shows you the memory consumption of the folders it contains.

In this way you can navigate through all folders and get a very good overview of the memory usage of each folder.


More articles on the topic

In the following category you will find further links on the subject of Rasperry PI.


Have fun with the project

I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂

P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂

Buy Me a Coffee at ko-fi.com   

Leave a Reply

Your email address will not be published. Required fields are marked *