There are lots of filesystems images for various Debian flavours on ARM developer boards like the Cubietruck floating about. Most of these images are large binary files of unknown providence and even compressed take a while to download. There is a better way of making a root image for your new ARM board, just build it on your own normal workstation directly from the Debian repos with debootstrap using the magic of QEMU.

First install the support packages on your workstation:

sudo apt-get install qemu-user-static debootstrap binfmt-support

You will need about 500MB of space in a directory for the image, choose the version of Debian in this case we are building a wheezy image.


Lets get going building the first stage of the rootfs image from the Debian mirrors, this will take a few minutes and downloads about 200MB.

mkdir $targetdir
sudo debootstrap --arch=armhf --foreign $distro $targetdir

Next copy the the qemu-arm-static binary into the right place for the binfmt packages to find it and copy in resolv.conf from the host.

sudo cp /usr/bin/qemu-arm-static $targetdir/usr/bin/
sudo cp /etc/resolv.conf $targetdir/etc

We now have a very basic armhf rootfs in a directory, the next stages take place inside a chroot of that directory.

sudo chroot $targetdir

Inside the chroot we need to set up the environment again

export LANG=C

Now we need to complete the second stage of debootstrap to install the packages downloaded earlier

/debootstrap/debootstrap --second-stage

Once the package installation has finished, setup some basic support files

cat <<EOT > /etc/apt/sources.list
deb $distro main contrib non-free
deb-src $distro main contrib non-free
deb $distro-updates main contrib non-free
deb-src $distro-updates main contrib non-free
deb $distro/updates main contrib non-free
deb-src $distro/updates main contrib non-free

cat <<EOT > /etc/apt/apt.conf.d/71-no-recommends
APT::Install-Recommends "0";
APT::Install-Suggests "0";

Pull in the latest apt database from the Debian mirrors

apt-get update

Install the locales package otherwise dpkg scripts, note in jessie you may need to install the dialog package as well.

apt-get install locales dialog
dpkg-reconfigure locales

Install some additional packages inside the chroot, an ssh server for network access and ntp because many boards don’t have a functional RTC.

apt-get install openssh-server ntpdate

Set a root password so you can login via ssh or the console


Build a basic network interfaces file so that the board will DHCP on eth0

echo <<EOT >> /etc/network/interfaces
allow-hotplug eth0
iface eth0 inet dhcp

Set the hostname

echo debian-armhf > /etc/hostname

Enable the serial console, Debian sysvinit way

echo T0:2345:respawn:/sbin/getty -L ttyS0 115200 vt100 >> /etc/inittab

We are done inside the chroot, so quit the chroot shell


Tidy up the support files

sudo rm $targetdir/etc/resolv.conf
sudo rm $targetdir/usr/bin/qemu-arm-static

You now have a root file system for pretty much any armhf machine but next you need to make a bootable sd card image. I’ll cover that in the next post, there are other howtos to assemble the bootable card.