More custom initramfs switch_root woes (bad '/sbin/init')

Luciano Miguel Ferreira Rocha strange at nsk.no-ip.org
Wed Apr 18 10:21:33 UTC 2007


On Tue, Apr 17, 2007 at 11:09:46PM -0500, Matthew Franz wrote:
> I've seen earlier thread this month (and a lot of the comments/wiki
> pages) over on the Gento site and read most everything (well, except
> Kernel/Busybox source)
> 
> switch_root: bad init '/sbin/init'
> [   18.571462] Kernel panic - not syncing: Attempted to kill init!
> [   18.584241]

The new sbin/init isn't valid. Are you copying the shared libraries?

> 
> Busybox 1.4.2 (glibc -- built on Ubuntu Dapper)
> Kernel 2.6.20.2
> 
> * I assume it is possible for the real root to be a ramfs  (if there
> are other ways to get job control and multiple terminals I'm fine with
> that too)

It is. /init on an initramfs behaves as the real sbin/init.

> I would love for the /init to behave like linuxrc and just
> behave like linitrd. There is no *real* root (meaning some physical
> device or cloop or whatever)
> 
> * The fact that my initramfs /init is being executed by bash (I have
> my reason) shouldn't be an issue?!

It shouldn't be an issue.

<snip/>
> Starting init!
> Creating new root directory
> Creating mount points...
> -/tmp
> -/var/lock
> -/proc
> -/sys
> -/dev
> Creating /proc & /sys
> Copying directories...
> -/etc
> -/sbin
> -/bin

Did you forget /lib?

> Creating devices...
> drwxr-xr-x    2 0        0               0 Apr 18 03:52 .
> drwxr-xr-x   10 0        0               0 Apr 18 03:52 ..
> crw-r--r--    1 0        0          5,   1 Apr 18 03:52 console
> crw-r--r--    1 0        0          1,   3 Apr 18 03:52 null
> Entering final root
> switch_root: bad init '/sbin/init'

Uuh... sbin/init isn't valid. You could try running it normally, before
the switch_root, to see if you can at least execute it.

> 
> And here is my init:
> 
> #!/bin/bash
> /bin/busybox  echo "Starting init!"

bash has an internal echo, you shouldn't need busybox for that

> /bin/busybox  mount -t proc none /proc
> /bin/busybox --install
> 
> echo "Creating new root directory"
> mkdir /newroot
> mount -t ramfs none /newroot

What's the point then? If you're going to use ramfs, keep using the one
the kernel created for you (it's called init_ramfs_ for a reason):

mkdir -p /proc /sys /dev/pts
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts -o gid=5,mode=620
## run the real init
exec /sbin/init

Anyway, if you don't want to use the original ramfs, you could skip the
cps with mount --bind:
mount --bind /dev /newroot/dev
mount --bind ...

-- 
lfr
0/0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20070418/763cc32a/attachment-0002.pgp 


More information about the busybox mailing list