Refactor the root mount hold code and add the wait to etc/rc.d/fsck.
This fixes mounting (non-root) USB drives on boot with fsck enabled (with non-zero 'Pass#' field in fstab(5)). Reported by: Graham Menhennitt <graham at menhennitt.com.au> Reviewed by: jilles@ MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D6221
This commit is contained in:
parent
8fadf66094
commit
6e9bf96d6f
@ -31,7 +31,21 @@ fsck_start()
|
||||
fsck -p
|
||||
fi
|
||||
|
||||
case $? in
|
||||
err=$?
|
||||
if [ ${err} -eq 3 ]; then
|
||||
echo "Warning! Some of the devices might not be" \
|
||||
"available; retrying"
|
||||
root_hold_wait
|
||||
check_startmsgs && echo "Restarting file system checks:"
|
||||
if checkyesno background_fsck; then
|
||||
fsck -F -p
|
||||
else
|
||||
fsck -p
|
||||
fi
|
||||
err=$?
|
||||
fi
|
||||
|
||||
case ${err} in
|
||||
0)
|
||||
;;
|
||||
2)
|
||||
@ -68,7 +82,7 @@ fsck_start()
|
||||
stop_boot
|
||||
;;
|
||||
*)
|
||||
echo "Unknown error; help!"
|
||||
echo "Unknown error ${err}; help!"
|
||||
stop_boot
|
||||
;;
|
||||
esac
|
||||
|
@ -37,37 +37,12 @@ mountcritlocal_start()
|
||||
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 [ ${err} -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
|
||||
root_hold_wait
|
||||
mount -a -t ${mount_excludes}
|
||||
err=$?
|
||||
fi
|
||||
|
31
etc/rc.subr
31
etc/rc.subr
@ -1954,6 +1954,37 @@ geli_make_list()
|
||||
echo ${devices2}
|
||||
}
|
||||
|
||||
# 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 rc scripts executing before all the devices - such
|
||||
# as graid(8), or USB disks - can be accessed. This function can
|
||||
# be used to explicitly wait for root mount holds to be released.
|
||||
root_hold_wait()
|
||||
{
|
||||
local wait waited holders
|
||||
|
||||
waited=0
|
||||
while true; 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} -ge ${root_hold_delay} ]; then
|
||||
echo
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
waited=$(($waited + 1))
|
||||
done
|
||||
}
|
||||
|
||||
# Find scripts in local_startup directories that use the old syntax
|
||||
#
|
||||
find_local_scripts_old() {
|
||||
|
Loading…
Reference in New Issue
Block a user