84 MB Minimal Raspbian ARMHF Image for Raspberry Pi

Many embedded systems applications do not require a desktop environment or graphical interface on the screen (e.g. server), and you may want to only install the files you really need on the SD card either to reserve as much space as possible for data and/or your program or to reduce costs.

After searching for a minimal image based on Raspbian ARMHF distribution for the Raspberry, I could only find Linux Systems minimal image based on the Alpha version of the Raspbian Wheezy. Their compressed image is 109 MB in size, has a custom kernel,  sshd and ntpd are enabled, but the wireless tools were deleted, and at the time the swap was located in another partition instead of a file inside the rootfs. The uncompress rootfs is about 414 MB (as reported by df -h when mounted as a loop device).

I decided to prepare a minimal image myself based on the first Raspbian Wheezy release, that supports about the same features of the image mentioned above, plus support for the wireless tools. I’ll describe how I proceeded below, but for those who are only interested in the image, and could not care less how it was done, here’s the download link (84 MB compressed image). The username / password are the same: pi /raspberry.

Upon the first boot you can change the time zone:


This image only support US keyboard layout and English locale, if you need to change those:


If you are mainly going to access your board via ssh, you probably don’t need those.

Instructions to Generate a Minimal Raspbian Image

I’ve downloaded the image via BiTorrent and copied it to the SD card using dd. During the first boot, I configured the keyboard to US layout, Bangkok timezone, enabled SSH and disabled X are started and did not resize the partition.

Now let’s have a look at the rootfs usage:


We’ve got 1.4 GB used, so we’ll need to delete about 1 GB.

The steps below are not optimized, and I’ve just described the way I did it.
As I login to the Raspberry Pi as pi user, the first thing I see is a directory called python_games. Sorry kids, but:


Then I vaguely remember some things that are pre-installed in the image by default, so I removed those:


Those two steps only shoved around 100 MB, so it’s not such a good start, but it’s still progress. I miraculously remember a command to find large file in Linux:


Now that’s more interesting! The first 3 files are the apt caches and the swap, we’ll take care of those at the end. Some icon takes appear to take a lot of space, the .a file show there are some development libs installed and the last file reminded me there’s some Raspberry media sample code.

Let’s take care of those code samples:


Now I need to find a way to list development packages installed in the system. Luckily there is a command to list installed packages, which I can filter to list development packages:


Good! Let’s remove those:


Let’s remove python and some other packages (LXDE, omxplayer…)that do not look necessary in a minimal image.

sudo apt-get remove sudo dpkg --get-selections | grep -v "deinstall" | grep python | sed s/install//
sudo apt-get remove lxde-common lxde-icon-theme omxplayer raspi-config

At this point I just discovered there were still some x11 packages, and realized this should have been the first thing I had removed since it would get rid of several hundred MB of data:

sudo apt-get remove sudo dpkg --get-selections | grep -v "deinstall" | grep x11 | sed s/install//

Let’s say we don’t need audio support either:

sudo apt-get remove sudo dpkg --get-selections | grep -v "deinstall" | grep sound | sed s/install//

As I mentioned above, we would still like to have ssh access, but we don’t need to use the default sshd, and we can replace it with the lightweight dropbear ssh server:

sudo apt-get remove sudo dpkg --get-selections | grep -v "deinstall" | grep ssh | sed s/install//
sudo apt-get install dropbear

We now have 550 MB used space in the rootfs, minus the 100 MB swap file, that’s still 450 MB which is well above the 414 MB for Linux Systems image. I can see gcc is still there, and we should not need to build anything directly on the device. let’s remove it!:

sudo apt-get remove sudo dpkg --get-selections | grep -v "deinstall" | grep gcc\- | sed s/install//
After this operation, 234 MB disk space will be freed.
You are about to do something potentially harmful.
To continue type in the phrase 'Yes, do as I say!'
?] no

OK, this was a bad idea, and I answered no. So instead,  I decided to only keep gcc 4.7:


After some more time trying to find non-essentials packages, I removed a few others, and call autoremove to delete unused packages.

sudo apt-get remove ca-certificates libraspberrypi-doc xkb-data fonts-freefont-ttf locales manpages
sudo apt-get autoremove

Almost done. Since we won’t use apt-get anymore, let’s clean apt-get cache:


Let’s disable swappping, and fill the swap file with zeros:


Delete the logs


Check the size:


Yes! That 461 MB including swap file. Time to turn off the Pi:


Now, we can remove the SD card from the Raspberry Pi board, and access it from a Linux PC to create an image.


