I'm building a custom SD image of Raspbian using debootstrap, and the resulting image fails to boot with Kernel panic - not syncing: No init found. on both my Raspberry Pi and under qemu. I can successfully boot the 2012-07-15-wheezy-raspbian image on both (although with a different SD card on the Pi). For qemu I'm using the kernel from XEC Design.

% qemu-system-arm -M versatilepb -cpu arm1136 -kernel /usr/local/share/qemu/kernel-qemu -m 256 -drive file=raspbian3.img -serial stdio -append "dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=tty1,115200 console=tty1 root=/dev/sda2 elevator=noop"
EXT3-fs (sda2): error: couldn't mount because of unsupported optional features (240)
EXT2-fs (sda2): error: couldn't mount because of unsupported optional features (240)
EXT4-fs (sda2): mounted filesystem with ordered data mode. Opts: (null)
VFS: Mounted root (ext4 filesystem) readonly on device 8:2.
devtmpfs: mounted
Freeing init memory: 132K
Kernel panic - not syncing: No init found.  Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.
[<c001a1cc>] (unwind_backtrace+0x0/0xf0) from [<c037ada0>] (panic+0x58/0x180)
[<c037ada0>] (panic+0x58/0x180) from [<c000857c>] (init_post+0x7c/0xcc)
[<c000857c>] (init_post+0x7c/0xcc) from [<c0475834>] (kernel_init+0xec/0x11c)

Adding init=/bin/bash to the kernel command line doesn't help:

Failed to execute /bin/bash.  Attempting defaults...
Kernel panic - not syncing: No init found.  Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.

My image contains a /boot and / partition, and seems to contain the right things:

% fdisk -l raspbian3.img

Disk raspbian3.img: 499 MB, 499999744 bytes
255 heads, 63 sectors/track, 60 cylinders, total 976562 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

        Device Boot      Start         End      Blocks   Id  System
raspbian3.img1   *        1024      132095       65536    c  W95 FAT32 (LBA)
raspbian3.img2          132096      976561      422233   83  Linux

% mount | grep raspbian
/dev/mapper/loop1p2 on /tmp/raspbian type ext4 (rw)
/dev/mapper/loop1p1 on /tmp/raspbian/boot type vfat (rw)

% ls /tmp/raspbian/
bin  boot  dev  etc  home  lib  lost+found  media  mnt  opt  proc  root  run  sbin  selinux  srv  sys  tmp  usr  var
% ls /tmp/raspbian/boot
arm128_start.elf  arm224_start.elf  bootcode.bin  config.txt          kernel_emergency.img  loader.bin
arm192_start.elf  arm240_start.elf  cmdline.txt   kernel_cutdown.img  kernel.img            start.elf
% ls /tmp/raspbian/sbin/*init*
% ls /tmp/raspbian/bin/*sh*
/tmp/raspbian/bin/bash  /tmp/raspbian/bin/dash

The SHA1 hash of /sbin/init in my image even matches that of the 2012-07-15-wheezy-raspbian image.

This is my script, and the image can be downloaded here.

set -ev

# Author: Michael Gorven <http://michael.gorven.za.net/>

IMAGE="${1?Please specify output image name.}"
PACKAGES="openssh-server sudo ntp fake-hwclock"

bootstrap() {
    if [ ! "$BUILDROOT" ]; then
        echo "BUILDROOT is empty, aborting."
        exit 1

    qemu-debootstrap --arch=armhf --keyring=~/.gnupg/pubring.gpg wheezy "$BUILDROOT" "$MIRROR"

configure() {
    if [ ! "$BUILDROOT" ]; then
        echo "BUILDROOT is empty, aborting."
        exit 1

    cat > "$BUILDROOT/etc/apt/sources.list" <<-EOF
    deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi

    cat > "$BUILDROOT/etc/apt/sources.list.d/mene.list" <<-EOF
    deb http://archive.mene.za.net/raspbian wheezy contrib

    cat > "$BUILDROOT/etc/apt/sources.list.d/raspi.list" <<-EOF
    deb http://archive.raspberrypi.org/debian/ wheezy main untested

    if [ "$http_proxy" ]; then
        cat > "$BUILDROOT/etc/apt/apt.conf.d/30proxy" <<-EOF
        Acquire::http::proxy "$http_proxy";

    wget -O- http://archive.raspberrypi.org/debian/raspberrypi.gpg.key | chroot "$BUILDROOT" apt-key add -
    wget -O- http://archive.mene.za.net/key.asc | chroot "$BUILDROOT" apt-key add -

    chroot "$BUILDROOT" apt-get --yes update
    chroot "$BUILDROOT" apt-get --yes install raspberrypi-bootloader libraspberrypi-bin $PACKAGES
    chroot "$BUILDROOT" apt-get --yes clean

    cp "$BUILDROOT/boot/arm128_start.elf" "$BUILDROOT/boot/start.elf"

    cat > "$BUILDROOT/boot/config.txt" <<-EOF

    cat > "$BUILDROOT/boot/cmdline.txt" <<-EOF
    dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

    chroot "$BUILDROOT" adduser --disabled-password --gecos 'rpi,,,,' rpi
    echo 'rpi:rpi' | chroot "$BUILDROOT" chpasswd
    chroot "$BUILDROOT" adduser rpi sudo
    chroot "$BUILDROOT" adduser --disabled-login --shell /bin/false --gecos 'XBMC,,,' xbmc

    cat >> "$BUILDROOT/etc/network/interfaces" <<-EOF
    auto eth0
    iface eth0 inet dhcp

    echo "xbmc" > "$BUILDROOT/etc/hostname"

    cat > "$BUILDROOT/etc/fstab" <<-EOF
    /dev/mmcblk0p1  /boot   vfat    defaults    0   0
    /dev/mmcblk0p2  /       ext4    errors=remount-ro,noatime,nodiratime    0   0

    cat >> "$BUILDROOT/etc/modules" <<-EOF

mkimage() {
    dd if=/dev/zero of="$IMAGE" bs=1MB count=0 seek="$IMAGE_SIZE"
    cat | sfdisk --quiet --unit S --force "$IMAGE" <<-EOF


    LOOP="$(basename $(losetup -f))"
    kpartx -a "$IMAGE"

    mkfs.vfat -F 32 -n boot "$BOOT"
    mkfs.ext4 -b 4096 -E stride=$ALIGN_FSBLOCKS,stripe-width=$ALIGN_FSBLOCKS -m 1 -L root "$ROOT"

    MNT="$(mktemp -d --tmpdir raspbian.XXXXXX)"
    mount "$ROOT" "$MNT"
    mkdir "$MNT/boot"
    mount "$BOOT" "$MNT/boot"

    rsync -rtvPHAX "$BUILDROOT" "$MNT"

    umount "$MNT/boot"
    umount "$MNT"

    kpartx -d "$IMAGE"

BUILDROOT="$(mktemp -d $PWD/raspbian.XXXXXX)/root/"
  • Interesting. The only thing I can think of is that init wasn't compiled for the same architecture as the kernel.
    – Jivings
    Aug 6, 2012 at 23:05
  • 1
    @Jivings The SHA1 hash of my /sbin/init matches the file in the official Raspbian image...
    – mgorven
    Aug 6, 2012 at 23:58
  • All that proves is that your init is the same as the official. That wasn't what I said. The kernel might have been compiled with different flags
    – Jivings
    Aug 7, 2012 at 6:17
  • @Jivings Oh, right. As far as I understand the kernel is external when using Qemu, so that's the same and the official image works.
    – mgorven
    Aug 7, 2012 at 7:00
  • How does your cmdline.txt compare to the Foundation's? Aug 7, 2012 at 8:25

2 Answers 2


The problem was that the rsync from the build directory into the image wasn't copying device and special files, and wasn't preserving enough file attributes. Specifically, I needed to add the --archive, --devices and --specials options, so the command now look like this:

rsync --archive --devices --specials --hard-links --acls --xattrs --sparse --verbose

It now boots fine under Qemu.

  • Are you going to write this up? It would be great as a self-answered question; How do I build a custom Raspbian image? Aug 8, 2012 at 6:27
  • Would it not be better to make a blog of how to make a custom image instead of doing it in an answer. I am sure its not going to be a few lines of code.
    – Piotr Kula
    Aug 8, 2012 at 9:05
  • @AlexChamberlain I'll try find the time to do that.
    – mgorven
    Aug 8, 2012 at 17:33
  • I've posted the working script on my blog.
    – mgorven
    Oct 22, 2012 at 19:48

This error message is asking for an initramfs in order to mount your root file system. I think you added or removed a wrong driver or feature and the kernel is unable to boot properly. This also explain why an official image is booting normally.

If this is really the problem, you have two options:

  1. Find which driver or feature was removed and put it back. Also make sure to do NOT mask as a module, but built-in nito the main kernel image. I recommend this one.
  2. Create a initramfs. Too much troublesome, don't do that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.