Subject: Re: PATCH: init(8) - multiuser under chroot
To: Simon J. Gerraty <sjg@crufty.net>
From: Jachym Holecek <freza@liberouter.org>
List: tech-userlevel
Date: 09/05/2005 12:29:55
> >  a) don't chroot anything.
> >  b) init never chroots itself, but does run /etc/rc in a chroot,
> 
> Unless someone has fixed a bunch of stuff in the kernel, then at least
> the part of /etc/rc that handles fsck / and mounting it rw, needs to be 
> unchrooted.

Hmm, do you recall what part of the kernel was involved?
But see below why this doesn't (necessarily) cause trouble.

> For this purpose I don't run /etc/rc chroot'd, but move the
> bulk of the functionality to a separate rc (rc.chroot), then /etc/rc runs
> that chroot'd (using the value of $CHROOT passed from init) after 
> making / writable. 

Note that multiuser startup is always done as follows:

  1. init runs /etc/rc (no chrooting)
  2. sysctl init.chroot is checked and if not equal to "/",
     we continue under chroot (beginning with ${chroot}/etc/rc).

  [If we add any other sysctls to control init's behaviour,
   we'd check them during (2) as well.]

So the real /etc/rc (on mfs for instance) can take care of
fsck and other tasks (such as mounting cgd) and then just set
init.chroot.

The assumption here is that we'll be chrooting into a "full
system" (not necessarily chroot-aware), starting from a
"trampoline root" (minimal system in mfs for instance).

	Regards,
		-- Jachym Holecek