If you often work with large or many files on the Raspberry Pi, you will sooner or later face the problem that the available memory runs out. That's what happened to me in any case.
Especially with several distributed files, it is not so easy to get an overview of which files and folders consume how much memory. Without further tools you have to switch to each folder individually, list the file content including file size to get an overview of the largest files. Quite cumbersome.
A tool that makes this process much easier is called "ncdu". How to install this tool and how to use it is described in the following article.
Safety instructions
I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.
https://www.nerdiy.de/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 make a purchase via this link, Nerdiy.de will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support Nerdiy.de in being able to offer other useful projects in the future. 🙂
Requirements
Helpful articles:
Before you start with this article, you should have prepared a RaspberryPi 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 RaspberryPi.
- RaspberryPi – setup for nerdiys!
- RaspberryPi – The first configuration!
- RaspberryPi – Control the RaspberryPi via SSH
In the following lists you will find all the parts you need to implement this article.
Required tool:
Number | Link |
---|---|
1x | Screwdriver set Buy at Amazon |
1x | SD card reader Buy at Amazon |
Required material:
Number | Link |
---|---|
1x | Raspberry Pi Buy at Amazon |
1x | Raspberry Pi power supply Buy at Amazon |
1x | Raspberry Pi case Buy at Amazon |
1x | Micro SD card 64GB Buy at Amazon |
Install NCDU
Of course, in order to use NCDU, you need to install it first.
To do this, simply run the following command.
sudo apt update && sudo apt install ncdu -y
Use NCDU to view the memory usage of individual folders and files.
After the installation you can use NCDU without any further configuration.
To start NCDU, simply enter the following command into the console of your Raspberry PI.
ncdu
NCDU then starts and scans all directories starting from the directory in which it was started. 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 finished, you will see an overview of the memory consumption of the folders in this folder level.
With the up and down arrow keys you can now select a folder. As soon as you press the Enter key, NCDU switches to this selected folder and shows you the memory consumption of the folders it contains.
This way you can navigate through all folders and get a very good overview of the storage usage of each folder.
More articles on the topic
You can find more articles about Raspberry Pi in the following category.
Have fun with the project
I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂
PS 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 think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