From owner-freebsd-hackers@FreeBSD.ORG Tue May 27 13:54:05 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8878D37B404 for ; Tue, 27 May 2003 13:54:05 -0700 (PDT) Received: from odin.ac.hmc.edu (Odin.AC.HMC.Edu [134.173.32.75]) by mx1.FreeBSD.org (Postfix) with ESMTP id E1EB743FBD for ; Tue, 27 May 2003 13:54:04 -0700 (PDT) (envelope-from brdavis@odin.ac.hmc.edu) Received: from odin.ac.hmc.edu (IDENT:brdavis@localhost.localdomain [127.0.0.1]) by odin.ac.hmc.edu (8.12.9/8.12.3) with ESMTP id h4RKs2Hp004558 for ; Tue, 27 May 2003 13:54:02 -0700 Received: (from brdavis@localhost) by odin.ac.hmc.edu (8.12.9/8.12.3/Submit) id h4RKs24o004552 for hackers@freebsd.org; Tue, 27 May 2003 13:54:02 -0700 Date: Tue, 27 May 2003 13:54:02 -0700 From: Brooks Davis To: hackers@freebsd.org Message-ID: <20030527205402.GA30952@Odin.AC.HMC.Edu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="cWoXeonUoKmBZSoM" Content-Disposition: inline User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-milter (http://amavis.org/) on odin.ac.hmc.edu Subject: rc.diskless1/initdiskless change for review X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 May 2003 20:54:05 -0000 --cWoXeonUoKmBZSoM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable The following patch (against rc.diskless1 on STABLE, but the code is identical in rc.d/initdiskless) simplifies the likely common case for remounts in the /conf hierarchy. It allows you to specify a path (i.e. /etc) in the diskless_remount file rather then having to record the path to the NFS root. I'm using this to allow me to copy a the entire root to a new location on my NFS server to do an upgrade without breaking running hosts on the old root and without touching /conf at all. I'd like to commit this after the tree is thawed again. What do people think? -- Brooks Index: rc.diskless1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /usr/cvs/src/etc/Attic/rc.diskless1,v retrieving revision 1.5.2.11 diff -u -r1.5.2.11 rc.diskless1 --- rc.diskless1 14 Apr 2003 18:12:05 -0000 1.5.2.11 +++ rc.diskless1 24 May 2003 00:33:19 -0000 @@ -121,6 +121,17 @@ done echo "Interface ${bootp_ifc} IP-Address ${bootp_ipa} Broadcast ${bootp_ipb= ca}" =20 +# Figure out our NFS root path +# +set `mount -t nfs` +while [ $# -ge 1 ] ; do + if [ "$2" =3D "on" -a "$3" =3D "/" ]; then + nfsroot=3D"$1" + break + fi + shift +done + # Resolve templates in /conf/base, /conf/default, /conf/${bootp_ipbca}, # and /conf/${bootp_ipa}. For each subdirectory found within these=20 # directories: @@ -136,6 +147,10 @@ # might contain 'myserver:/etc'. NFS remounts allow you to avoid # having to dup your system directories in /conf. Your server must # be sure to export those filesystems -alldirs, however. +# If the diskless_remount file contains a string beginning with a +# '/' it is assumed that the local nfsroot should be prepended to +# it before attemping to mount allowing the root to be relocated +# without needing to change the remount files. # for i in base default ${bootp_ipbca} ${bootp_ipa} ; do for j in /conf/$i/* ; do @@ -150,6 +165,9 @@ # if [ -d $j -a -f $j/diskless_remount ]; then nfspt=3D`/bin/cat $j/diskless_remount` + if [ `expr "$nfspt" : '\(.\)'` =3D "/" ]; then + nfspt=3D"${nfsroot}${nfspt}" + fi mount_nfs $nfspt $j chkerr $? "mount_nfs $nfspt $j" fi --=20 Any statement of the form "X is the one, true Y" is FALSE. PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4 --cWoXeonUoKmBZSoM Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE+09BpXY6L6fI4GtQRArfNAKDK/qwFPD4ZFibqWWr7MbsK45UuTgCfaVK7 IonXDf2sYgvvu8d9YbnTQSI= =xh51 -----END PGP SIGNATURE----- --cWoXeonUoKmBZSoM--