[SLL] root filesystem as a subdirectory of same device
Robert Woodcock
rcw at blarg.net
Tue Nov 27 16:37:57 PST 2007
On Tue, Nov 27, 2007 at 03:58:12PM -0600, Jeremy C. Reed wrote:
> I want to change the root filesystem to a subdirectory of the only
> device. I want this to happen at boot time.
>
> chroot could be used to run init -- but I am not sure easiest way to do
> the chroot before running init.
I don't know if init can be a shell script on Linux (I doubt it, but I've
never tested it). Assuming that it can't, you could write a small C wrapper
that calls chroot(), then execve()'s the real init (ensuring that init still
gets PID 1). You'd have to make sure you pass the environment and command
line parameters through to the real init when you call execve.
You could also make an initrd that does it just after it does the
pivot_root thing.
Note that the kernel developers don't consider chroot() secure:
http://kerneltrap.org/Linux/Abusing_chroot
--
Robert Woodcock - rcw at blarg.net
"The thought of being stuck in the Tube with strangers for minutes on end
and having to listen to endless repeated messages of my own voice fills me
with horror."
-- Emma Clarke, former London Underground announcer
More information about the linux-list
mailing list