Raspberry Pi

How to Analyse Storage on Raspberry Pi 4

It is sometimes difficult to increase the system speed because of the presence of some unused apps that require extra storage on your SD card and are difficult to locate. It is necessary for you to look for those high-storage applications and delete them if you do not intend to use them in the future. A single command line will not provide you with your SD card’s storage information. If you are interested in analyzing storage on a Raspberry Pi, read this article, which describes some steps to successfully obtain your storage information of Raspberry Pi 4.

How to analyse storage on Raspberry Pi 4

Here, you will find the right way of analysing your SD card storage through the below mentioned steps and you need to be careful while performing those steps.

You need an analyser tool that will help you to analyse storage on Raspberry Pi 4. Ncdu disk analyser is a specially designed tool aiming to provide you a simple and fast user interface and does not require any complex procedure to install it on Raspberry Pi. You will need to do the steps mentioned below to have it on your Raspberry Pi 4.

Step 1: First make sure that your Raspberry Pi device is displaying properly and is running with adequate power supply.

Step 2: Now you need to open the terminal of Raspberry Pi in order to begin the installation of “ncdu” Disk Analyser.

Step 3: Next, you need to ensure that your packages are updated and for that you need to use the command given below.

$ sudo apt-get update

Step 4: Now, after confirming that the packages are updated, you will need to install “ncdu” on Raspberry Pi. Add the command mentioned below and press the Enter button to start the installation of “ncdu”.

$ sudo apt-get install -y ncdu

There, you will see that it is already installed on your Raspberry Pi. You can check the version of ncdu by entering the command in the terminal shown below.

$ ncdu -v

Step 5: Now to run the Ncdu, type the given command-line in the terminal to have it on your Raspberry Pi screen.

$ ncdu

After entering the ncdu command in the terminal, you will see your required SD card space on Raspberry Pi desktop.

You can even click on any directory to see the contents as well as their sizes. Furthermore, you can delete files by going into the directories and deleting the files that are no longer useful to you.

If you need the storage information of a different directories, you can have it using the below mentioned command.

$ ncdu /

The above command will take a longer time in order to process the storage information of directories and you have to wait until it is finished.

You can then click on any directory and view the storage information of contents in each directory.

If you want to delete the selected file or a directory from the terminal without going into each directory, you can do that pretty well by pressing the “d” key on a given directory or on a file present in the directory as shown below.

You can also see the storage in percentage by pressing the “g” button from your keyboard and you will end up with the below result.

You can also change the order of the directories in ascending order based on their sizes. If you are interested in viewing the directories in ascending order, press the “s” view.

In order to view the directories in descending order, press the “n” button and it successfully arranges the directories in descending order.

If you want to explore more keys you will find them in the help section. You just need to press the “?” key from your keyboard on the main menu of “ncdu” and it will show you the information of different keys. Each key has a different function and it will help you to do the required task with ease on ncdu.

Removing ncdu from Raspberry Pi

If you are not interested in using the features of ncdu on Raspberry Pi, you can remove it by entering the below given command-line in the terminal.

$ sudo apt-get remove ncdu

Enter “Y” to confirm the deletion of ncdu from Raspberry Pi.

Conclusion

Raspberry Pi is packed with useful commands that are specifically designed to make the environment more user friendly. If you are new to the Raspberry Pi environment, you will surely enjoy trying these commands. In this article we learned how to analyse Raspberry Pi storage through terminal commands. There is a utility called “ncdu” which assists in analysing the storage of Raspberry Pi. You can also monitor the storage taken by each directory and delete the unused programs using this utility.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.