From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org) by nuthatch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1FtBj1-0000j8-Bm for garchives@archives.gentoo.org; Wed, 21 Jun 2006 23:03:07 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.13.7/8.13.6) with SMTP id k5LN0wlW003793; Wed, 21 Jun 2006 23:00:58 GMT Received: from wx-out-0102.google.com (wx-out-0102.google.com [66.249.82.207]) by robin.gentoo.org (8.13.7/8.13.6) with ESMTP id k5LMpsiI015335 for ; Wed, 21 Jun 2006 22:51:55 GMT Received: by wx-out-0102.google.com with SMTP id t4so207323wxc for ; Wed, 21 Jun 2006 15:51:54 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=J1hUJ/eJFB5TWXvJvY5b+A6PSSi+3wrKqHGyIGACEz1D2nfL8hnCJ5iAwCZ/YPmLzk4Kp4ogkLiEE+XNClI2aumoAI8tkLRdBG+3xOtwI5CKa+g8EZKrpsyIfgr3jhQgYfWj99CnSka2K7UlhYY6RdISZICOkQrQ+cAeXJufMXA= Received: by 10.70.74.4 with SMTP id w4mr1978326wxa; Wed, 21 Jun 2006 15:51:51 -0700 (PDT) Received: by 10.70.91.13 with HTTP; Wed, 21 Jun 2006 15:51:51 -0700 (PDT) Message-ID: <7573e9640606211551j4d74e1c2xc43c98e22294d3cf@mail.gmail.com> Date: Wed, 21 Jun 2006 15:51:51 -0700 From: "Richard Fish" Sender: richard.j.fish@gmail.com To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] initramfs, network diskless boot, init process, problems with switchroot (pivot_root) In-Reply-To: <20060621234505.d3471724.hilse@web.de> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <7573e9640606211350o4042b571i514307d6ac242fc8@mail.gmail.com> <20060621234505.d3471724.hilse@web.de> X-Google-Sender-Auth: 14c500cfee5eeca8 X-Archives-Salt: 03e35923-b0f3-4469-9b74-b2a3d1a932c7 X-Archives-Hash: d36c232aa9b79968b70d1d6369874959 On 6/21/06, Hans-Werner Hilse wrote: > On Wed, 21 Jun 2006 13:50:12 -0700 > > Hm, I'm pretty sure that it is well possible to pivot_root from an > initramfs. Isn't that the whole point of pivot_root? But you may be > right that it is not possible for NFS mounts, I never tried that before. http://bugzilla.kernel.org/show_bug.cgi?id=4857 My final comments on that bug are based on the attached email that I received from Andrew Morton that made it clear that Al Viro was opposed to pivot_root being used from an initramfs. (BTW, viro's comments are not very polite, but you have to expect such directness from kernel hackers!) Note, be sure we are talking about an initramfs here, not an initrd. >>From an initrd it is still possible and supported to use pivot_root. > In fact, the approach you took is weak. /sbin/init wouldn't run as PID > 1 in this case which is bad for the situation that the calling script > (which _has_ PID 1) dies. The kernel would recognize this and reboot > (and/or panic, not sure). To avoid this, one has to exec the init from > the script. No, this works perfectly. I use it every time I boot my kernel, and my init *is* PID 1. The "exec ./bin/chroot" part replaces the shell executing the /init script with the chroot command, so chroot then becomes PID 1. Chroot then does an exec of ./sbin/init so that init becomes PID 1. > > So basically it boils down to this /init in the initramfs: > > #!/bin/sh > PATH=/bin:/sbin > modprobe supermightyrootfsprovidingmodule && \ > mount -t blahfs /dev/whereitis /mnt/stagetwo && \ > cd /mnt/stagetwo && \ > pivot_root . /mnt/initramfs || reboot -f > exec /sbin/init Be warned that if you do this, and then you try to "mount --move" anything, your kernel will probably hang. But again, in recent kernels, pivot_root *should* be returning -EINVAL if you do this. Indeed I just checked my 2.6.16 sources, and the code that returns EINVAL in sys_pivot_root for unattached mounts is still there: error = -EINVAL; if (user_nd.mnt->mnt_root != user_nd.dentry) goto out2; /* not a mountpoint */ if (user_nd.mnt->mnt_parent == user_nd.mnt) goto out2; /* not attached */ if (new_nd.mnt->mnt_root != new_nd.dentry) goto out2; /* not a mountpoint */ if (new_nd.mnt->mnt_parent == new_nd.mnt) goto out2; /* not attached */ So unless your the pivot_root program is doing something other than sys_pivot_root(), I don't see how this can possibly work on a recent kernel. -Richard -- gentoo-user@gentoo.org mailing list