We can mount the root and use sfill to fill free space with zeros:


and finally compress the image with 7z using ultra settings:

7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on 2012-07-15-wheezy-raspian-minimal.img.7z 2012-07-15-wheezy-raspian-minimal.img

Done. We now have a 84 MB minimal Raspbian image.

It’s certainly possible to even go slightly lower, as a basic debootstrap of Debian unstable comes out at 269MB uncompressed, and using Emdebian Grip might even allow a ~100 MB uncompressed rootfs with all the features we need, but I doubt this option is available with Raspbian mirrors (TBC).

Leave a Reply

90 Comments on "84 MB Minimal Raspbian ARMHF Image for Raspberry Pi"

avatar
  Subscribe  
newest oldest most voted
Notify of
trackback

[…] Linux distribution (e.g. Raspbian) if space if not an issue, but all what I did below is based on Raspbian minimal image.Install ngnix, php and mysql in the server:sudo apt-get update sudo apt-get install nginx php5-fpm […]

trackback

[…] my quest to put Raspbian on a diet I stumbled across this.  It appears CNXSoft has already done what I set out to do so why try to reinvent the wheel.  Go […]

dave m
Guest

Great post, thanks.

rew
Guest

Hi, You forgot to mention the “mkswap /var/swap”

Matias
Guest

Deleting the whole /opt directory is not a wise thing, because you will lose the ability to change resolutions and use OpenGL. I guess you can remove “include” and “src” directories, however “bin”, “lib” and “sbin” should be spared.

Nicolás
Guest

Hi!
Thanks for this great post!!!
It would be great if you release this article’s instructions as a shell script, so everyone can follow your steps easily!
Regards

sophana
Guest

Hi, thanks for the image.
I found out that there is no sftp-server in openssh-server
I had to do a: “apt-get install openssh-server –reinstall” to get it back
removing useless packages is a good thing.
But removing files from packages is not a good idea.
Are there any other files deleted like this?

sophana
Guest

@cnxsoft
strange, so there’s something I don’t understand well in debian…

dpkg -L openssh-server gave me a list of files, which was much smaller than now after I reinstalled.

Artem Sidorenko
Guest

Thanks for creation of this howto and image,
But please add following steps to your howto/image:
#SWAP
sudo swapoff -a
cd /var
sudo dd if=/dev/zero of=swap bs=1M count=100
#We have to put the swap signature
mkswap /var/swap

#Optional: Regeration of SSH keys (I’m using openssh and not dropbear)
#Take a look to the original image, copy the script /etc/init.d/regenerate_ssh_host_keys to your image
chmod +x /etc/init.d/regenerate_ssh_host_keys
update-rc.d regenerate_ssh_host_keys defaults
update-rc.d ssh disable
rm -f /etc/ssh/ssh_host_*

v1ncen7
Guest

hunting for MBs 🙂

sudo apt-get remove liblapack3
sudo apt-get remove libatlas3-base
sudo apt-get remove penguins puzzle
sudo apt-get remove gdb

v1ncen7
Guest

I meant sudo apt-get remove penguinspuzzle

Pieter-Jan
Guest

Thanks for this! Definitely going to try this!!

DrB
Guest

Using “apt-get purge” instead of “remove” will drop the configs and save some more bytes.

Chris Hatton
Guest

When will someone produce an image which is actually shrunk to fit? It’s easy to expand an image once its copied onto a card, not so easy to shrink one down using loopback or some other method beforehand. I want to run a minimal distro on 512Mb card. I can’t be the only one?

Adwin
Guest

