Hi, I am trying to use an initramfs to load my rootfs from the sd card. I have used buildroot to generate both the initramfs, and another rootfs.
My /init script looks like this for the initramfs:
Code:
#!/bin/sh
# devtmpfs does not get automounted for initramfs
/bin/mount -t devtmpfs devtmpfs /dev
/bin/mkdir /mnt/root
/bin/mount -r -t ext4 /dev/mmcblk0p2 /mnt/root
echo "Mounting proc, sys, dev"
/bin/mount -t proc proc /proc
/bin/mount -t sysfs sysfs /sys
/bin/mount -t tmpfs tmpfs /dev
echo "Mount finished"
if [[ -x "/mnt/root" ]]; then
echo "Found real rootfs"
echo "Remounting"
/bin/mount --move /proc /mnt/root/proc
/bin/mount --move /sys /mnt/root/sys
/bin/mount --move /dev /mnt/root/dev
fi
if [[ -x "/mnt/root/sbin/init" ]]; then
echo "Found INIT binary on new rootfs"
exec /sbin/switch_root /mnt/root /mnt/root/sbin/init
fi
echo "FAILURE"
After boot, I get this error message:
Code:
EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
Mounting proc, sys, dev
Mount finished
Found real rootfs
Remounting
Found INIT binary on new rootfs
switch_root: can't execute '/mnt/root/sbin/init': No such file or directory
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100
CPU: 0 PID: 1 Comm: switch_root Not tainted 3.10.0 #46
[<c0012090>] (unwind_backtrace+0x0/0xec) from [<c0010a04>] (show_stack+0x10/0x14)
[<c0010a04>] (show_stack+0x10/0x14) from [<c04720c8>] (panic+0x8c/0x1c8)
[<c04720c8>] (panic+0x8c/0x1c8) from [<c001f100>] (complete_and_exit+0x0/0x1c)
[<c001f100>] (complete_and_exit+0x0/0x1c) from [<00000001>] (0x1)
It doesn't make sense to me, since /mnt/root/sbin/init does indeed exist. To simplify things, I have skipped the exec part, and started a shell. Within that shell, I can verify that the mounting was done correctly, since I can run the binaries from the sd card which are all mounted on /mnt/root/bin.
Any idea what's going on?