localmount/netmount: allow mount points to be marked critical

In previous releases, we either treated no mount points as critical or
all of them.

Now both localmount and netmount support a critical_mounts setting. If
mount points listed in this setting fail to mount, localmount and
netmount will fail.
This commit is contained in:
William Hubbs 2016-04-25 12:04:34 -05:00
parent 1c3c2cf6d8
commit 5d130cc45c
4 changed files with 26 additions and 13 deletions

View File

@ -2,8 +2,9 @@
# This could be useful for some NFS related work. # This could be useful for some NFS related work.
#no_umounts="/dir1:/var/dir2" #no_umounts="/dir1:/var/dir2"
# #
# Ignore errors when mounting local file systems. # Mark certain mount points as critical.
# This should be left alone unless you know what you are doing. If it is # This contains aspace separated list of mount points which should be
# set to yes, not only will we allow mount failures, but we will ignore # considered critical. If one of these mount points cannot be mounted,
# syntax errors in fstab. # localmount will fail.
#ignore_mount_errors="NO" # By default, this is empty.
#critical_mounts="/home /var"

View File

@ -38,3 +38,10 @@
# other words, please change it to be more suited to your system. # other words, please change it to be more suited to your system.
# #
rc_need="net" rc_need="net"
#
# Mark certain mount points as critical.
# This contains aspace separated list of mount points which should be
# considered critical. If one of these mount points cannot be mounted,
# netmount will fail.
# By default, this is empty.
#critical_mounts="/home /var"

View File

@ -22,7 +22,7 @@ depend()
start() start()
{ {
# Mount local filesystems in /etc/fstab. # Mount local filesystems in /etc/fstab.
local types="noproc" x= no_netdev= rc= local critical= types="noproc" x= no_netdev= rc=
for x in $net_fs_list $extra_net_fs_list; do for x in $net_fs_list $extra_net_fs_list; do
types="${types},no${x}" types="${types},no${x}"
done done
@ -37,13 +37,13 @@ start()
mount -at "$types" $no_netdev mount -at "$types" $no_netdev
eend $? "Some local filesystem failed to mount" eend $? "Some local filesystem failed to mount"
rc=$? rc=$?
if [ "$RC_UNAME" != Linux ]; then if [ -z "$critical_mounts" ]; then
rc=0
elif yesno "${ignore_mount_errors:-NO}"; then
if [ $rc -ne 0 ]; then
ewarn "localmount: errors detected, but ignored"
fi
rc=0 rc=0
else
for x in ${critical_mounts}; do
mountinfo -q $x || critical=x
done
[-z "$critical" ] && rc=0
fi fi
return $rc return $rc
} }

View File

@ -42,8 +42,13 @@ start()
rc=$? rc=$?
fi fi
ewend $rc "Could not mount all network filesystems" ewend $rc "Could not mount all network filesystems"
if [ "$RC_UNAME" != Linux ]; then if [ -z "$critical_mounts" ]; then
rc=0 rc=0
else
for x in ${critical_mounts}; do
mountinfo -q $x || critical=x
done
[-z "$critical" ] && rc=0
fi fi
return $rc return $rc
} }