12MB Minimal Image for Raspberry Pi using the Yocto Project

Last year, I wrote instructions and provided a download link about a minimal image for Raspberry Pi based on Raspbian. The compressed image is 84MB, and the good thing about it is that you can just use apt-get to install packages. The problem is that it’s not actually that small as once it is uncompressed the rootfs is still a massive 414 MB.

So today, I’ll explain how to create a smaller (and custom) image using the Yocto Project, a platform that let you build an embedded Linux distribution matching exactly your project’s requirements. Other advantages are that the build is configurable with config files, so it’s easily reproducible with a few command lines, and it might turn out to be useful to learn more about the Yocto Project as many boards and SoC are now making use of the framework, including Freescale i.MX6 (Wandboard, Olinuxino-imx233, Sabrelite, etc…), the Beagleboard, and Minnowboard to name a few.

If you just want the image, you can download the compressed image (12MB), extract it, use dd to copy it to your SD card, and gparted to resize the rootfs. This is an image that’s only useful for (headless) embedded systems, but more likely than not, you’d want to customize it with the instructions below.

I got started with instructions from pimpmypi, but these are a little old, and now everything seems much simpler. I’ve performed the steps below in a PC running Ubuntu 12.04 LTS, and with most dependencies required (e.g. build-essentials, git) already installed.

First you need to get poky and the meta layer for Raspberry Pi:

dylan is the codename of the latest Yocto Project release (Version 1.4).

Then you can run the following command line to initialize some environment variables and the build directory:

Now edit conf/local.conf with vim or nano to optimize the build speed depending on your PC processor (generally number of threads/cores +1), set the machine as Raspberry Pi, and possibly adjust the GPU memory, by updating or adding the corresponding lines:

You may want to check the README if you want to overclock your R-Pi board, change the rootfs type, add VC-1 or/and MPEG-2 licenses, or disable overscan. All those extra options, including GPU_MEM, can be added by editing config.txt directly in the SD card, but doing it before the build makes the steps automatically reproducible.

You also need to add the path to meta-raspberrypi in conf/bblayers file, so that it looks like:

Now we’re ready to build the image. There are two images possible: rpi-basic-image and rpi-hwup-image, both of will provide a minimal image, but rpi-basic-image will add ssh-server-dropbear (for ssh server support) and splash (for the splash screen). Let’s go with rpi-basic-image:

It took just over one hour in my computer, but it may take less or much more time depending on your computer and/or Internet connection.

Once the build is complete you should see a file called tmp/deploy/images/rpi-basic-image-raspberrypi.rpi-sdimg, which is a symlink to the binary image you want to dump on your SD card. The file size is 80MB, but it can be compressed to 12MB if you want to distribute over the Internet:

Now insert an SD card in your Linux computer, and check the device name:

Since I have a USB hard drive attached to my computer I do this all the time, because sometimes the SD card is /dev/sdb, and other times /dev/sdc, and if I use the wrong one, all my data will be lost.

Let’s copy the image with dd or dd.sh:

Now remove the SD card, and reinsert it. The ext-3 partition in the image is only 55MB, so to make full use of your SD card storage capacity, you need to resize the partition with the command line, or easier, with gparted. Resizing from the Raspberry Pi won’t work with this image, as resize2fs utility is not available.

We’re now ready to try it out. Let’s insert the SD card into the Raspberry Pi, and connect the power. You can access the console via HDMI, the UART port, or if you’ve connected an Ethernet cable via ssh.

Near the end of the boot, or when you access the board with SSH, you should see:

Login with as root without password.

Let’s check some details about the kernel:


available space:

and available memory:

We’ve got a recent kernel, only 42.8MB of the root file system is used, and 232MB RAM available on a Raspberry Pi Model B with 256 MB RAM.

Let’s check the kernel config on the board:

You can download the kernel config for details.

If you want to save even more memory, or add features, you can change the kernel configuration with:

and build the kernel with:

Busybox can also be tuned with the commands:

The images recipes are located in poky/meta-raspberrypi/recipes-core/images, and you you could copy rpi-basic-image.bb to rpi-myappliance-image.bb, and edit the later to add the recipes/packages you need.

But this may be difficult, if you don’t know exactly what you need, and luckily the Yocto Project also have a graphical interface called “hob” that you can just start from the build directory. Let’s start with rpi-hwup-image for the Raspberry Pi by selecting the corresponding machine and base image:


You can then either select “Edit Image” to add recipes and/or package groups, or simply click “Build Image” to start the build. Let’s just do that. The build is now much faster since most packages have already been built when we ran “bitbake rpi-basic-image”.


After a few minutes, you should the “Your image is ready” window below with easy access to the binaries and log files:


If instead of clicking “Build Image”, you clicked on “Edit image” you’d have access to the list of included recipes, all recipes and package groups. In the screenshot below I searched for recipes with “bcm” and “rpi” names. bcm2835 is used for GPIO support, so you may want to include it in the build.


Once you’ve selected the required packages, click on “Build Packages”, and after a while, Step 2 window will appear and let you click on “Build Image”. Your custom SD card image will be available in tmp/deploy/images/ directory with the name hob-image-raspberrypi.rpi-sdimg.

That’s just a small overview of what’s possible with the Yocto Project for the Raspberry Pi board. For further details you may want to check the project’s documentation, and you may also read Hob’s manual for specific details about Yocto’s GUI.

Share this:

Support CNX Software! Donate via cryptocurrencies or become a Patron on Patreon

ROCK Pi 4C Plus
Notify of
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
Weller PCB manufacturer