mountcritlocal revision 298514
178344Sobrien#!/bin/sh 278344Sobrien# 398184Sgordon# $FreeBSD: head/etc/rc.d/mountcritlocal 298514 2016-04-23 16:10:54Z lme $ 478344Sobrien# 578344Sobrien 678344Sobrien# PROVIDE: mountcritlocal 7208307Sdougb# REQUIRE: root hostid_save mdconfig 8215824Sdougb# KEYWORD: nojail shutdown 978344Sobrien 1078344Sobrien. /etc/rc.subr 1178344Sobrien 1278344Sobrienname="mountcritlocal" 13298514Slmedesc="Mount critical local filesystems" 1478344Sobrienstart_cmd="mountcritlocal_start" 15215824Sdougbstop_cmd=sync 1678344Sobrien 1778344Sobrienmountcritlocal_start() 1878344Sobrien{ 19290197Strasz local err holders waited 20176873Smtm 21124618Smtm # Set up the list of network filesystem types for which mounting 22124618Smtm # should be delayed until after network initialization. 23124618Smtm case ${extra_netfs_types} in 24124618Smtm [Nn][Oo]) 25124618Smtm ;; 26124618Smtm *) 27124618Smtm netfs_types="${netfs_types} ${extra_netfs_types}" 28124618Smtm ;; 29124618Smtm esac 3078344Sobrien 31124618Smtm # Mount everything except nfs filesystems. 32298514Slme check_startmsgs && echo -n 'Mounting local filesystems:' 33124618Smtm mount_excludes='no' 34124618Smtm for i in ${netfs_types}; do 35124618Smtm fstype=${i%:*} 36124618Smtm mount_excludes="${mount_excludes}${fstype}," 37124618Smtm done 38124618Smtm mount_excludes=${mount_excludes%,} 39290197Strasz 40294022Strasz # Originally, root mount hold had to be released before mounting 41294022Strasz # the root filesystem. This delayed the boot, so it was changed 42294022Strasz # to only wait if the root device isn't readily available. This 43294022Strasz # can result in this script executing before all the devices - such 44294022Strasz # as graid(8) - are available. Thus, should the mount fail, 45294022Strasz # we will wait for the root mount hold release and retry. 46124618Smtm mount -a -t ${mount_excludes} 47176873Smtm err=$? 48294021Strasz if [ ${err} -ne 0 ]; then 49290197Strasz echo 50290197Strasz echo 'Mounting /etc/fstab filesystems failed,' \ 51290197Strasz 'will retry after root mount hold release' 52290197Strasz 53290197Strasz waited=0 54290197Strasz while [ ${waited} -lt ${root_hold_delay} ]; do 55290197Strasz holders="$(sysctl -n vfs.root_mount_hold)" 56290197Strasz if [ -z "${holders}" ]; then 57290197Strasz break; 58290197Strasz fi 59290197Strasz if [ ${waited} -eq 0 ]; then 60290197Strasz echo -n "Waiting ${root_hold_delay}s" \ 61290197Strasz "for the root mount holders: ${holders}" 62290197Strasz else 63290197Strasz echo -n . 64290197Strasz fi 65290197Strasz if [ ${waited} -eq ${root_hold_delay} ]; then 66290197Strasz break 2 67290197Strasz fi 68290197Strasz sleep 1 69290197Strasz waited=$(($waited + 1)) 70290197Strasz done 71290197Strasz mount -a -t ${mount_excludes} 72290197Strasz err=$? 73290197Strasz fi 74290197Strasz 75197947Sdougb check_startmsgs && echo '.' 7698184Sgordon 77176873Smtm case ${err} in 78124618Smtm 0) 7998184Sgordon ;; 80124618Smtm *) 81124618Smtm echo 'Mounting /etc/fstab filesystems failed,' \ 82290197Strasz 'startup aborted' 83169668Smtm stop_boot true 8498184Sgordon ;; 8598184Sgordon esac 8678344Sobrien} 8778344Sobrien 8878344Sobrienload_rc_config $name 8978344Sobrienrun_rc_command "$1" 90