Re: pivot_root off an initramfs broken

From: H. Peter Anvin
Date: Wed Dec 03 2003 - 19:32:29 EST

Followup to: <1070496272.8280.443.camel@xxxxxxxxxxxxxxxx>
By author: Martin Hicks <mort@xxxxxxxxxxxxxxxxxx>
In newsgroup:
> If I boot a 2.6 kernel that first execs /sbin/kinit on the initramfs,
> does some setup (mostly to find the real root filesystem), then
> pivot_roots over to the real root filesystem and execs /sbin/init the
> kernel spins inside check_mnt() while mounting /proc in the initscripts.

The initramfs is the "real root" -- you shouldn't pivot_root from it,
instead you should mount the new root on top of it.

This makes cleaning up a bit of an issue -- the proposed rootfs
mount_single patch takes care of that -- but it can also be done by
leaving a cleanup process with cwd inside the initramfs with would use
relative paths to clean up.

Something like this:

mount / /dev/real_root_whatever
( rm -rf . ) &
exec /sbin/init "$@"

<hpa@xxxxxxxxxxxxx> at work, <hpa@xxxxxxxxx> in private!
If you send me mail in HTML format I will assume it's spam.
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at