Init.c, making it chroot

M. Warner Losh imp at bsdimp.com
Thu Dec 28 12:31:34 PST 2006


In message: <200612281237.kBSCbE2n047391 at lurza.secnetix.de>
            Oliver Fromme <olli at lurza.secnetix.de> writes:
: Erik Udo wrote:
:  > How can i make init chroot after executing /etc/rc, and executing 
:  > /etc/rc again in the chrooted enviroment?
:  > 
:  > For this to work, i'd like to know at what point do i call chroot(), 
:  > becouse init.c uses fork() at the point where it runs the rc script.
:  > 
:  > The thing is, i want to run a whole system in a chrooted enviroment in 
:  > this livecd i'm making. But the command "chroot /mnt/root /etc/rc" 
:  > returns after the /etc/rc has been run, dropping me back from the 
:  > chrooted enviroment. And if it doesn't, init never starts the multiuser 
:  > mode.
: 
: That's exactly the problem I had when I created a combined
: DVD-ROM with FreeBSD and DragonFly BSD on it.  For them to
: share the same ISO-9660, at least one of them needed to be
: chrooted.  I decided to add the feature to DragonFly BSD's
: init(8) because the DragonFly people seemed to be easier to
: convince of the usefulness.  ;-)   Indeed, the feature was
: committed quickly.  I didn't try to send-pr a similar patch
: for FreeBSD.

You do the FreeBSD developer community a disservice with this
attitude.  We've been talking about needing something like this for a
while.

: It shouldn't be too difficult to port it, though:
: 
: http://www.dragonflybsd.org/cvsweb/src/sbin/init/init.c
: 
: The chroot() patch has been committed with r1.6.  It uses
: kenv to specify the chroot directory, so it can easily be
: set by the loader(8), e.g. using a custom boot menu.
: 
: Best regards
:    Oliver
: 
: PS:  I see NetBSD has a similar feature, too.  Maybe
: FreeBSD should join the crowd and adopt it.  ;-)

Please, don't come into the FreeBSD forums and talk trash on FreeBSD
when you've not even tried to get a change into the base system.

Warner


More information about the freebsd-hackers mailing list