Click here to Skip to main content
15,888,984 members
Articles / Internet of Things / Raspberry-Pi

Raspberry Pi – Minimize Raspbian OS to under 1 GB

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
29 Nov 2016Ms-PL2 min read 9.1K   4   2
How to minimize Raspbian OS to under 1GB

In a previous blog post, I had mentioned that I had run out of space on the out of the box 4 GB SD card with the Raspbian OS. As it turned out, I found the Raspbian had a lot of pseudo-bloat. The out of the box system comes with components meant alike to be used for software development and as a GUI desktop. I wanted neither of these, as I was running it as a pure WordPress stack server. This meant there was a lot of scope for minimizing Raspbian.

If you know how packages in Linux are organized, you will know that there are a lot of inter-dependencies between them. Even the advanced user would soon get lost in a maze of dependencies. The trick then is to get to the smallest set of packages on which the largest set of installed applications depend. You get rid of those packages then everything depending on them will go away too in a sort of a “cannon-ball tied to the end of a string pushed into the ocean” kind of way.

Taking a look at the list of pre-installed components, among language tools I had only PHP installed, so nothing there to remove. The challenge was X11, that on its own has a ton of packages and then all the X-apps that come installed with it. However, all of them ultimately depend on one package, and that is the libx11. Removing it then is a piece of cake:

# apt-get remove --auto-remove --purge libx11-.*

This will take a long time. It took about 20 minutes on my Raspberry Pi 2. After that, I found some forum threads asking me to install and run a package called “deborphan”. This tool finds orphaned files and packages (that have bad dependency information or got left behind by previous uninstalls) and removes them. However, I decided to skip this, and use apt-get’s own command:

# apt-get autoremove

This command did nothing on my system, indicating it was clean as a whistle.

The next task is to re-role the Raspbian to a non-desktop role. The Debian OS on which the Raspbian is based comes with a tool called “tasksel” to do this for you. To run it:

# tasksel --list-tasks

It will take some time to figure out what roles are installed already. After about nearly a minute, it printed out a bunch of items. Of these, I needed to remove only the “desktop” role. So issue the next command:

# tasksel remove desktop

If all the packages were already removed with the apt-get commands above, this should finish pretty quickly and it did. Although the system did not ask me to, I went ahead and rebooted the Raspberry Pi 2.

From the 4GB plus system I had earlier, the newly minimized system now occupied under 1 GB.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionMinibian Pin
Dominic Amann30-Nov-16 6:30
Dominic Amann30-Nov-16 6:30 
GeneralAlternative Pin
Jochen Arndt29-Nov-16 22:38
professionalJochen Arndt29-Nov-16 22:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.