Estou construindo uma imagem SD personalizada do Raspbian usando o debootstrap, e a imagem resultante falha ao inicializar Kernel panic - not syncing: No init found.
no Raspberry Pi e no qemu. Posso inicializar com êxito a imagem 2012-07-15-wheezy-raspbian nos dois (embora com um cartão SD diferente no Pi). Para o qemu, estou usando o kernel do 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)
Adicionar init=/bin/bash
à linha de comando do kernel não ajuda:
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.
Minha imagem contém uma partição /boot
e /
, e parece conter as coisas certas:
% 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*
/tmp/raspbian/sbin/init
% ls /tmp/raspbian/bin/*sh*
/tmp/raspbian/bin/bash /tmp/raspbian/bin/dash
O hash SHA1 da /sbin/init
minha imagem é igual ao da imagem 2012-07-15-wheezy-raspbian.
Este é o meu script, e a imagem pode ser baixada aqui .
#!/bin/sh
set -ev
# Author: Michael Gorven <http://michael.gorven.za.net/>
IMAGE="${1?Please specify output image name.}"
IMAGE_SIZE=500
BOOT_SIZE=64
ALIGN_SECTORS=1024
ALIGN_FSBLOCKS="$(($ALIGN_SECTORS*512/4096))"
MIRROR="http://mirrordirector.raspbian.org/raspbian"
PACKAGES="openssh-server sudo ntp fake-hwclock"
bootstrap() {
if [ ! "$BUILDROOT" ]; then
echo "BUILDROOT is empty, aborting."
exit 1
fi
qemu-debootstrap --arch=armhf --keyring=~/.gnupg/pubring.gpg wheezy "$BUILDROOT" "$MIRROR"
}
configure() {
if [ ! "$BUILDROOT" ]; then
echo "BUILDROOT is empty, aborting."
exit 1
fi
cat > "$BUILDROOT/etc/apt/sources.list" <<-EOF
deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi
EOF
cat > "$BUILDROOT/etc/apt/sources.list.d/mene.list" <<-EOF
deb http://archive.mene.za.net/raspbian wheezy contrib
EOF
cat > "$BUILDROOT/etc/apt/sources.list.d/raspi.list" <<-EOF
deb http://archive.raspberrypi.org/debian/ wheezy main untested
EOF
if [ "$http_proxy" ]; then
cat > "$BUILDROOT/etc/apt/apt.conf.d/30proxy" <<-EOF
Acquire::http::proxy "$http_proxy";
EOF
fi
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
disable_overscan=1
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
EOF
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
EOF
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
EOF
cat >> "$BUILDROOT/etc/modules" <<-EOF
vchiq
snd_bcm2835
EOF
}
mkimage() {
dd if=/dev/zero of="$IMAGE" bs=1MB count=0 seek="$IMAGE_SIZE"
cat | sfdisk --quiet --unit S --force "$IMAGE" <<-EOF
$ALIGN_SECTORS,$(($BOOT_SIZE*2048)),c,*
$(($ALIGN_SECTORS+$BOOT_SIZE*2048)),,L
EOF
LOOP="$(basename $(losetup -f))"
kpartx -a "$IMAGE"
BOOT="/dev/mapper/${LOOP}p1"
ROOT="/dev/mapper/${LOOP}p2"
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/"
bootstrap
configure
mkimage
/sbin/init
partidas o arquivo na imagem Raspbian oficial ...
cmdline.txt
compara à da Fundação?