build your own basic Raspberry Pi Debian image

Debian / Raspberry Pi

Outdated! May I point you to Raspbian Lite Image by the Raspberry Pi Foundation.
Outdated! May I point you to raspbian-ua-netinst.

Seems that I’m one of these lucky guys already received their Raspberry Pi. I ordered it from RS on the 5th and got it on the 10th of May. Posted my unboxing on Google+.

But which distribution should I install? There are many on the downloads page. First choice was the Debian image, because I’m a Debian fanboy! Impressive, but its not Wheezy.

There is already a Debian Wheezy distribution available: Raspbian. But not all packages are ported yet. Let’s come back later.

Another choice is Chris Boot’s Debian Wheezy image with a Linux 3.2 kernel. He has also already prepared a pre-compiled binary for Debian. One great improovement of Chris‘ kernel is that IPv6 is enabled and its based on Linux 3.2! In the meantime, also the stock Raspberry Pi kernel got IPv6 enabled.

By the way, if your Raspberry Pi always hangs during boot at:

Waiting for root device /dev/mmcblk0p2
mmc0: problem reading SD Status register.
mmc0: error -110 whilst initialising SD card

Then just take an other SD card and it would boot like a charm. Hopefully. 🙂

Ok, I also could have upgraded Debian Squeeze to Wheezy, but I’d like to have a basic system without anything, so I decided to debootstrap my own image.

Based on

I’ve developed a script which generates the SD card for your Raspberry Pi on your Desktop PC. You can download it from There you can also download a recently generated image.

Before you start, you should have installed some packages:

# apt-get install binfmt-support qemu qemu-user-static debootstrap kpartx lvm2 dosfstools

As only parameter give the blockdevice of your SD card (like /dev/sdc) and run it as root.

# sudo /dev/sdc

Or just leave the parameters and the script will produce an image file.

The shell script will perform following steps:

  • check for root and blockdevice or create empty file for looping
  • remove MBR on SD card
  • setup new partitions and generate filesystems
  • debootstrap first stage
  • chroot into new system
  • debootstrap second stage
  • create config files
  • install kernel, modules and firmware with Hexxeh’s rpi-update
  • install ntp, openssh-server and some other usefull stuff
  • set root password to raspberry
  • cleanup

If you have created an image, just put it with the following command onto your SD card.

# sudo dd if=<image file> of=<blockdevice of your SD card> bs=1M

Plug the SD card into your Raspberry Pi and power it up. It should boot up with DHCP and the root password is raspberry (what else? 🙂 ).

Enjoy your basic, virgin Debian Wheezy on your Raspberry Pi. Any comments are welcome.

History of
# 2012-06-24
#    just checking for how partitions are called on the system (thanks to Ricky Birtles and Luke Wilkinson)
#    using as debian mirror, see
#    tested successfully in debian squeeze and wheezy VirtualBox
#    added hint for lvm2
#    added debconf-set-selections for kezboard
#    corrected bug in writing to etc/modules
# 2012-06-16
#    improoved handling of local debian mirror
#    added hint for dosfstools (thanks to Mike)
#    added vchiq & snd_bcm2835 to /etc/modules (thanks to Tony Jones)
#    take the value fdisk suggests for the boot partition to start (thanks to Mike)
# 2012-06-02
#    improoved to directly generate an image file with the help of kpartx
#    added deb_local_mirror for generating images with correct sources.list
# 2012-05-27
#    workaround for just touching /boot/start.elf before running rpi-update
# 2012-05-20
#    back to wheezy, solved,
# 2012-05-19
#    stage3: remove eth* from /lib/udev/rules.d/75-persistent-net-generator.rules
#    initial