Bug #615 ยป diskless.2.patch
| rc.d/diskless 12 Apr 2007 19:25:41 -0000 | ||
|---|---|---|
|
dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
|
||
|
[ ${dlv:=0} -eq 0 ] && exit 0
|
||
|
name="diskless2"
|
||
|
name="diskless"
|
||
|
# 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.
|
||
|
# Provide a function for normalizing the mounting of memory filesystems.
|
||
|
# $1 = size
|
||
|
# $2 = mount point
|
||
|
# $3 = (optional) bytes-per-inode
|
||
| ... | ... | |
|
if [ -n "$3" ]; then
|
||
|
bpi="-i $3"
|
||
|
fi
|
||
|
/sbin/mdmfs $bpi -s $1 -M md $2
|
||
|
/sbin/mount_mfs $bpi -s $1 swap $2
|
||
|
}
|
||
|
# If there is a global system configuration file, suck it in.
|
||
| ... | ... | |
|
rmdir /var/.diskless
|
||
|
else
|
||
|
echo "+++ mount_md of /var"
|
||
|
mount_md ${varsize:=32m} /var
|
||
|
mount_md ${varsize:=32768} /var
|
||
|
fi
|
||
|
if [ ! -d /var/db ]; then
|
||
| ... | ... | |
|
true
|
||
|
elif (/bin/mkdir /dev/.diskless 2> /dev/null); then
|
||
|
# if /dev is writable assume it has already been populated
|
||
|
# via rc.diskless1
|
||
|
# via rc.d/diskless
|
||
|
#
|
||
|
rmdir /dev/.diskless
|
||
|
else
|
||
| ... | ... | |
|
# generate our hostname
|
||
|
#
|
||
|
if [ -z "`hostname -s`" ]; then
|
||
|
hostname=`/bin/kenv dhcp.host-name`
|
||
|
hostname=`/usr/bin/kenv dhcp.host-name`
|
||
|
hostname $hostname
|
||
|
echo "Hostname is $hostname"
|
||
|
fi
|
||
| ... | ... | |
|
# build the resolv.conf
|
||
|
#
|
||
|
if [ ! -e /etc/resolv.conf ]; then
|
||
|
echo domain `/bin/kenv dhcp.domain-name` > /etc/resolv.conf
|
||
|
echo domain `/usr/bin/kenv dhcp.domain-name` > /etc/resolv.conf
|
||
|
set `/bin/kenv dhcp.domain-name-servers`
|
||
|
set `/usr/bin/kenv dhcp.domain-name-servers`
|
||
|
for ns in `IFS=','; echo $*`; do
|
||
|
echo nameserver $ns >> /etc/resolv.conf;
|
||
|
done
|
||
|
fi
|
||
| rc.d/initdiskless 12 Apr 2007 19:25:41 -0000 | ||
|---|---|---|
|
#
|
||
|
# If a subdirectory contains the file 'md_size', the contents of the
|
||
|
# file is used to determine the size of the memory filesystem, in 512
|
||
|
# byte sectors. The default is 8192 (4MB). You only have to specify an
|
||
|
# byte sectors. The default is 4096 (2MB). You only have to specify an
|
||
|
# md_size if the default doesn't work for you (i.e. if it is too big or
|
||
|
# too small). Note that in -current the default is 4096 (2MB). For
|
||
|
# example, /conf/base/etc/md_size might contain '16384'.
|
||
|
# too small). For example, /conf/base/etc/md_size might contain '16384'.
|
||
|
#
|
||
|
# If /conf/<special_dir>/SUBDIR.cpio.gz exists, the file is cpio'd into
|
||
|
# the specified /SUBDIR (and a memory filesystem is created for /SUBDIR
|
||
| ... | ... | |
|
# /conf/default/etc/{rc.conf,rc.local,fstab}. Your fstab should be sure
|
||
|
# to mount a /usr... typically an NFS readonly /usr.
|
||
|
#
|
||
|
# NOTE! rc.diskless2 will create /var, /tmp, and /dev. Those filesystems
|
||
|
# NOTE! rc.d/diskless will create /var, /tmp, and /dev. Those filesystems
|
||
|
# should not be specified in /conf. At least not yet.
|
||
|
dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
|
||
| ... | ... | |
|
# Create a generic memory disk
|
||
|
#
|
||
|
mount_md() {
|
||
|
/sbin/mdmfs -i 4096 -s $1 -M md $2
|
||
|
/sbin/mount_mfs -i 4096 -s $1 swap $2
|
||
|
}
|
||
|
# Create the memory filesystem if it has not already been created
|
||
|
#
|
||
|
create_md() {
|
||
|
if [ "x`eval echo \\$md_created_$1`" = "x" ]; then
|
||
|
if [ "x`eval echo \\$md_size_$1`" = "x" ]; then
|
||
|
md_size=4096
|
||
|
else
|
||
|
md_size=`eval echo \\$md_size_$1`
|
||
|
fi
|
||
|
mount_md $md_size /$1
|
||
|
/bin/chmod 755 /$1
|
||
|
eval md_created_$1=created
|
||
|
fi
|
||
|
if [ "x`eval echo \\$md_size_$1`" = "x" ]; then
|
||
|
md_size=4096
|
||
|
else
|
||
|
md_size=`eval echo \\$md_size_$1`
|
||
|
fi
|
||
|
mount_md $md_size /$1
|
||
|
/bin/chmod 755 /$1
|
||
|
eval md_created_$1=created
|
||
|
fi
|
||
|
}
|
||
|
# DEBUGGING
|
||
| ... | ... | |
|
#
|
||
|
# - calculate memory filesystem sizes. If the subdirectory (prior to
|
||
|
# NFS remounting) contains the file 'md_size', the contents specified
|
||
|
# in 512 byte sectors will be used to size the memory filesystem. Otherwise
|
||
|
# 8192 sectors (4MB) is used.
|
||
|
# in 512 byte sectors will be used to size the memory filesystem.
|
||
|
#
|
||
|
# - handle NFS remounts. If the subdirectory contains the file
|
||
|
# diskless_remount, the contents of the file is NFS mounted over
|
||
| ... | ... | |
|
#
|
||
|
subdir=${j##*/}
|
||
|
if [ -d $j -a -f $j/md_size ]; then
|
||
|
eval md_size_$subdir=`cat $j/md_size`
|
||
|
eval md_size_$subdir=`cat $j/md_size`
|
||
|
fi
|
||
|
# NFS remount
|
||
| ... | ... | |
|
if [ -d $j -a -f $j/diskless_remount ]; then
|
||
|
nfspt=`/bin/cat $j/diskless_remount`
|
||
|
if [ `expr "$nfspt" : '\(.\)'` = "/" ]; then
|
||
|
nfspt="${nfsroot}${nfspt}"
|
||
|
nfspt="${nfsroot}${nfspt}"
|
||
|
fi
|
||
|
mount_nfs $nfspt $j
|
||
|
chkerr $? "mount_nfs $nfspt $j"
|
||
|
fi
|
||
|
done
|
||
|
done
|
||
|
done
|
||
|
# - Create all required MFS filesystems and populate them from
|
||
| ... | ... | |
|
if [ -f $j ]; then
|
||
|
create_md $subdir
|
||
|
echo "Loading /$subdir from cpio archive $j"
|
||
|
(cd / ; /stand/gzip -d < $j | /stand/cpio --extract -d )
|
||
|
(cd / ; /usr/bin/gzip -d < $j | /usr/bin/cpio --extract -d )
|
||
|
fi
|
||
|
done
|
||
|
for j in /conf/$i/*.remove ; do
|
||
| ... | ... | |
|
fi
|
||
|
done
|
||
|
done
|
||