proposal: etc/rc.d/initdiskless -> /etc/rc.initdiskless

Brooks Davis brooks at one-eyed-alien.net
Wed Mar 2 18:59:24 GMT 2005


On Sun, Feb 27, 2005 at 04:12:03PM +0300, Mike Makonnen wrote:
> On Thu, Feb 24, 2005 at 02:12:57PM -0800, Brooks Davis wrote:
> > I would like to propose that we move the initdiskless script out of rc.d
> > and back into /etc.  The reason for doing this is that initdiskless is
> > really about bootstrapping /etc from a minimial configuration.  Thus
> > running it via rcorder is really running it too early. 
>                                               ^^^^^^^^^
> I think you mean too late, right?
> 
> > By moving it to
> > /etc and running it directly from /etc/rc (possiably conditionally based
> > on the existance of /conf) we fix this issue.  The main benefit of this
> > is that /etc/rc.d can now be modified or created entierly from entries
> > under /conf which could make it easier to maintain extra scripts in the
> > main flow of rc.d.
> > 
> > The change to /etc/rc would look something like:
> > 
> > diff -u -p -r1.335 rc
> > --- rc  8 Oct 2004 14:23:49 -0000       1.335
> > +++ rc  24 Feb 2005 21:02:18 -0000
> > @@ -50,6 +50,10 @@ HOME=/
> >  PATH=/sbin:/bin:/usr/sbin:/usr/bin
> >  export HOME PATH
> >  
> > +if [ -d /conf ]; then
> > +	/etc/rc.initdiskless
> > +fi
> > +
> 
> This is too generic. Isn't there some way of definitely knowing
> whether this is a diskless boot?
> 
> >  . /etc/rc.subr
> >  
> >  # Note: the system configuration files are loaded as part of
> > 
> > 
> > Does anyone have major objections to this change?  The goal is to run
> > initdiskless as early as possible so /etc can be as minimal as possible
> > at that point.
> 
> Sounds ok to me.

Does the following patch address your concerns?  I'd be having
etc/rc.d/initdiskless repo-copied to /etc/rc.initdiskless and would
remove etc/rc.d/preseedrandom.  etc/rc.d/rcconf.sh would lose its
dependency on initdiskless and become the first script to run.

-- Brooks

Index: rc
===================================================================
RCS file: /usr/cvs/src/etc/rc,v
retrieving revision 1.335
diff -u -p -r1.335 rc
--- rc	8 Oct 2004 14:23:49 -0000	1.335
+++ rc	2 Mar 2005 17:57:29 -0000
@@ -50,6 +50,11 @@ HOME=/
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 export HOME PATH
 
+dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
+if [ ${dlv:=0} -ne 0 -o -f /etc/diskless ]; then
+	/etc/rc.initdiskless
+fi
+
 . /etc/rc.subr
 
 # Note: the system configuration files are loaded as part of
Index: rc.d/initdiskless
===================================================================
RCS file: /usr/cvs/src/etc/rc.d/initdiskless,v
retrieving revision 1.41
diff -u -p -r1.41 initdiskless
--- rc.d/initdiskless	12 Dec 2004 08:04:26 -0000	1.41
+++ rc.d/initdiskless	2 Mar 2005 18:20:42 -0000
@@ -124,9 +124,6 @@
 #
 # (end of documentation, now get to the real code)
 
-dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
-[ ${dlv:=0} -eq 0 ] && [ ! -f /etc/diskless ] && exit 0
-
 # chkerr:
 #
 # Routine to check for error
@@ -171,11 +168,16 @@ create_md() {
 #
 # set -v
 
+# We need some entropy for some commands to work, so feed the PRNG.
+( ps -fauxww; sysctl -a; date; df -ib; dmesg; ps -fauxww; ) \
+    | dd of=/dev/random bs=8k 2>/dev/null
+
 # Figure out our interface and IP.
 #
 bootp_ifc=""
 bootp_ipa=""
 bootp_ipbca=""
+dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
 if [ ${dlv:=0} -ne 0 ] ; then
 	iflist=`ifconfig -l`
 	for i in ${iflist} ; do
@@ -321,3 +323,9 @@ done
 
 # umount partitions used to fill the memory filesystems
 [ -n "${to_umount}" ] && umount $to_umount
+
+# The entropy we fed the PRNG was low quality to mark it unseeded.
+seeded=`sysctl -n kern.random.sys.seeded 2>/dev/null`
+if [ -n "${seeded}" ]; then
+	sysctl kern.random.sys.seeded=0 2>/dev/null
+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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-rc/attachments/20050302/7693fee8/attachment.bin


More information about the freebsd-rc mailing list