Home‎ > ‎Dabbles‎ > ‎RaspberryPi‎ > ‎

RaspberryPi 111 - Shrinking the Pi

posted Oct 18, 2015, 6:47 PM by Joshua S   [ updated Nov 12, 2015, 6:01 PM ]
This tutorial will work to remove a number of unused packages.  This has the benefit of allowing the Pi to run more quickly by removing these processes from memory, and removing potential security vulnerabilities by removing unused packages.

With any of the Dabbles on this site, if you have questions, suggestions, or thoughts, please feel free to send me an eMail (I'm still working to figure out how to enable comments on Google Sites -- suggestions would be appreciated)!


Supply List:
  • RaspberryPi  The actual RaspberryPi hardware this will all be built around.  In this tutorial, a Raspberry Pi 2 is used and has a memory card with the Raspbian operating system pre-installed.
  • PuTTY SSH Client – PuTTY is a free and open-source terminal emulator, serial console and network file transfer application. It supports several network protocols, including SCP, SSH, Telnet, rlogin, and raw socket connection.  Other SSH tools can be used, but this tutorial will leverage PuTTY.
Prerequisites:

Project:
  • I know I said this guide was going to be comprehensive and not skip any steps, so what better way to start this off than by skipping steps.  I am not writing out instructions for the following (and illustrating from XKCD):
    • Buying a MicroSD Card
    • Buying a RaspberryPi 
    • Finding the IP Address of your Pi
      • This can be done in many ways, including on your router or using an IP scanner such as (AngryIP Scanner or NMAP) -- if there are requests from the "Contact Me" form; I'll look to create a tutorial for this.
    • Obtaining and installing PuTTY
https://xkcd.com/1343/
  • Using PuTTY (or the SSH client of your choice) enter the IP Address or DNS Name of the RaspberryPi.
  • If this is the first time you connect, you will get a warning that the RaspberryPi's host key is unknown.  Click "Accept" or "Connect Once" to proceed with the connection.
  • Once connected, log onto the Pi using the default credentials:
    • UserID:  pi 
    • Password:  raspberry
  • We'll start by removing unused locales by installing the localepurge package.  The package will automatically run upon install -- make sure to select the right locale to keep and deselect all others using the space bar.  In the configuration tutorial, it was advised you select UTF-8 and in my example, I chose US as that is my country.
sudo apt-get install -y localepurge
      • localepurge – The software to remove unused locales and keep them removed into the future.






  • Now, let's remove the Python Games since you need to log onto the graphical interface to play these.
sudo rm -rf python_games

  • Next, let's remove the key unused packages such as anything related to graphics, graphical only text editors (midori), and graphical development environments (scratch).  Note, several packages will not be located (you're using wildcards) and you will see errors as a result. 
sudo apt-get -y purge console-setup desktop-file-utils desktop.* gnome.* gtk.* gsfonts gvfs.* libgtk.* libqt.* libxcb.* libxcomposite libxcursor libxdamage libxdmcp libxext libxfont.* libxft libxi libxinerama libxkbfile libxklavier libxmu libxpm libxrandr libxrender libxres libxt.* libxxf86 lightdm lxappearance lxde.* lxinput lxmenu.* lxpanel lxpolkit lxrandr lxsession.* lxshortcut lxtask lxterminal midori obconf omxplayer openbox penguinspuzzle python-tk python3-tk scratch shared-mime-info task-desktop tcl.* tsconf x11.* xarchiver xauth xdg-.* xinit xkb-data xserver.*


  • Let's clean up the display removal using tasksel.
sudo tasksel remove desktop

sudo apt-get -y autoremove
sudo apt-get -y update
sudo apt-get install --fix-broken



  • Now all that's left is to reboot!
sudo reboot

  • Mission accomplished!  You shrunk your RaspberryPi!

Comments