My Raspbian Image

SD card with RPi logo As I never intended to use the Raspberry Pi as a desk top computer, I was never really interested in the Graphical User Interface of Raspian. All I really wanted was a simple shell interface for my projects. The GUI was just overkill for me.
In the beginning everything fitted nicely on a 2GB SD card. But gradually the official Raspbian image grew larger and larger, until it required at least a 4GB SD card. That's why I've decided to shrink everything down, removing the GUI to reduce the image size of the distribution to make it fit on a 2GB SD card again.

However ever since the Raspberry Pi 2 is out, more and more people seem to use it as a desktop computer replacement. The fully featured images of Raspbian Jessie doesn't even fit on a 4GB SD card anymore. But fortunately you can now officially download a small image from the Raspberry Pi website, which has no GUI or office software installed. This is ideal for all my Raspberry Pi version 1 boards, as they don't perform very well with these heavy programs anyway.

So basically I don't have to shrink the images down myself anymore, which would make most of this page obsolete now. However some of the settings of this official small image are not to my satisfaction. That's why I keep this page alive anyway.
The shrinked down Jessie version I offer here is basically the official package with just a few tweaks which I tend to make to every installation anyway. That way I only have to do these tweaks only once. What tweaks I have made can be read below.

How To Write An Image To SD Card Using A Linux Computer

Once you have download an image file, any image not only mine, you can write it on an SD card of at least the size of the image. First you'll need to find out what device name your SD card will have on your computer.
Before inserting the SD card into your computer's card reader type the next command in the terminal:

df -h

Then insert the SD card into the card reader and repeat the command. The first field of the line which wasn't there the first time contains the device name of your SD card. It usually is the last line of the list and it usually looks like /dev/sdc1 (the c can be any other letter). I'll use this device name throughout the rest of this page. You will have to replace it with your particular device name of course. Be careful, using the wrong device name will probably over write some other partition, destroying all its data!
Now unmount the SD card, but leave it in the card reader. Type the next command:

umount /dev/sdc1

If you want to re-use an SD card which you have previously used in your Raspberry Pi there will be two partitions. Simply unmount both of them before you continue.

Use the cd command to change into the directory which holds the downloaded and unpacked image file you want to write to the SD card. Then give the next command to actually write the image to the card:

sudo dd bs=1M if=imagefile of=/dev/sdc

This will take quite a while. Don't be surprised if it takes over 5 minutes to complete. Of course you'll have to replace imagefile with the actual name of the image file. And please note that the device name no longer contains the partition number, it's now called plainly /dev/sdc.

How To Make A Copy Of Your SD Card On A Linux Computer

Now I'll explain the reverse process, reading the card back to your computer. Perhaps you have made some tweaks of your own and want to save them so you can easily copy it all to a new card, or you want to keep a backup of your card in case something goes wrong.

You can't just copy the files from the SD card to create an image. However, creating an image is as simple as reversing the if and of parameters in the previous command. But before you can do that you'll have to insert the SD card into the computer and then unmount the two partitions which are now present on your SD card. The reason why there are 2 partitions now is because the GPU has its own FAT formatted partition of about 56MB. This GPU is the first to start after booting your Raspberry Pi. Once it's started it will boot the CPU using the second EXT4 formatted partition. Obviously you'll need a copy of both to make a complete image.

umount /dev/sdc1
umount /dev/sdc2

Then it's only a matter of entering the command below.

sudo dd bs=1M of=newimagefile if=/dev/sdc

Don't forget to give your newimagefile a proper name and to use the correct device, as described above. And B.T.W., since you had to use sudo to read directly from the SD card reader device, the image file is now owned by root. You can easily change that after reading to the user pi (or any other user) with sudo chown pi:pi newimagefile .

Some Extra Preparation

That is basically all you have to do to make a backup image of your SD card. However you may want to consider the next preparations. I make these preparations because I want the image to be as small as possible so it downloads faster. Another reason is that the images started out to be some 3GB in size, while I want to support 2GB cards, so I'll have to reduce the image size.
You don't necessarily have to follow both steps though. But remember that if you don't shrink the image you can only write it back to cards with the same or bigger size than the one you took the image from. So if you have expanded your file system to 8GB, you won't be able to write it back to smaller cards, even if only 1GB of the image is actually used.

Erase Unused Space

Deleting all the GUI related programs from the SD card leaves over 1GB of garbage on the free sectors on the SD card. This doesn't compress very well. I want to compress the image file, so it will download faster. Nothing compresses better than repeating data. So it's best to erase all unused space on the SD card before you make a copy of it.

