[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-hackers
Subject:    rc.diskless1/initdiskless change for review
From:       Brooks Davis <brooks () one-eyed-alien ! net>
Date:       2003-05-27 20:54:02
[Download RAW message or body]


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
===================================================================
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_ipbca}"
 
+# Figure out our NFS root path
+#
+set `mount -t nfs`
+while [ $# -ge 1 ] ; do
+    if [ "$2" = "on" -a "$3" = "/" ]; then
+        nfsroot="$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 
 # 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=`/bin/cat $j/diskless_remount`
+            if [ `expr "$nfspt" : '\(.\)'` = "/" ]; then
+                nfspt="${nfsroot}${nfspt}"
+            fi
 	    mount_nfs $nfspt $j
 	    chkerr $? "mount_nfs $nfspt $j"
 	fi

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

[Attachment #3 (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic