using switch_root from initfamfs ( switch_root: error moving root)

E Robertson e.robertson.svg at gmail.com
Mon Apr 20 20:45:40 UTC 2009


Hi all,
During an initramfs filesystem boot I created a /tmp/root and mount it
as tmpfs to which I copy some new files to.
I then did:

    umount -l /proc
    umount -l /sys
    exec switch_root -c /dev/console /tmp/root /sbin/init

but then I got:
switch_root: error moving root
Kernel panic - not syncing: Attempted to kill init!

In looking through the switch_root.c I see that the contents of "/" is
deleted and I'm wondering to what extent.
Do that mean that all directories under "/" is deleted? If so, that
means that all of the /dev devices ahould be deleted.
Since mounting to a /dev/mtd device has worked for me in the past I
doubt "everything" is "everything". is this correct?

	// Zap everything out of rootdev

	delete_contents("/");

	// Overmount / with newdir and chroot into it.  The chdir is needed to
	// recalculate "." and ".." links.

	if (mount(".", "/", NULL, MS_MOVE, NULL) || chroot("."))
		bb_error_msg_and_die("error moving root");
	xchdir("/");

Is the problem because I'm switching to another tmpfs root system? (in
that all of /tmp is deleted?)
/tmp/root is mounted with -t tmps tmpfs /tmp/root
and /tmp is also mounted as tmpfs. Should this be a problem?
I'm using 1.13.4 source.


More information about the busybox mailing list