Date: Thu, 28 Dec 2006 13:37:14 +0100 (CET) From: Oliver Fromme <olli@lurza.secnetix.de> To: freebsd-hackers@FreeBSD.ORG, erik.udo@gmail.com Subject: Re: Init.c, making it chroot Message-ID: <200612281237.kBSCbE2n047391@lurza.secnetix.de> In-Reply-To: <4592C91C.2040801@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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. 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. ;-) -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. "Python tricks" is a tough one, cuz the language is so clean. E.g., C makes an art of confusing pointers with arrays and strings, which leads to lotsa neat pointer tricks; APL mistakes everything for an array, leading to neat one-liners; and Perl confuses everything period, making each line a joyous adventure <wink>. -- Tim Peters
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200612281237.kBSCbE2n047391>