1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-04 12:52:15 +00:00

* 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
This commit is contained in:
Brian S. Dean 2001-05-09 15:13:51 +00:00
parent e2413c56ed
commit 44e0389495
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=76409
8 changed files with 102 additions and 82 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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