Home Raspberry Pi How to free space on your Raspberry Pi SD card

How to free space on your Raspberry Pi SD card

The primary storage medium for a Raspberry Pi is an SD card. Running out of space while working on your projects is possible and may hinder/ limit your operations. The Raspbian image is a downloadable ISO file whose primary purpose is to boot the Raspberry Pi onto an APC.

The Raspberry Pi is available on their official website in two sizes. Therefore, whenever your Raspberry Pi is nearly full, you can free space by reducing the image size. This article will comprehensively cover the tips you require to know to free up to approximately 1 GB of space on your Raspberry’s SD card.

SD card image size

The inclusion of a desktop environment as a larger version in a Raspberry Pi brings about the differences in the size of the two images. If you want to have more storage, you should opt for the ‘lite’ image version. This is the most miniature version of the Raspberry Pi images. The lite version will save you some space.

However, if you still find the lite version to be much larger than what you intended, then opt for the “Raspbian stretch lite.” This version download size is about 350MB, and it stretches to around 1.8GB. This will save you a lot of space instead of the ‘Raspbian stretch with Desktop,’ whose download size is about 1.7GB and stretches to around 4.8GB when installed.

After freeing space by selecting the most suitable Raspberry Pi image, you can now look at these other ways to free space on their Raspberry Pi SD card.

To display the current SD card usage in your Raspberry Pi, execute the command below in the terminal:

df –h
raspberry pi, checking current sd card space

Raspberry Pi, Checking current SD card space.

The command shows a display table with the various ‘file systems’ available in your device with their respective ‘size,’ ‘used space,’ ‘available space,’ ‘percentage use,’ and ‘mounted on’ information.

Uninstalling unnecessary packages

  • Libre office is one of the unnecessary packages that comes preinstalled in Raspberry Pi. It is a free and open-source office software that runs on multiple operating systems, such as Linux and Windows. When you consider storage dynamics for your Raspberry Pi, this application should be rendered useless, and you should uninstall it to have more storage on your SD card. For a preinstalled office suite application, one would need at least 250MB of free space. This makes it entirely irrelevant to have Libre office on your Raspberry Pi if you intend to increase and free up more space.
  • Scratch is another free program in a Raspberry Pi usually installed in its operating system to educate people on programming languages. Unfortunately, the program requires at least 90MB of storage, and therefore removing it could save up a little more storage space for your projects when necessary.
  • Wolfram Engine is a program used for physics and math programming in a Raspberry Pi and often requires approximately 700MB to execute its functions successfully. For those with no plans to use the program, uninstalling it would significantly save storage space on your Pi computer.

Note: Apart from uninstalling the mentioned packages, you have to take precautions and enlist all the currently installed packages to decide which programs you can proceed to uninstall to save more space in your Raspberry Pi. To uninstall an application, use the following command syntax:

dpkg --get-selections
dpkg selections

dpkg selections

This command will give you a long output. To prevent inefficiency, it would be as wise to export it as a text file using the following command:

dpkg --get-selections > packages.txt
packages lists

Packages lists

To enlist the packages according to their storage capacities in the Raspberry Pi, use this command;

dpkg-query –Wf ‘${installed-size}\t${package}\n’ | sort –n
enlist packages according to size

Enlist packages according to Size (Small size on the top)

The list may be enormous, but the packages will be arranged from the ones with the least storage at the top and the packages containing the most storage at the bottom of the list.

enlist packages according to size (big files from the bottom)

Enlist Packages according to size (Big files from the bottom)

Cleaning apt-cache

The apt-cache is usually created in a Raspberry Pi while installing and updating packages. The cache created during the process often gets bigger and bigger and needs to be cleared from the device. To remove the cache from your device, use the following command:

sudo apt-get clean

Removing unused packages

There are some unnecessary applications in your Raspberry Pi that you rarely or seldom use for long periods. These applications often occupy and waste your storage with unnecessary data and services, and therefore to free space on your SD card, you should consider uninstalling such applications. To perform this action, use the syntax command below:

sudo apt-get purge –y package name

To uninstall those three packages (mentioned earlier in this tutorial) from your Raspberry Pi device, use the following command:

sudo apt-get purge wolfram-engine libreoffice* scratch –y

unistalling applications using the command lineOtherwise, whatever package you choose to remove from your Raspberry Pi device is entirely up to you to decide.

The ‘-y’ option is used to remove a package with no prompt. Therefore, running a command minus that option lets you know what you are uninstalling so you can verify it before proceeding to the uninstall process. This is much safer if you intend on being sure about the applications you remove on your Pi.

Removing the LibreOffice, Oracle Java, and Wolfram packages can free up to 1GB of storage space on your Raspberry’s SD card.

Recovering additional space

Some packages will remain on your Raspberry SD card after completing the uninstallation process. For instance, you may successfully uninstall Oracle Java from your Pi, but some of its components will remain. This is because these packages occupy additional space, and most of them were installed initially to support the parent application that has already been uninstalled.

To get rid of them, execute the following command:

sudo apt-get autoremove
autoremove applicatations from raspberry pi

Autoremove applications from Raspberry Pi

Once you run the command, now run the ‘clean’ command. This command will clear all the local repositories of the retrieved package files.

sudo apt-get clean

This command will clear up to 40% of your storage on your Raspberry’s SD card.

Generally, the process of freeing up storage space on your Raspberry Pi’s SD card should involve you backing up your files into a USB disk or external hard disk. Once the backup is complete, you could switch to a lightweight Raspbian operating system version such as Picore or the Raspbian Lite. Once done, remove the unnecessary and unwanted packages on the existing SD card for the Raspbian Lite o install. This will aid in free lots of space on your Raspberry Pi card.


This article covered how one can free space on their Raspberry Pi card. If you intend to freeing space on your Pi, you can choose whatever method covered above that suits you. Besides, you can opt for the lite versions of the operating systems as they will help in saving space. We hope the tutorial was helpful. If yes, give a thumbs up via the comments section.

You may also like

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept