Comparison of compressed images
826 MB - Original 2014-06-20-wheezy-raspbian
284 MB - Additional packages added, desktop extras removed
156 MB - Desktop environment removed,
184 MB - As above, with
Short summary of changes
After some initial setup, some common development tools and other utilities were added.
The desktop extras were then removed, followed by the desktop itself. To handle
auto-mounting of USB drives,
udisks-glue was installed as a service using
Being quite large,
Mono was installed after room had been made for it. Wiring Pi is
gpio access, and for dropbox sync,
dbox is used.
Note: less common changes are listed towards the end of the post
- Basic Pi Tips
- First login tasks
- Change Hostname
- Generate new RSA host keys
- Configure WiFi adapter
- SSH login by public key only
- Update dosfstools build
- Add a cron job for dynamic DNS
- Backup installation
- Removing the desktop environment
- Configure automount for usb drives
- Add services using Supervisor
- Install Mono
- Link settings to root profile
- Build and install WiringPi
- Install Transmission
- Dropbox sync using dbox
- Precompiled XBMC
- Connecting to the Pi
Basic Pi Tips
You can copy an image to the SD card, without first extracting it:
To backup an entire SD card to an image file, use
For details on making an optimised
dd image, see
Making a Pi disk image.
First login tasks
The first task after booting the Raspberry Pi, is to set up the environment. For a headless Pi (one without a monitor or keyboard connected), you may want to use a serial connection to login until WiFi and zeroconfig have been configured.
Note that there will be a login message recommending to run
sudo raspi-config. This can
be done later for tasks more specific to the installation, such as expanding the
partition to fill the SD card.
Most of the commands below need root privileges on the Pi, as they alter the system
configuration. To run a single command with root privileges, prepend the
to it. To run many commands this way without typing
sudo each time, first start a root
sudo -s (logout with ‘exit’ or ctrl+d when finished).
Depending upon your uses, you may have a set of packages you install to every fresh Raspbian image. Below are the packages I like to install.
If it’s likely the Pi won’t be the only one using the local network, then it should be given a unique host name.
Generate new RSA host keys
These keys confirm the identity of the Pi, to prevent a malicious host from intercepting the remote login process. Not so important for your HTPi, but good standard security practice. Also recommended if you have more than one Pi.
If you’re using dropbear instead of openssh, then use:
Configure WiFi adapter
Some distributions include WiFi setup as part of the terminal configuration script, but
this functionality is not yet included in
raspi-config. If keeping the desktop
installed, then its network configuration tools can be used. Otherwise, use the
instructions for manual configuration.
SSH login by public key only
If the Pi is open to the internet or a shared WiFi hotspot, it’s recommended to disable SSH password logins (after first setting up public key login).
Update dosfstools build
The current raspbian version of
dosfstools is out of date and won’t reset the ‘dirty bit’
of a FAT volume, such as that used by the
Add a cron job for dynamic DNS
If you have a dynamic DNS entry to keep updated, or another simple command or script to run every so often, then a cron job can be set up to run as a particular user.
At this point we have a Raspbian image with minor tweaks, added/updated packages, and zeroconfig support which provides mDNS/Bonjour discovery of the Pi over a network without needing it’s IP address.
To minimise the time spent installing updates on future install, it’s a good idea to backup the card to a disk image that can be reinstalled later. This will also come in handy if you decide later to revert large changes made after this point (such as removal of the desktop).
Removing the desktop environment
If you only plan to run the terminal environment (and self-hosted programs, such as XBMC), then a lot of space can be recovered by removing x11 and related packages.
At this point, the base desktop system and utilities are still installed. However, over 800MB has already been recovered - so if you just wanted to save a little space, you may want to keep the desktop after all.
Finally, purge packages no longer needed and clean up unused files.
Note: see cnx-software.com for an even lighter install.
Configure automount for usb drives
Install udisks-glue to automount usb drives without starting the desktop.
Note: for startup methods other than
angryelectron.com for an example of
how to add
udisks-glue as a service using a traditional init.d script, or the section:
Add services using Supervisor.
Add services using Supervisor
Supervisor provides a simple way to add user services, without messing with
Create a startup script
Remove the previous startup of
udisks-glue - if already
configured above - and start the new service
by reloading the
udisks-glue program should start automatically on boot. Use
restart to manually control Supervisor programs:
Install Mono development tools, runtime, and interactive shell.
Note: If you’ve previously shrunk the system partition down, it may need to be expanded
sudo raspi-config) to be able to fit the mono installation (about 153MB).
Link settings to root profile
Occasionally you’ll want to use a root shell, and then be annoyed that your aliases etc. are not configured for the root user. You can either copy the profile files into ~/root or, as shown here, link them symbolically so that any future modifications will be reflected.
If you prefer to copy the files into ~root, then replace
ln -sfv with
Build and install WiringPi
WiringPi is a library to access the Pi’s GPIO, SPI, and I2C headers, modelled on the Arduino Wiring system. It also includes the
gpio utility for use of the libraries from the command prompt.
The transmission bittorrent client doesn’t have many dependencies, can be installed as a daemon, and accessed remotely using a Web UI.
The following block includes settings needed to get the Web UI up and running, pasting it before the last setting will replace any definitions duplicated earlier in the file.
Full details on transmission’s config files may be found
here. Other settings such as port
forwarding, bandwidth throttling, and encryption, can be configured from the Web UI
Dropbox sync using dbox
If you’re running raspbian and want to use the same image with XBMC, you can install the base XBMC and required packages as follows (adapted from michael.gorven.za.net):
Connecting to the Pi
With support for zeroconfig installed (via
avahi-daemon), it’s much easier to
find your Pi on the network1.
Note: If multiple Pis are active on the same network, they should be given unique hostnames.
Copy public key to the Pi
Before setting up the Pi remotely, there are some things that can be done locally (on your PC, laptop, etc.) to ease logging in when using SSH. This will obviate the need to enter a password, or specify the full host name each time we access the Pi.
If generating a new key pair, accept the default key location as suggested by
ssh-keygen below. While a passphrase is optional, anyone can use a copy of the unencrypted private key to authenticate with your identity. Many operating systems are preconfigured to use
ssh-agent or a similar utility, to avoid having to enter a passphrase multiple times (if at all).
The easiest way to append a key to the remote user’s
~/.ssh/authorized_keys file is to use
ssh-copy-id as shown above. Download ssh-copy-id from source (or github) if your system doesn’t already have it (installation instructions), this alternative method should also work in most situations.
Add an alias to .ssh/config
Locally define the alias
pi, to be used in place of
ssh commands such as
ssh pi and
sftp pi. Enter the text below as a single command, or
manually paste the quoted text into
nano or similar (the IP
address can be used for
Hostname if preferred).
If you have previous files from your Pi stored locally, you can transfer them using
scp, etc. For easily transferring many arbitrary files , a GUI sftp client is recommended.
Manually configure WiFi adapter
lsusb to check that the adapter is recognised, and
lsmod to check the kernel module (e.g.
8192cu) is loaded.
Make sure the following lines exist in the interfaces file, adding them as needed:
Open the file that configures WiFi hotspots:
Add your network details, using the following template:
Or, more fully as required:
Reinitialise the adapter, and check it’s connected.
iwconfig to view wifi adapter info and
ifconfig for general network info.
Configure bluetooth adapter
*Note: a bluetooth adapter may be listed in
hciconfig, without being recognised by
hcitool. This is the case with the belkin dongle I have, so use
hcitool to check that a device is working properly.
Install aircrack and related tools
Taken from blog.petrilopia.net.
Configure automount for usb drives
If there’s no service already installed to automount usb drives, then udisks-glue can be setup as follows.
Note: see angryelectron.com for an example of how to add udisks-glue as a service when using a traditional init.d script.
Install XBian onto a Raspbian image
Not used with recent versions
Previously useful functionality or workarounds
Clear cached network adapter
(needed for switching cards between devices)
Regional system settings
If the console keyboard is not setup correctly for the en_GB layout, a solution I’ve used before is to install
keyboard-configuration, which only seems to work once
console-setup is also installed.
The latter package will change the console font, but this can be reverted during the commands shown below. Just choose the font you prefer, or choose ‘Do not change the boot/kernel font’.
It should be possible to connect with the hostname even without zeroconfig, e.g.
pi@raspberrypi, but I’ve had no luck with this (except for when the router sets this up via DNS).↩