summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorbsd <bsd@FreeBSD.org>2001-05-09 15:13:51 +0000
committerbsd <bsd@FreeBSD.org>2001-05-09 15:13:51 +0000
commit3cc4938297c88cc1f7b39876590c6593a9dd3211 (patch)
treea06d8b6079aefba80a37f57e231d3f3e36ad6e98 /etc
parenta968ca96b61c019a71445292f287bfb6efafc46f (diff)
downloadFreeBSD-src-3cc4938297c88cc1f7b39876590c6593a9dd3211.zip
FreeBSD-src-3cc4938297c88cc1f7b39876590c6593a9dd3211.tar.gz
* Simplify the population of the /etc memory filesystem. To avoid
the null mount, we currently create a temporary mfs on /tmp, copy /etc to /tmp, then mount /etc as mfs and copy everything back from /tmp, then delete the /tmp mfs. The patch eliminates the temporary /tmp mfs and the subsequent copying and simply populates the /etc mfs by copying from /conf/default/etc. This requires that /conf/default/etc contain a complete copy of all the /etc stuff instead of just overrides. I don't think that is too much of an extra step in setting up a diskless environment. * Provide the ability to make /tmp a memory filesystem independent of /var. This removes the requirement that /tmp be a symlink to /var/tmp and this makes the diskless code work with the default filesystem layout. If a seperate /tmp memory filesystem is created, the 'tmpsize' environment variable is used to determine its size (default to 10 Meg). * Reduce diffs between the -current and -stable versions of these files to a bare minimum. Only the definition of the shell function 'mount_md' is different. Not Objected to by: -arch@, -small@ MFC after: 2 days
Diffstat (limited to 'etc')
-rw-r--r--etc/rc.d/diskless26
-rw-r--r--etc/rc.d/initdiskless18
-rw-r--r--etc/rc.d/resolv26
-rw-r--r--etc/rc.d/tmp26
-rw-r--r--etc/rc.d/var26
-rw-r--r--etc/rc.diskless118
-rw-r--r--etc/rc.diskless226
-rw-r--r--etc/rc.initdiskless18
8 files changed, 102 insertions, 82 deletions
diff --git a/etc/rc.d/diskless b/etc/rc.d/diskless
index 37c1cf6..f297e24 100644
--- a/etc/rc.d/diskless
+++ b/etc/rc.d/diskless
@@ -29,10 +29,20 @@
# PROVIDE: diskless
# REQUIRE: initdiskless mountcritlocal
+# BEFORE: addswap random
+# KEYWORD: FreeBSD
+dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
+[ ${dlv:=0} -eq 0 ] && exit 0
+
+name="diskless2"
+
+# Provide a function for normalizing the mounting of memory
+# filesystems. This should allow the rest of the code here to remain
+# as close as possible between 5-current and 4-stable.
# $1 = size
# $2 = mount point
- /sbin/newfs /dev/md$3c
+# $3 = md unit number (ignored in pre 5.0 systems)
# $4 = (optional) bytes-per-inode
mount_md()
{
@@ -46,7 +56,7 @@ mount_md()
}
echo "+++ mfs_mount of /var"
-mount_md ${varsize:=65536} /var 2
+mount_md ${varsize:=65536} /var 1
if [ -r /etc/rc.subr ]; then
. /etc/rc.subr
load_rc_config $name
@@ -63,11 +73,11 @@ fi
if [ -d /conf/default/etc ]; then
newaliases
fi
-# We assume that /tmp is symlinked to /var/tmp on the shared root
-# partition. mount_null seems to have problems.
-#if [ ! -h /tmp -a ! -h /var/tmp ]; then
-# mount_null /var/tmp /tmp
-#fi
+
+#
+# /var/tmp, otherwise, use a small memory filesystem for /tmp.
+ mount_md ${tmpsize:=20480} /tmp 2
+# so if /var/tmp == /tmp, then you don't get a vi.recover.
#
if [ ! -h /tmp ]; then
mount_md ${tmpsize:=64m} /tmp 2
@@ -75,7 +85,7 @@ if [ ! -h /tmp ]; then
fi
if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
- mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
+ # we have DEVFS, no worries...
true
else
# extract a list of device entries, then copy them to a writable fs
diff --git a/etc/rc.d/initdiskless b/etc/rc.d/initdiskless
index 6f19e3c..fdf71c6 100644
--- a/etc/rc.d/initdiskless
+++ b/etc/rc.d/initdiskless
@@ -100,22 +100,12 @@ echo "Interface ${bootp_ifc} IP-Address ${bootp_ipa} Broadcast ${bootp_ipbca}"
# Create an MFS /tmp to temporarily hold files from /etc until we
# can bootstrap /etc as an MFS.
-mount_md 4096 /tmp 0
-chmod 1777 /tmp
-chkerr $? "MFS mount on /tmp"
-/bin/cp -Rp /etc /tmp
-chkerr $? "cp /etc to /tmp/etc MFS"
-
-mount_md 4096 /etc 1
+mount_md 4096 /etc 0
chkerr $? "MFS mount on /etc"
/bin/chmod 755 /etc
-/bin/cp -Rp /tmp/etc/* /etc
-chkerr $? "cp /tmp/etc to /etc MFS"
-
-rm -rf /tmp/etc
-/sbin/umount /tmp
-/sbin/mdconfig -d -u 0
+/bin/cp -Rp /conf/default/etc/* /etc
+chkerr $? "cp /conf/default/etc to /etc MFS"
# Allow for override files to replace files in /etc. Use /conf/*/etc
# to find the override files. First choice is default files that
@@ -127,7 +117,7 @@ rm -rf /tmp/etc
# on separate subnets.
#
-for i in default ${bootp_ipbca} ${bootp_ipa} ; do
+for i in ${bootp_ipbca} ${bootp_ipa} ; do
if [ -d /conf/${i}/etc ]; then
cp -Rp /conf/${i}/etc/* /etc
fi
diff --git a/etc/rc.d/resolv b/etc/rc.d/resolv
index 37c1cf6..f297e24 100644
--- a/etc/rc.d/resolv
+++ b/etc/rc.d/resolv
@@ -29,10 +29,20 @@
# PROVIDE: diskless
# REQUIRE: initdiskless mountcritlocal
+# BEFORE: addswap random
+# KEYWORD: FreeBSD
+dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
+[ ${dlv:=0} -eq 0 ] && exit 0
+
+name="diskless2"
+
+# Provide a function for normalizing the mounting of memory
+# filesystems. This should allow the rest of the code here to remain
+# as close as possible between 5-current and 4-stable.
# $1 = size
# $2 = mount point
- /sbin/newfs /dev/md$3c
+# $3 = md unit number (ignored in pre 5.0 systems)
# $4 = (optional) bytes-per-inode
mount_md()
{
@@ -46,7 +56,7 @@ mount_md()
}
echo "+++ mfs_mount of /var"
-mount_md ${varsize:=65536} /var 2
+mount_md ${varsize:=65536} /var 1
if [ -r /etc/rc.subr ]; then
. /etc/rc.subr
load_rc_config $name
@@ -63,11 +73,11 @@ fi
if [ -d /conf/default/etc ]; then
newaliases
fi
-# We assume that /tmp is symlinked to /var/tmp on the shared root
-# partition. mount_null seems to have problems.
-#if [ ! -h /tmp -a ! -h /var/tmp ]; then
-# mount_null /var/tmp /tmp
-#fi
+
+#
+# /var/tmp, otherwise, use a small memory filesystem for /tmp.
+ mount_md ${tmpsize:=20480} /tmp 2
+# so if /var/tmp == /tmp, then you don't get a vi.recover.
#
if [ ! -h /tmp ]; then
mount_md ${tmpsize:=64m} /tmp 2
@@ -75,7 +85,7 @@ if [ ! -h /tmp ]; then
fi
if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
- mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
+ # we have DEVFS, no worries...
true
else
# extract a list of device entries, then copy them to a writable fs
diff --git a/etc/rc.d/tmp b/etc/rc.d/tmp
index 37c1cf6..f297e24 100644
--- a/etc/rc.d/tmp
+++ b/etc/rc.d/tmp
@@ -29,10 +29,20 @@
# PROVIDE: diskless
# REQUIRE: initdiskless mountcritlocal
+# BEFORE: addswap random
+# KEYWORD: FreeBSD
+dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
+[ ${dlv:=0} -eq 0 ] && exit 0
+
+name="diskless2"
+
+# Provide a function for normalizing the mounting of memory
+# filesystems. This should allow the rest of the code here to remain
+# as close as possible between 5-current and 4-stable.
# $1 = size
# $2 = mount point
- /sbin/newfs /dev/md$3c
+# $3 = md unit number (ignored in pre 5.0 systems)
# $4 = (optional) bytes-per-inode
mount_md()
{
@@ -46,7 +56,7 @@ mount_md()
}
echo "+++ mfs_mount of /var"
-mount_md ${varsize:=65536} /var 2
+mount_md ${varsize:=65536} /var 1
if [ -r /etc/rc.subr ]; then
. /etc/rc.subr
load_rc_config $name
@@ -63,11 +73,11 @@ fi
if [ -d /conf/default/etc ]; then
newaliases
fi
-# We assume that /tmp is symlinked to /var/tmp on the shared root
-# partition. mount_null seems to have problems.
-#if [ ! -h /tmp -a ! -h /var/tmp ]; then
-# mount_null /var/tmp /tmp
-#fi
+
+#
+# /var/tmp, otherwise, use a small memory filesystem for /tmp.
+ mount_md ${tmpsize:=20480} /tmp 2
+# so if /var/tmp == /tmp, then you don't get a vi.recover.
#
if [ ! -h /tmp ]; then
mount_md ${tmpsize:=64m} /tmp 2
@@ -75,7 +85,7 @@ if [ ! -h /tmp ]; then
fi
if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
- mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
+ # we have DEVFS, no worries...
true
else
# extract a list of device entries, then copy them to a writable fs
diff --git a/etc/rc.d/var b/etc/rc.d/var
index 37c1cf6..f297e24 100644
--- a/etc/rc.d/var
+++ b/etc/rc.d/var
@@ -29,10 +29,20 @@
# PROVIDE: diskless
# REQUIRE: initdiskless mountcritlocal
+# BEFORE: addswap random
+# KEYWORD: FreeBSD
+dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
+[ ${dlv:=0} -eq 0 ] && exit 0
+
+name="diskless2"
+
+# Provide a function for normalizing the mounting of memory
+# filesystems. This should allow the rest of the code here to remain
+# as close as possible between 5-current and 4-stable.
# $1 = size
# $2 = mount point
- /sbin/newfs /dev/md$3c
+# $3 = md unit number (ignored in pre 5.0 systems)
# $4 = (optional) bytes-per-inode
mount_md()
{
@@ -46,7 +56,7 @@ mount_md()
}
echo "+++ mfs_mount of /var"
-mount_md ${varsize:=65536} /var 2
+mount_md ${varsize:=65536} /var 1
if [ -r /etc/rc.subr ]; then
. /etc/rc.subr
load_rc_config $name
@@ -63,11 +73,11 @@ fi
if [ -d /conf/default/etc ]; then
newaliases
fi
-# We assume that /tmp is symlinked to /var/tmp on the shared root
-# partition. mount_null seems to have problems.
-#if [ ! -h /tmp -a ! -h /var/tmp ]; then
-# mount_null /var/tmp /tmp
-#fi
+
+#
+# /var/tmp, otherwise, use a small memory filesystem for /tmp.
+ mount_md ${tmpsize:=20480} /tmp 2
+# so if /var/tmp == /tmp, then you don't get a vi.recover.
#
if [ ! -h /tmp ]; then
mount_md ${tmpsize:=64m} /tmp 2
@@ -75,7 +85,7 @@ if [ ! -h /tmp ]; then
fi
if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
- mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
+ # we have DEVFS, no worries...
true
else
# extract a list of device entries, then copy them to a writable fs
diff --git a/etc/rc.diskless1 b/etc/rc.diskless1
index 6f19e3c..fdf71c6 100644
--- a/etc/rc.diskless1
+++ b/etc/rc.diskless1
@@ -100,22 +100,12 @@ echo "Interface ${bootp_ifc} IP-Address ${bootp_ipa} Broadcast ${bootp_ipbca}"
# Create an MFS /tmp to temporarily hold files from /etc until we
# can bootstrap /etc as an MFS.
-mount_md 4096 /tmp 0
-chmod 1777 /tmp
-chkerr $? "MFS mount on /tmp"
-/bin/cp -Rp /etc /tmp
-chkerr $? "cp /etc to /tmp/etc MFS"
-
-mount_md 4096 /etc 1
+mount_md 4096 /etc 0
chkerr $? "MFS mount on /etc"
/bin/chmod 755 /etc
-/bin/cp -Rp /tmp/etc/* /etc
-chkerr $? "cp /tmp/etc to /etc MFS"
-
-rm -rf /tmp/etc
-/sbin/umount /tmp
-/sbin/mdconfig -d -u 0
+/bin/cp -Rp /conf/default/etc/* /etc
+chkerr $? "cp /conf/default/etc to /etc MFS"
# Allow for override files to replace files in /etc. Use /conf/*/etc
# to find the override files. First choice is default files that
@@ -127,7 +117,7 @@ rm -rf /tmp/etc
# on separate subnets.
#
-for i in default ${bootp_ipbca} ${bootp_ipa} ; do
+for i in ${bootp_ipbca} ${bootp_ipa} ; do
if [ -d /conf/${i}/etc ]; then
cp -Rp /conf/${i}/etc/* /etc
fi
diff --git a/etc/rc.diskless2 b/etc/rc.diskless2
index 189d5e3..a3f58fe 100644
--- a/etc/rc.diskless2
+++ b/etc/rc.diskless2
@@ -29,10 +29,20 @@
# rc.diskless2
#
+# Provide a function for normalizing the mounting of memory
+# filesystems. This should allow the rest of the code here to remain
+# as close as possible between 5-current and 4-stable.
+# $1 = size
+# $2 = mount point
+# $3 = md unit number (ignored in pre 5.0 systems)
+# $4 = (optional) bytes-per-inode
mount_md() {
+ if [ -n "$4" ]; then
+ bpi="-i $4"
+ fi
/sbin/mdconfig -a -t malloc -s $1 -u $3
/sbin/disklabel -r -w md$3 auto
- /sbin/newfs /dev/md$3c
+ /sbin/newfs $bpi /dev/md$3c
/sbin/mount /dev/md$3c $2
}
@@ -46,7 +56,7 @@ elif [ -r /etc/rc.conf ]; then
fi
echo "+++ mfs_mount of /var"
-mount_md ${varsize:=65536} /var 2
+mount_md ${varsize:=65536} /var 1
echo "+++ populate /var using /etc/mtree/BSD.var.dist"
/usr/sbin/mtree -deU -f /etc/mtree/BSD.var.dist -p /var
@@ -63,11 +73,11 @@ mount -a # chown and chgrp are in /usr
# XXX make sure to create one dir for each printer as requested by lpd
#
-# We assume that /tmp is symlinked to /var/tmp on the shared root
-# partition. mount_null seems to have problems.
-#if [ ! -h /tmp -a ! -h /var/tmp ]; then
-# mount_null /var/tmp /tmp
-#fi
+# If /tmp is a symlink, assume it points to somewhere writable, like
+# /var/tmp, otherwise, use a small memory filesystem for /tmp.
+if [ ! -h /tmp ]; then
+ mount_md ${tmpsize:=20480} /tmp 2
+fi
if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
# we have DEVFS, no worries...
@@ -75,6 +85,6 @@ if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
else
# extract a list of device entries, then copy them to a writable fs
(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
- mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
+ mount_md 4096 /dev 3 512
(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
fi
diff --git a/etc/rc.initdiskless b/etc/rc.initdiskless
index 6f19e3c..fdf71c6 100644
--- a/etc/rc.initdiskless
+++ b/etc/rc.initdiskless
@@ -100,22 +100,12 @@ echo "Interface ${bootp_ifc} IP-Address ${bootp_ipa} Broadcast ${bootp_ipbca}"
# Create an MFS /tmp to temporarily hold files from /etc until we
# can bootstrap /etc as an MFS.
-mount_md 4096 /tmp 0
-chmod 1777 /tmp
-chkerr $? "MFS mount on /tmp"
-/bin/cp -Rp /etc /tmp
-chkerr $? "cp /etc to /tmp/etc MFS"
-
-mount_md 4096 /etc 1
+mount_md 4096 /etc 0
chkerr $? "MFS mount on /etc"
/bin/chmod 755 /etc
-/bin/cp -Rp /tmp/etc/* /etc
-chkerr $? "cp /tmp/etc to /etc MFS"
-
-rm -rf /tmp/etc
-/sbin/umount /tmp
-/sbin/mdconfig -d -u 0
+/bin/cp -Rp /conf/default/etc/* /etc
+chkerr $? "cp /conf/default/etc to /etc MFS"
# Allow for override files to replace files in /etc. Use /conf/*/etc
# to find the override files. First choice is default files that
@@ -127,7 +117,7 @@ rm -rf /tmp/etc
# on separate subnets.
#
-for i in default ${bootp_ipbca} ${bootp_ipa} ; do
+for i in ${bootp_ipbca} ${bootp_ipa} ; do
if [ -d /conf/${i}/etc ]; then
cp -Rp /conf/${i}/etc/* /etc
fi
OpenPOWER on IntegriCloud