665aea9323
if they are not required for mounting rootfs. However, it's possible that some setups try to mount them in mountcritlocal (ie from fstab). Export the list of current root mount holds using a new sysctl, vfs.root_mount_hold, and make mountcritlocal retry if "mount -a" fails and the list is not empty. MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3709
89 lines
1.9 KiB
Bash
Executable File
89 lines
1.9 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
# PROVIDE: mountcritlocal
|
|
# REQUIRE: root hostid_save mdconfig
|
|
# KEYWORD: nojail shutdown
|
|
|
|
. /etc/rc.subr
|
|
|
|
name="mountcritlocal"
|
|
start_cmd="mountcritlocal_start"
|
|
stop_cmd=sync
|
|
|
|
mountcritlocal_start()
|
|
{
|
|
local err holders waited
|
|
|
|
# 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}"
|
|
;;
|
|
esac
|
|
|
|
# Mount everything except nfs filesystems.
|
|
check_startmsgs && echo -n 'Mounting local file systems:'
|
|
mount_excludes='no'
|
|
for i in ${netfs_types}; do
|
|
fstype=${i%:*}
|
|
mount_excludes="${mount_excludes}${fstype},"
|
|
done
|
|
mount_excludes=${mount_excludes%,}
|
|
|
|
# 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.
|
|
mount -a -t ${mount_excludes}
|
|
err=$?
|
|
if [ $? -ne 0 ]; then
|
|
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
|
|
|
|
check_startmsgs && echo '.'
|
|
|
|
case ${err} in
|
|
0)
|
|
;;
|
|
*)
|
|
echo 'Mounting /etc/fstab filesystems failed,' \
|
|
'startup aborted'
|
|
stop_boot true
|
|
;;
|
|
esac
|
|
}
|
|
|
|
load_rc_config $name
|
|
run_rc_command "$1"
|