mountcritlocal revision 294021
1#!/bin/sh 2# 3# $FreeBSD: head/etc/rc.d/mountcritlocal 294021 2016-01-14 16:53:17Z trasz $ 4# 5 6# PROVIDE: mountcritlocal 7# REQUIRE: root hostid_save mdconfig 8# KEYWORD: nojail shutdown 9 10. /etc/rc.subr 11 12name="mountcritlocal" 13start_cmd="mountcritlocal_start" 14stop_cmd=sync 15 16mountcritlocal_start() 17{ 18 local err holders waited 19 20 # Set up the list of network filesystem types for which mounting 21 # should be delayed until after network initialization. 22 case ${extra_netfs_types} in 23 [Nn][Oo]) 24 ;; 25 *) 26 netfs_types="${netfs_types} ${extra_netfs_types}" 27 ;; 28 esac 29 30 # Mount everything except nfs filesystems. 31 check_startmsgs && echo -n 'Mounting local file systems:' 32 mount_excludes='no' 33 for i in ${netfs_types}; do 34 fstype=${i%:*} 35 mount_excludes="${mount_excludes}${fstype}," 36 done 37 mount_excludes=${mount_excludes%,} 38 39 # Originally, root mount hold had to be released before mounting the root 40 # filesystem. This delayed the boot, so it was changed to only wait if 41 # the root device isn't readily available. This can result in this script 42 # executing before all the devices - such as graid(8) - are available. 43 # Thus, should the mount fail, we will wait for the root mount hold release 44 # and retry. 45 mount -a -t ${mount_excludes} 46 err=$? 47 if [ ${err} -ne 0 ]; then 48 echo 49 echo 'Mounting /etc/fstab filesystems failed,' \ 50 'will retry after root mount hold release' 51 52 waited=0 53 while [ ${waited} -lt ${root_hold_delay} ]; do 54 holders="$(sysctl -n vfs.root_mount_hold)" 55 if [ -z "${holders}" ]; then 56 break; 57 fi 58 if [ ${waited} -eq 0 ]; then 59 echo -n "Waiting ${root_hold_delay}s" \ 60 "for the root mount holders: ${holders}" 61 else 62 echo -n . 63 fi 64 if [ ${waited} -eq ${root_hold_delay} ]; then 65 break 2 66 fi 67 sleep 1 68 waited=$(($waited + 1)) 69 done 70 mount -a -t ${mount_excludes} 71 err=$? 72 fi 73 74 check_startmsgs && echo '.' 75 76 case ${err} in 77 0) 78 ;; 79 *) 80 echo 'Mounting /etc/fstab filesystems failed,' \ 81 'startup aborted' 82 stop_boot true 83 ;; 84 esac 85} 86 87load_rc_config $name 88run_rc_command "$1" 89