Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Dec 2006 12:19:23 +0100 (CET)
From:      Oliver Fromme <olli@lurza.secnetix.de>
To:        imp@bsdimp.com (M. Warner Losh)
Cc:        erik.udo@gmail.com, freebsd-hackers@freebsd.org
Subject:   Re: Init.c, making it chroot
Message-ID:  <200612301119.kBUBJNno062104@lurza.secnetix.de>
In-Reply-To: <20061229.130333.-1771083254.imp@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help

M. Warner Losh wrote:
 > Oliver Fromme <olli@lurza.secnetix.de> writes:
 > : Thanks for the new patch, I'll try it as soon as possible.

I got a few minutes and tested it.

 > I don't have the proper environment to easily test this
 > out, but I think what I sent will work...

It does work indeed!  With that patch, the chrooted system
boots fine into multi-user mode and I get a login prompt.

If you would like to look at my ISO (or anybody else who's
following this thread):

http://www.secnetix.de/tmp/init_chroot/

The ISO is 17 MB compressed (I removed some stuff to keep
it small).  Actually it's pretty much a standard FreeBSD
base system.  There's also an ls -alR listing on the URL
above.

The directory structure on it looks like this:

   /boot
   /ochroot
   /ochroot/bin
   /ochroot/boot
   /ochroot/dev
   /ochroot/etc
   /ochroot/...

i.e. basically everything is located under /ochroot, except
for /boot which is hardlinked from /ochroot/boot (to save
space).

In particular, there is no /dev, so I still get this one
from the kernel:

   Lookup of /dev for devfs, error: 2

But then init and everything starts up fine, so it doesn't
seem to cause any harm.  That raises two questions:

1-  Why does the kernel try to mount /dev at all?  Why not
    simply let init mount it in all cases, with ot without
    init_chroot?  Would make things simpler.  There doesn't
    seem to be a clear reason why the kernel needs to mount
    it.  (Or maybe there _are_ reasons, byt they don't
    appear during my testing.)

2-  Another solution would be to let init(8) autodetect
    whether /dev needs to be mounted.  However, that might
    not be as trivial as it sounds.

By the way, testing the whole thing is easy.  Just install
qemu from ports, then run this command:

   qemu -monitor stdio -cdrom chroot-test.iso -boot d

Creating the ISO (with mkisofs) takes 5 seconds, and booting
it in qemu takes 10 seconds (even without the kqemu kernel
accelerator module), so the development and testing cycles
are very short.  That's how I developed my CD/DVD boot
manager "eltoro"[1].  As soon as the ISO runs successfully
in qemu, I write it to a CD-RW and boot it on a real PC
for verification.

Best regards
   Oliver


PS:  [1]  http://www.secnetix.de/products/eltoro/

-- 
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.

"One of the main causes of the fall of the Roman Empire was that,
lacking zero, they had no way to indicate successful termination
of their C programs."
        -- Robert Firth



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200612301119.kBUBJNno062104>