You can also drop the docs & man for an additional 44Mb:
rm -fr /usr/share/doc/* /usr/share/man/*

DrB
Guest

@cnxsoft
The manpages are part of the individual packages. Deleting them, is a hack, this
will damage the package consistency.

[email protected]:~ # dpkg -S /usr/share/man/man8/fdisk.8.gz
util-linux: /usr/share/man/man8/fdisk.8.gz

jtoledano
Guest

Wil dropbear suppor sftp with some pach

gnrl
Guest

thank for this great tutorial. I’m on a 2GB disk and after yate and dc++ hub (probably 4MB), and it’s out of space. It’s terrible how much space is wasted. Do people even use that crap?

Sander
Guest

FWIW http://www.raspberrypi.org/phpBB3/viewtopic.php?f=66&t=17028 offers a ready-to-run minimal Raspbian.

Samuel HERMANN
Guest

thank you very much for your tutorial ! Its really helps me 😉

Georg Bisseling
Guest

Hi,

Having a smaller image is a very appealing idea.

I just wanted to give the minimal image a try in the hope to use one of my 128 MB or 256 MB SD cards. Unfortunately the image is tailored to a 2 GB card. How much is actually needed? Would it be possible to provide a smaller image?

I tried to copy the image to a 256 MB card and to fix the partition table, but fdisk complained even about the start of the partitions so I refrained from further experiments.

Nice work though!

Andre
Guest

Hi,
I am pretty new to this and recently I downloaded one of the images online.
However, this one had at boot a logo which I wanted to remove.
If I use your image, will there be an option to enable splash or a simple picture as log at boot time?
If so, in which file can I change the boot logo?

Ps.: nice work as you make it sound easy even for a newbe like me.

trackback

[…] CNXSoft’s minimal image based on Raspian or D/L […]

Witiko
Guest

@Matias
You don’t need either when you’re not using a graphical environment, do you?

Matthew
Guest

Andre :
Hi,
I am pretty new to this and recently I downloaded one of the images online.
However, this one had at boot a logo which I wanted to remove.
If I use your image, will there be an option to enable splash or a simple picture as log at boot time?
If so, in which file can I change the boot logo?
Ps.: nice work as you make it sound easy even for a newbe like me.

Search online for a “plymouth” tutorial. “plymouth” allows you to have a custom boot animation/logo.

Will
Guest

Some others you may want to consider removing:

not needed if you don’t have a desktop and are running headless:
menu
menu-xdg
xdg-utils
desktop-file-utils
raspberrypi-artwork

If your not going to do anything wireless
libiw30, wpa-supplicant, wireless-tools

network filesystem stuff
samba-common
smbclient
cifs-utils
nfs-common

A couple of others
parted
nano / ed vim / vim-tiny Whichever you dont use
dpkg-dev

Andres Misiak
Guest

Exelent!! Thank’s was very helpfull

Benjamin
Guest

Yeah ya,

I’m just performing your cleanup on a new 2013.05 Raspbian Image and I got to notice the following. First you just use apt-get remove, but since you want to get rid of the packages at all you better should use apt-get purge which will also remove any configuration etc file 🙂 Freeed up another 40 MB or so 🙂 (as mentioned before by DrB)

apt-get purge dpkg --get-selections | grep deinstall | sed s/deinstall//

In doing all the stuff from your post and stuff mentioned in the comments, I get an rootfs of 675MB. There is still the icon-theme.cache around (74MB), apt’s cache not cleared, logs still in place etc. So you could say can squeeze another 100MB out of it (maybe more).

Thanks again for the info

trackback

[…] year I wrote instructions and download link about a minimal image for Raspberry Pi based on Raspbian. The compressed image is 84MB, and the good think about it is that you can just […]

RajaRaviVarma
Guest

I get an ‘sfill’ command not found error on Ubuntu 12.10. Neither it is available in repository.

RajaRaviVarma
Guest

How to install this minimal image back into the pi?

Liviy
Guest

Hi,

Great read…I’m just trying to do the same with the current version and I’m a little confused where you got your offset & block counts for the mount & dd commands?

Thanks 🙂

Berry
Guest

What’s the password for user ‘root’?

Berry
Guest

@Berry
Solved.
Enter ‘sudo passwd root’ to set the password for root.

trackback

[…] 84 MB Minimal Raspbian ARMHF Image for Raspberry Pi […]

trackback

[…] veel te veel programma’s geïnstalleerd. Deze halen we weg. Hiervoor volgen we een deel van deze handleiding, die ik hier maar even schaamteloos […]

billy.
Guest

Security risk “IMPORTANT”.

I download this image and it’s fantastic awesome. I clone the image to the SDD-Raspberrypi and export the public key to access password less.

After I had clone the same download and I cloned another SDD.

Now I do ssh [email protected] and work my pi1. and I do the same for the pi2 and I have Shell Access…

All the copy’s of this image have the same private key.

As soon you install this image you must to generate a new ssh_keys.

generate a host-key:
# rm -f /etc/dropbear/dropbear/dropbear_*
# dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
# dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
# /etc/init.d/dropbear restart

Please in future releases please delete the keys before generate the image.

NB also the image have keys for openssh If some one install openssh the host it’s vulnerable too.

onebir
Guest

Also check out minibian: http://minibianpi.wordpress.com/

trackback

[…] Instalar una versión mínima de Raspbian, sin GUI, que permite utilizar el Raspberry Pi como un servidor para diferentes […]