Raspberry Pi is a tiny single-board that does not have any internal storage, it uses an external storage device, and obviously larger storage costs you more and you cannot keep changing your storage device because the Raspberry Pi OS is also present on the storage device. So, replacing the storage device means you need to reinstall the OS too. If you are facing space issues then instead of changing the storage device it is recommended to free up some space on disk. In this article, we will present how to free up disk space on Raspberry Pi.
Free Up Raspberry Pi’s Disk Space
If you want to free up space then you can follow the below-written commands:
Command to Check Space
If you want to check the available and used storage on your device then type the below-mentioned command in the terminal:
Command to Display Installed Packages
If you want to display the list of packages installed on Raspberry Pi then use the below-mentioned command:
By running the above command, a long list of installed packages will be displayed on the screen. From there you can track which package you want to remove to free up the disk space.
To save the list of packages to a file use the below-written command:
To Find Out Which Package Has Acquired Most Space
To decide which package, you want to uninstall to empty more and more space, follow the below command to list all packages along with the space acquired by them:
To Remove or Uninstall the Package
To free up the space on Raspberry Pi you will be required to remove some packages. To remove a particular package, you can use any of the below-mentioned commands:
Command 1
Example
There is also another command that can be used to remove the required package. The command is mentioned below
Command 2
Example
To Auto-clean the Space
There is also a command to automatically remove the packages that have not been used for a long time. To automatically remove unnecessary packages, follow the below-mentioned command:
Press y key when asked to continue.
Another command that can be used to free up the space by uninstalling the unused packages present in the repository:
That’s it by uninstalling unused packages a lot of space can be freed.
Conclusion
There are several commands to free up disk space on Raspberry Pi, firstly check the used space in the disk by using the df command, and if you want to check the space acquired by each package the command for that purpose is shared in the article. To remove unnecessary packages, remove or purge commands can be used. If you are required to auto-clean the storage by removing used packages then autoremove or autoclean commands can be used.