On the Raspberry Pi execute df -m | grep rootfs | awk '{ print $4 }' . This command will show you the amount of free disk space in Mega Bytes. Subtract 1 or 2 from that number (we don't want to rob the Raspberry Pi of all of its free space while it is running) and use that number in the next command to replace the xxxx.

dd if=/dev/zero of=somefilename bs=1M count=xxxx
rm somefilename

The first command will write zeroes into the file somefilename until the entire free space of the SD card is filled (this may take a while, don't worry). Immediately after that you must erase the file, to free the disk space again. Now almost all free disk space is filled with zeroes, which compresses brilliantly.

The free space is clean now. So don't mess about with the Raspberry Pi too much from now on, until you have made your backup image. With anything you do from now on, while your Raspberry Pi keeps running, you risk polluting the free space again. So execute sudo halt -p to switch off your Raspberry Pi as soon as possible.

Shrinking The Image

For that I would like to call in the help of an expert, gparted in this case. Gparted can be installed on your Linux desktop computer, or it can be run as live image from USB stick or CD-Rom.
Shrinking is then only a matter of inserting the SD card into your desktop computer, start Gparted, select the partition to shrink and press "Apply all operations". Obviously you'll need to shrink the Ext4 partition of the SD card, not the FAT partition.

Don't over do the shrinking though. You'll want some free space on the image for the Raspberry Pi to use once it boots up again. Leaving about 300MB should be perfect I suppose.

Now the process of creating an image from the card is somewhat different from the method described before. The previous method would make an image of the same size as the SD card. My image was created from the 3.3GB original image burned onto an 8GB SD card. And even after shrinking it to 1.7GB this would still create an image file of 8GB, thank you very much.
We can simply correct this by telling the dd command how much of the SD card it should read. While we are still running Gparted we can find out exactly how big the part is that we should read. Right click on the second partition, the EXT4 formatted partition. That also happens to be the last partition which is allocated. There should be nothing but free space behind it. Then click the "Information" option. That will give you the following screen:

Partition information

Take a note of the last sector number (3399679 in this case) and add 1 to that (we started counting from 0). The number you get now is the total number of sectors from the start of the SD card until the last sector of the allocated area of the SD card. Obviously that is the number of sectors the dd command should read. A sector is 512 bytes in size, so we need to make the block size 512, instead of the usual 1M. So here we go, this is the command you should give, with the information taken from this example:

sudo dd if=/dev/sdc of="imagename.img" bs=512 count=3399680

In this case you'll get an image with the size of 1.7GB. Small enough to fit on a 2GB SD card, or any size above that. Once you've started your Raspberry Pi from a copy of this image you can run the sudo raspoi-config program to expand the file system to the full size of your SD card again, which ever size that me be.

How I Prepare My Image

Here's a step by step tear down of what I do to create my image. You don't have to do these if you don't want to because you can download the final result further down the page.

Configuration

After downloading the lite image from the official Raspberry Pi website it is written on an SD card which is at least 2GB in size. Then the Raspberry Pi is started using this SD card. As of version 2016-11-29 resizing the root partition is started automatically at first boot, so I don't have to change that. Doesn't matter, I'm going to shrink it later on to make the image smaller to download anyway.
On Raspbian Jessie-Lite I have to start raspi-config manually.
This is what I do there:

  • Set boot to text console (very important, because we won't have a GUI any more once we're finished)
  • Set Wait for network at boot to Slow
  • Set locale to en_US.UTF-8 and nl_NL.UTF-8 (disabling en_GB.UTF-8)
  • Set keyboard to a standard US
  • Set time zone to CET (Amsterdam)
  • Disable overscan (just in case)
  • Set memory split to 16MB
  • Enable ssh server
  • Disable VNC, spi, i2c, 1-wire and serial console
  • Force audio out through 3.5mm jack

If you don't like my settings you can easily change them to your liking by running the sudo raspi-config program again.

On Raspbian Jessie-Lite adding the locale en_US.UTF-8 automatically fixes the error messages you would normally get when you log in to your shell. Updating the software normally would also complain about missing locale schemes, which is also fixed now. So the below errors do not appear any more if you download my version of Raspbian Jessie-Lite.

-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

Update Everything

This is a very important step. It is so important that I shouldn't have actually mentioned it. It should be second nature to a Linux user.

sudo apt-get update
sudo apt-get -y upgrade

User Name, Password And Host Name

Normally this is something you want to do immediately too. However I don't do that here because I'm going to share the image with you. So I'll keep the default user pi and his password raspberry as it was from the original image. Changing the host name can easily be done with the raspi-config script nowadays.

There is one little thing I have changed to increase the security. In Linux you can execute commands as super user by preceding sudo to the command you want to executed. It is customary that you'll have to enter your password before the command is executed. Not so in Raspbian, there you don't have to enter the password.
Although it is convenient, I don't like it very much. So I've taken the liberty to change that. As of version 2016-11-29 this is done by deleting (or renaming) a file in /etc/sudoers.d . I have chosen to rename the file 010_pi-nopasswd to 010_pi-nopasswd.disabled.

Disable Sleep Mode

I hate it when the screen blanks out, just because I haven't touched a key in the last 15 seconds. It's no use having a screen saver for an LCD monitor anyway. So I really want to disable the screen saver. As we are no longer going to have a GUI, we only have to disable the text mode screen saver.
Execute sudo nano /etc/kbd/config and change the line BLANK_TIME=30 into BLANKD_TIME=0. And change the line POWERDOWN_TIME=30 into POWERDOWN_TIME=0. Then reboot, or reload the kbd daemon by typing sudo service kbd restart.

This used to be enough. However I've discovered that despite of all this the screen still blanks after 15 minutes of keyboard idle time. To fix this, hopefully once and for all you'll, have to type sudo nano /etc/rc.local and add the following line, just before the line containing exit 0.

setterm -blank 0 -powerdown 0 -powersave off

Install Some Useful Tools

Now that we have plenty of free disk space again we can add some useful tools. Don't worry, it's all fairly small stuff.

sudo apt-get install screen htop links lynx sshfs silversearcher-ag
sudo apt-get autoclean

As a bonus I'll throw in my .screenrc file, which makes the screen command even a little better.

Directories

I have added 3 of my favourite directories in the main user's home directory, mkdir bin src tmp. The bin directory will hold my scripts and my own programs. It will automatically be included to the $PATH on the next login.
I use the src directory for writing my software in. And the tmp directory is used for temporary junk.

Clean Up

We're almost ready, let's clean up a bit. I delete my bash history so you can't see what mistakes I've made :-) And I delete everything from the .ssh directory, which might contain some information from my own network. Then we can clear all the unused disk space as I've described above.

Then we're done! We have our selves a basic, text only, Raspbian image. You can download the result below.

Download

Download Raspbian with no GUI Raspbian Jessie with no GUI

Download the 2017-04-10-raspbian-jessie-nox image file, based on the original 2017-04-10-raspbian-jessie-lite.img. It will fit on an SD card of at least 2GB.
Last updated on 2017-0-12.

What To Do After First Boot

You have downloaded my image and burned it on an SD card, now what?

First of all you'll have to log in to your Raspberry Pi. You can do that using an LCD monitor or TV and a USB keyboard. However if you want to login to your Raspberry Pi while it is not connected to a monitor you'll have to setup an ssh connection. To do that you'll need to know its IP address (I assume you have connected your Raspberry Pi to your network using an ethernet cable). On a Linux machine this is very easy, execute the command sudo nmap -sP 192.168.1.0/24 (assuming your network address is 192.168.1.0 with netmask 255.255.255.0). The output of this command looks something like this:

Starting Nmap 6.00 ( http://nmap.org ) at 2015-01-21 11:16 CET
Nmap scan report for 192.168.1.1
Host is up (0.0011s latency).
MAC Address: 00:14:BF:4E:42:67 (Cisco-Linksys)
Nmap scan report for 192.168.1.10
Host is up (0.00038s latency).
MAC Address: 48:5B:39:5C:75:DC (Asustek Computer)
Nmap scan report for 192.168.1.81
Host is up (0.00058s latency).
MAC Address: B8:27:EB:90:C2:C4 (Raspberry Pi Foundation)

I'll leave you to guess which one is the Raspberry Pi in my network. BTW, this command has to be executed as root (hence the sudo in front of it), otherwise you won't see the lines containing the MAC address. And you may have to install nmap, because it rarely is installed out of the box.

Once you know the Raspberry Pi's IP address you can connect to it with the command ssh pi@192.168.1.81. You'll have to replace the IP address with your Raspberry Pi's IP address of course.

As soon as you are logged in for the very first time you can run sudo raspi-config to expand the file system to the maximum size of your SD card. After expanding the file system your Raspberry Pi wants to reboot, after which you can log in again. Then execute the following commands to update the system to the latest release:

sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get clean

After that you certainly should change the password, especially when you intend to connect your Raspberry Pi to the internet. Changing the user name and host name are optional extras. Furthermore you would want to change your locales settings, like character set, keyboard and time zone.
Most of these settings can be done using the program sudo raspi-config. The only thing you can't change with that is the default user name. I've written a special chapter on how that can be done.
And while you're running raspi-config anyway, let's expand the partition size it maximum.

Once you've done all that you'll have a working Raspbian system without a Graphical User Interface but with a reasonable amount of free disk space, even on a 2GB SD card.

Other Real Small Raspbian Based Images

Do you think my image is still way too heavy for you, then you might consider downloading one of these very minimalistic systems.

LinuxSystems

This version can run off a 512kB SD card if you like. I wouldn't recommend it though as these small sized cards are rather old and therefore rather slow. But if speed doesn't matter much to you it is perfectly possible.

You can read about it and download it from this web site.

Raspbian Un-Attended Net Install

Here's a nice little project on Github, which gives you a system which can just boot and install everything you want afterwards. Raspbian-ua-netinst

Diet Pi

Do you think Raspbian ate too many Pies? Then you can send it on a diet.

Minibian - Raspberry Pi

Another minimal Raspbian image for the Raspberry Pi.