From owner-freebsd-hackers@FreeBSD.ORG Sat Dec 30 11:19:38 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 22A1216A407 for ; Sat, 30 Dec 2006 11:19:38 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [83.120.8.8]) by mx1.freebsd.org (Postfix) with ESMTP id 7939513C45D for ; Sat, 30 Dec 2006 11:19:37 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (tojuzm@localhost [127.0.0.1]) by lurza.secnetix.de (8.13.4/8.13.4) with ESMTP id kBUBJRZ4062116; Sat, 30 Dec 2006 12:19:32 +0100 (CET) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.13.4/8.13.1/Submit) id kBUBJNno062104; Sat, 30 Dec 2006 12:19:23 +0100 (CET) (envelope-from olli) From: Oliver Fromme Message-Id: <200612301119.kBUBJNno062104@lurza.secnetix.de> To: imp@bsdimp.com (M. Warner Losh) Date: Sat, 30 Dec 2006 12:19:23 +0100 (CET) In-Reply-To: <20061229.130333.-1771083254.imp@bsdimp.com> X-Mailer: ELM [version 2.5 PL8] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Sat, 30 Dec 2006 12:19:33 +0100 (CET) X-Mailman-Approved-At: Sat, 30 Dec 2006 12:31:13 +0000 Cc: erik.udo@gmail.com, freebsd-hackers@freebsd.org Subject: Re: Init.c, making it chroot X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Dec 2006 11:19:38 -0000 M. Warner Losh wrote: > Oliver Fromme 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