Commit first rc.diskless startup plus modifications to rc.conf and Makefile

to make it work.  NOTE!  Uses new kern.conf_dir sysctl.
This commit is contained in:
Matthew Dillon 1999-01-25 18:24:46 +00:00
parent 633dcb59ac
commit 5ab0c62f95
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=43198
3 changed files with 136 additions and 5 deletions

View file

@ -1,5 +1,5 @@
# from: @(#)Makefile 5.11 (Berkeley) 5/21/91
# $Id: Makefile,v 1.186 1999/01/10 21:08:26 rnordier Exp $
# $Id: Makefile,v 1.187 1999/01/13 08:20:53 hm Exp $
SUBDIR= sendmail
@ -9,7 +9,8 @@ BIN1= aliases amd.map crontab csh.cshrc csh.login csh.logout dm.conf \
newsyslog.conf pam.conf phones pccard.conf.sample \
printcap profile protocols \
rc rc.atm rc.conf rc.devfs rc.firewall rc.isdn rc.network rc.pccard \
rc.serial rc.shutdown etc.${MACHINE_ARCH}/rc.${MACHINE_ARCH} \
rc.diskless rc.serial rc.shutdown \
etc.${MACHINE_ARCH}/rc.${MACHINE_ARCH} \
remote security services shells syslog.conf \
etc.${MACHINE_ARCH}/ttys etc.${MACHINE_ARCH}/disktab rpc make.conf \
${.CURDIR}/../gnu/usr.bin/man/manpath/manpath.config \

View file

@ -6,7 +6,7 @@
#
# All arguments must be in double or single quotes.
#
# $Id: rc.conf,v 1.75 1999/01/13 17:32:37 joerg Exp $
# $Id: rc.conf,v 1.76 1999/01/17 03:32:07 grog Exp $
##############################################################
### Important initial Boot-time options #####################
@ -199,6 +199,19 @@ vinum_slices="" # put in names of vinum slices to enable vinum
##############################################################
### Allow local configuration override at the very end here ##
##############################################################
if [ -f /etc/rc.conf.local ]; then
. /etc/rc.conf.local
#
# If the kernel configuration script MIB exists, use it.
sysctl -n kern.conf_dir > /dev/null 2>&1
if [ $? = 0 ]; then
conf_dir=`sysctl -n kern.conf_dir`
fi
if [ "X$conf_dir" = "X" ]; then
conf_dir=/etc
fi
if [ -f $conf_dir/rc.conf.local ]; then
. $conf_dir/rc.conf.local
fi

117
etc/rc.diskless Normal file
View file

@ -0,0 +1,117 @@
#
# /etc/rc.diskless - general BOOTP startup
#
# BOOTP has mounted / for us. Assume a read-only mount. We must then
# - figure out where the NFS mount is coming from
# - mount /usr via nfs
# - figure out our IP by querying the interface
# - setup the configuration script directory
# - setup the configuration function
#
# SEE SAMPLE FILES IN /usr/share/examples/diskless. If you have nothing
# better to do, try:
#
# ln -s /usr/share/examples/diskless /conf
#
# but at least read the README.
# chkerr:
#
# Routine to check for error
#
# checks error code and drops into shell on failure.
# if shell exits, terminates script as well as /etc/rc.
chkerr() {
if [ $1 != 0 ]; then
echo "$2 failed: dropping into /bin/sh"
/bin/sh
# RESUME
fi
}
# DEBUGGING
#
set -v
# Figure out where the root mount is coming from, synthesize a mount
# for /usr and mount it. Also mount /var
#
# e.g. nfs_root might wind up as "A.B.C.D:/"
#
set `/bin/df /`
nfs_root=$8
mount_nfs -o ro ${nfs_root}/usr /usr
mount_nfs -o ro ${nfs_root}/var /var
chkerr $? "mount of /usr"
# Figure out our interface and IP.
#
bootp_ifc=`route -n get default | fgrep interface | awk '{ print $2; }'`
bootp_ipa=`ifconfig $bootp_ifc | fgrep inet | head -1 | awk '{ print $2; }'`
echo "Interface $bootp_ifc IP-Address $bootp_ipa"
# retarget the configuration directory, where rc.conf.local and rc.local
# are found. We set the directory to /conf/$bootp_ipa.
#
conf_dir=/conf/$bootp_ipa
sysctl -w kern.conf_dir=$conf_dir
sysctl -w kern.bootfile=$conf_dir/kernel
if [ ! -f $conf_dir/rc.conf.local ]; then
chkerr 1 "access to $conf_dir"
fi
# Tell /etc/rc to skip normal disk configuration
#
skip_diskconf=YES
diskless_mount_func=diskless_mount_system
# Default mounting pass procedure
#
# We have to create the filesystems that are expected
# to be writeable.
diskless_mount_system() {
sysctl -w net.inet.ip.portrange.first=4000
mount_mfs -s 2048 -T qp120at dummy /var/run
mount_mfs -s 16384 -T qp120at dummy /var/db
mount_mfs -s 65536 -T qp120at dummy /var/tmp
mount_mfs -s 65536 -T qp120at dummy /var/spool
chmod 755 /var/run
chmod 755 /var/db
chmod 755 /var/spool
chmod 1777 /var/tmp
#
# XXX /tmp should be a softlink to /var/tmp
mkdir /var/spool/mqueue
mkdir /var/spool/ljet4
mkdir /var/spool/lpd
mkdir /var/spool/output
mkdir /var/spool/output/lpd
chown daemon /var/spool/ljet4
chown -R root.daemon /var/spool/output
chgrp daemon /var/spool/lpd
# /proc may be necessary
#
mount_procfs proc /proc
# We need a R+W /dev ! Use cpio to copy /dev from the
# server to an MFS mount.
mkdir /tmp/root
mount ${nfs_root} /tmp/root
mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
( cd /tmp/root ; find -x dev | cpio -o -H newc ) | \
( cd / ; cpio -i -H newc -d )
umount /tmp/root
}