Slimming an existing Raspbian install

Raspbian is the definitive full-featured Linux distribution for the Raspberry Pi. As it is tailored for educational use, there is a lot of software that is unnecessary (i.e. bloat) if you intend to use your Pi headless.

While various slimmed down Linux distributions exist for the Raspberry Pi, what if you want to slim down an existing Raspbian install?

I encountered this problem when I hosted a Raspberry Pi with Raspberry Pi Colocation from PCextreme. You’ll get a Raspberry Pi with stock Raspbian, complete with X11 and a bunch of other software unnecessary for use in a datacenter.

Based on the official Raspbian build scripts (previously asb/spindle), you can copy and paste the commands below to uninstall all the extra educational and GUI packages:

The above snippet is available in Github as a gist—I’ll keep it up to date, and feel free to fork it and add/remove whatever other packages you find necessary.

Download and run it with:

sudo cp /etc/network/interfaces /etc/network/interfaces.bak
wget -O
sh ./ | sudo sh

The above backups up/etc/network/interfacesin case it’s deleted (see comments).

Coming soon: how to create your own Raspbian image!

UPDATE [19 Aug 2015]: Robert Ely pointed out that purging raspberrypi-ui-mods will delete your network config—I’ve updated the gist so this package is only removed, not purged. I’ve also added a line from Gareth Jones that will remove the configuration files for packages no longer installed.

UPDATE [06 Jan 2015]: Raspbian now offers a “lite” image that won’t include a lot of this bloat. If you’re setting up a new Raspberry Pi, consider using that image.


Comments powered by Disqus