L'image Raspbian personnalisée ne démarre pas avec «aucun init trouvé»


11

Je construis une image SD personnalisée de Raspbian en utilisant debootstrap, et l'image résultante ne démarre pas avec Kernel panic - not syncing: No init found.à la fois sur mon Raspberry Pi et sous qemu. Je peux démarrer avec succès l'image 2012-07-15-wheezy-raspbian sur les deux (bien qu'avec une carte SD différente sur le Pi). Pour qemu, j'utilise le noyau de 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)

L'ajout init=/bin/bashà la ligne de commande du noyau n'aide pas:

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.

Mon image contient une partition /bootet /, et semble contenir les bonnes choses:

% 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

Le hachage SHA1 de /sbin/initmon image correspond même à celui de l'image 2012-07-15-wheezy-raspbian.

Ceci est mon script, et l'image peut être téléchargée ici .

#!/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

Intéressant. La seule chose à laquelle je peux penser est que init n'a pas été compilé pour la même architecture que le noyau.
Jivings

1
@Jivings Le hachage SHA1 de mes /sbin/initcorrespond au fichier dans l'image officielle Raspbian ...
mgorven

Tout ce qui prouve, c'est que votre init est le même que l'officiel. Ce n'est pas ce que j'ai dit. Le noyau peut avoir été compilé avec différents drapeaux
Jivings

@Jivings Oh, c'est vrai. Autant que je sache, le noyau est externe lors de l'utilisation de Qemu, c'est donc la même chose et l'image officielle fonctionne.
mgorven du

Comment vous cmdline.txtcomparez- vous à celle de la Fondation?
Alex Chamberlain

Réponses:


5

Le problème était que le rsync du répertoire de construction dans l'image ne copiait pas le périphérique et les fichiers spéciaux et ne préservait pas suffisamment d'attributs de fichier. Plus précisément, je besoin d'ajouter les --archive, --deviceset --specialsoptions, la commande ressemble maintenant à ceci:

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

Il démarre désormais correctement sous Qemu.


Allez-vous écrire cela? Ce serait formidable comme une question auto-répondue; Comment créer une image Raspbian personnalisée?
Alex Chamberlain

Ne serait-il pas préférable de faire un blog sur la façon de créer une image personnalisée au lieu de le faire dans une réponse. Je suis sûr que ce ne sera pas quelques lignes de code.
Piotr Kula

@AlexChamberlain Je vais essayer de trouver le temps de le faire.
mgorven

J'ai publié le script de travail sur mon blog .
mgorven

0

Ce message d'erreur demande un initramfs afin de monter votre système de fichiers racine. Je pense que vous avez ajouté ou supprimé un mauvais pilote ou une mauvaise fonctionnalité et que le noyau ne peut pas démarrer correctement. Cela explique également pourquoi une image officielle démarre normalement.

Si c'est vraiment le problème, vous avez deux options:

  1. Recherchez le pilote ou la fonctionnalité supprimé et remettez-le en place. Assurez-vous également de ne PAS masquer en tant que module, mais de nito intégré l'image du noyau principal. Je recommande celui-ci.
  2. Créez un initramfs. Trop gênant, ne fais pas ça.
En utilisant notre site, vous reconnaissez avoir lu et compris notre politique liée aux cookies et notre politique de confidentialité.
Licensed under cc by-sa 3.0 with attribution required.