2001-06-16 07:16:14 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2002-06-13 22:14:37 +00:00
|
|
|
# $FreeBSD$
|
2001-06-16 07:16:14 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: mountcritlocal
|
2010-05-19 19:03:19 +00:00
|
|
|
# REQUIRE: root hostid_save mdconfig
|
2010-11-25 18:20:28 +00:00
|
|
|
# KEYWORD: nojail shutdown
|
2001-06-16 07:16:14 +00:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name="mountcritlocal"
|
2016-04-23 16:10:54 +00:00
|
|
|
desc="Mount critical local filesystems"
|
2001-06-16 07:16:14 +00:00
|
|
|
start_cmd="mountcritlocal_start"
|
2010-11-25 18:20:28 +00:00
|
|
|
stop_cmd=sync
|
2001-06-16 07:16:14 +00:00
|
|
|
|
|
|
|
mountcritlocal_start()
|
|
|
|
{
|
2015-10-30 15:52:10 +00:00
|
|
|
local err holders waited
|
2008-03-06 14:39:33 +00:00
|
|
|
|
2004-01-17 10:40:45 +00:00
|
|
|
# Set up the list of network filesystem types for which mounting
|
|
|
|
# should be delayed until after network initialization.
|
|
|
|
case ${extra_netfs_types} in
|
|
|
|
[Nn][Oo])
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
netfs_types="${netfs_types} ${extra_netfs_types}"
|
2002-06-13 22:14:37 +00:00
|
|
|
;;
|
2004-01-17 10:40:45 +00:00
|
|
|
esac
|
2002-06-13 22:14:37 +00:00
|
|
|
|
2004-01-17 10:40:45 +00:00
|
|
|
# Mount everything except nfs filesystems.
|
2016-04-23 16:10:54 +00:00
|
|
|
check_startmsgs && echo -n 'Mounting local filesystems:'
|
2004-01-17 10:40:45 +00:00
|
|
|
mount_excludes='no'
|
|
|
|
for i in ${netfs_types}; do
|
|
|
|
fstype=${i%:*}
|
|
|
|
mount_excludes="${mount_excludes}${fstype},"
|
|
|
|
done
|
|
|
|
mount_excludes=${mount_excludes%,}
|
2015-10-30 15:52:10 +00:00
|
|
|
|
2016-01-14 16:55:07 +00:00
|
|
|
# Originally, root mount hold had to be released before mounting
|
|
|
|
# the root filesystem. This delayed the boot, so it was changed
|
|
|
|
# to only wait if the root device isn't readily available. This
|
|
|
|
# can result in this script executing before all the devices - such
|
|
|
|
# as graid(8) - are available. Thus, should the mount fail,
|
|
|
|
# we will wait for the root mount hold release and retry.
|
2004-01-17 10:40:45 +00:00
|
|
|
mount -a -t ${mount_excludes}
|
2008-03-06 14:39:33 +00:00
|
|
|
err=$?
|
2016-01-14 16:53:17 +00:00
|
|
|
if [ ${err} -ne 0 ]; then
|
2015-10-30 15:52:10 +00:00
|
|
|
echo
|
|
|
|
echo 'Mounting /etc/fstab filesystems failed,' \
|
|
|
|
'will retry after root mount hold release'
|
|
|
|
|
|
|
|
waited=0
|
|
|
|
while [ ${waited} -lt ${root_hold_delay} ]; do
|
|
|
|
holders="$(sysctl -n vfs.root_mount_hold)"
|
|
|
|
if [ -z "${holders}" ]; then
|
|
|
|
break;
|
|
|
|
fi
|
|
|
|
if [ ${waited} -eq 0 ]; then
|
|
|
|
echo -n "Waiting ${root_hold_delay}s" \
|
|
|
|
"for the root mount holders: ${holders}"
|
|
|
|
else
|
|
|
|
echo -n .
|
|
|
|
fi
|
|
|
|
if [ ${waited} -eq ${root_hold_delay} ]; then
|
|
|
|
break 2
|
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
waited=$(($waited + 1))
|
|
|
|
done
|
|
|
|
mount -a -t ${mount_excludes}
|
|
|
|
err=$?
|
|
|
|
fi
|
|
|
|
|
2009-10-10 22:17:03 +00:00
|
|
|
check_startmsgs && echo '.'
|
2004-01-17 10:40:45 +00:00
|
|
|
|
2008-03-06 14:39:33 +00:00
|
|
|
case ${err} in
|
2004-01-17 10:40:45 +00:00
|
|
|
0)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo 'Mounting /etc/fstab filesystems failed,' \
|
2015-10-30 15:52:10 +00:00
|
|
|
'startup aborted'
|
2007-05-18 12:04:41 +00:00
|
|
|
stop_boot true
|
2002-06-13 22:14:37 +00:00
|
|
|
;;
|
|
|
|
esac
|
2001-06-16 07:16:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|