Free space on Raspberry Pi

I have been using a 16GB SD card (I know, could be larger) in a Raspberry Pi for a few years now and never had a problem but recently I started working in a side project and decided to use Docker on this Pi. Because of this I almost filled the SD card in just a few months.

In this post I’m going to give you a few commands that should help you to reclaim some space in your SD card and continue your experiments or side projects. I take no responsibility for any undesired data loss and I ask you to do the proper research about any of the commands posted here. Enjoy!

Also, very important: please backup the contents of your SD card periodically and especially before you start doing this. To do this, run this on Linux in an unmounted partition (not tested, I’m using Windows right now. Yes I know!).

If you are using Windows use Win32DiskImager, type a file name for your backup image, select your SD card and click Read.

When looking for this topic online the first tip was to remove WolframAlpha and LibreOffice. The thing is, if you want to use Raspbian in a Raspberry Pi that will serve only as a server you want to choose Raspbian Lite and not the full desktop version. In any case, if you already installed the desktop version run the following commands to remove WolframAlpha and LibreOffice:

If you use Pi-hole you can remove the SQLite database created by Pihole to store logs:

You can also clean the APT cache and remove any unused dependencies.

And finally, run the following command to clean your Docker cache (don’t worry, you need to confirm after running the command):

After cleaning everything run a command to see your available space:

If you still don’t have enough available space run this command in your root system folder for getting which folders/files are using most of the space in your card:

You will need to check these folders/file one by one and use your judgement to see if they can be deleted or not. Normally you can delete everything from your /tmp folder but I wouldn’t mess with anything else.

I hope this helped you, have a good day!

comments powered by Disqus