Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Mar 2012 09:03:28 GMT
From:      Attila Nagy <bra@fsn.hu>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   misc/166484: rc.initdiskless patch for different major versions living together
Message-ID:  <201203290903.q2T93Sqc073985@red.freebsd.org>
Resent-Message-ID: <201203290910.q2T9A9EN038611@freefall.freebsd.org>

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

>Number:         166484
>Category:       misc
>Synopsis:       rc.initdiskless patch for different major versions living together
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 29 09:10:08 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Attila Nagy
>Release:        9-stable
>Organization:
>Environment:
>Description:
In /etc/rc.initdiskless (used for NFS based diskless booting) it is possible to use different template directories, currently base -used mainly for storing the FreeBSD standard /etc base-, default -which is used for all netbooted machines, overriding what is in base-, broadcast and IP address based overrides.
This scheme works well for a small amount of machines running the same major FreeBSD version, but when there are different major versions running concurrently, the same base /etc starts to cause problems.
In our application we use FreeBSD 7, 8 and 9 versions, and to make things work somehow, we have to pick one /etc (main concerns are the rc scripts in rc* and rc.d/*) from a given major version which works for all major versions.
But due to incompatibilities, this is a no go, so we started to use different base templates for the given major release.
The attached patch is the fix for this problem, it makes possible to use base as today, and base.${major_release} (preferred over base if exists) for the major release.
With this patch we can run any FreeBSD major releases together from the same NFS servers without any problems and hacks due to differing rc.d and rc script versions and needs.

>How-To-Repeat:
Use different FreeBSD major releases with the same /etc.
>Fix:
Multiple -major release based- base templates.

Patch attached with submission follows:

--- etc/rc.initdiskless.orig	2012-03-13 10:17:09.000000000 +0100
+++ etc/rc.initdiskless	2012-03-13 10:17:09.000000000 +0100
@@ -39,7 +39,10 @@
 # for which memory filesystems will be created and filled,
 # and T is one of the "template" directories below:
 #
-#  base		universal base, typically a replica of the original root;
+#  base.${rel}	universal base for the given major release, typically a 
+#		replica of the original root;
+#  base		universal base, typically a replica of the original root,
+#		effective only if base.${rel} does not exist;
 #  default	secondary universal base, typically overriding some
 #		of the files in the original root;
 #  ${ipba}	where ${ipba} is the assigned broadcast IP address
@@ -53,7 +56,9 @@
 #  ip/${ip}	same as above
 #
 # Template directories are scanned in the order they are listed above,
-# with each successive directory overriding (merged into) the previous one;
+# with each successive directory overriding (merged into) the previous one
+# (except in the case of the base directory, where the release-specific
+# base is chosen if exists to help multiple major releases to work together);
 # non-existing directories are ignored.  The subdirectory forms exist to
 # help keep the top level /conf manageable in large installations.
 #
@@ -261,7 +266,7 @@
 done
 
 # The list of directories with template files
-templates="base default"
+templates="default"
 if [ -n "${bootp_ipbca}" ]; then
 	templates="${templates} ${bootp_ipbca} bcast/${bootp_ipbca}"
 fi
@@ -275,7 +280,17 @@
 # If /conf/diskless_remount exists, remount all of /conf.
 handle_remount /conf
 
-# Resolve templates in /conf/base, /conf/default, /conf/${bootp_ipbca},
+# Extract the major revision from uname
+rel=`expr \`uname -r\` : '\(.\)'`
+# If we have a "base.${rel}" directory, use that as base, otherwise fall back
+# to "base"
+if [ -d "/conf/base.${rel}" ]; then
+	templates="base.${rel} ${templates}"
+else
+	templates="base ${templates}"
+fi
+
+# Resolve templates in /conf/base[.${rel}], /conf/default, /conf/${bootp_ipbca},
 # and /conf/${bootp_ipa}.  For each subdirectory found within these
 # directories:
 #
--- share/man/man8/diskless.8.orig	2011-08-08 15:13:22.000000000 +0200
+++ share/man/man8/diskless.8	2012-03-13 10:14:56.000000000 +0100
@@ -255,6 +255,7 @@
 .Pp
 The scripts provide four
 overriding directories situated in
+.Pa /conf/base.<major-release> or
 .Pa /conf/base ,
 .Pa /conf/default ,
 .Pa /conf/<broadcast-ip> ,
@@ -267,6 +268,14 @@
 on the
 .Nm
 machine.
+If you run different major releases, you should maintain a base /etc for
+each one to provide backwards compatibility for older releases.
+You can do this by installing major release specific /etc into
+.Pa /conf/base.<major-release>
+The
+.Nm
+boot script will first look for this release specific base, then
+the standard base in this order. The more specific base will be used.
 You can clone the server's
 .Pa /etc
 here or you can create a special file which tells the


>Release-Note:
>Audit-Trail:
>Unformatted:



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