3 # netfs Mount network filesystems.
5 # Authors: Bill Nottingham <notting@redhat.com>
6 # AJ Lewis <alewis@redhat.com>
7 # Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
10 # description: Mounts and unmounts all Network File System (NFS), \
11 # CIFS (Lan Manager/Windows), and NCP (NetWare) mount points.
13 [ -f /etc/sysconfig/network ] || exit 0
14 . /etc/rc.d/init.d/functions
15 . /etc/rc.d/init.d/cryptsetup
16 . /etc/sysconfig/network
18 if [[ "$container" = lxc* ]]; then
22 # nfs uses own script for that
23 if [ ! -f /etc/rc.d/init.d/nfsfs ]; then
24 NFSFSTAB=$(LC_ALL=C awk '!/^#/ && $3 ~ /^nfs/ && $3 != "nfsd" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
25 NFSMTAB=$(LC_ALL=C awk '$3 ~ /^nfs/ && $3 != "nfsd" && $2 != "/" { print $2 }' /proc/mounts)
28 CIFSFSTAB=$(LC_ALL=C awk '!/^#/ && $3 == "cifs" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
29 NCPFSTAB=$(LC_ALL=C awk '!/^#/ && $3 == "ncpfs" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
30 NETDEVFSTAB=$(LC_ALL=C awk '!/^#/ && $4 ~/_netdev/ && $4 !~ /noauto/ { print $1 }' /etc/fstab)
32 NFSMTAB=$(LC_ALL=C awk '$3 ~ /^nfs/ && $3 != "nfsd" && $2 != "/" { print $2 }' /proc/mounts)
33 CIFSMTAB=$(LC_ALL=C awk '$3 == "cifs" { print $2 }' /proc/mounts)
34 NCPMTAB=$(LC_ALL=C awk '$3 == "ncpfs" { print $2 }' /proc/mounts)
35 NETDEVMTAB=$(LC_ALL=C awk '$4 ~ /_netdev/ && $2 != "/" { print $2 }' /etc/mtab)
38 if [ ! -f /var/lock/subsys/network ]; then
41 if [ "$(id -u)" != "0" ]; then
46 [ -n "$NFSFSTAB" ] && {
47 [ ! -f /var/lock/subsys/rpcbind ] && service rpcbind start
48 run_cmd "Mounting NFS filesystems" mount -a -t nfs,nfs4
51 [ -n "$CIFSFSTAB" ] && run_cmd "Mounting CIFS filesystems" mount -a -t cifs
52 [ -n "$NCPFSTAB" ] && run_cmd "Mounting NCP filesystems" mount -a -t ncpfs
54 [ -n "$NETDEVFSTAB" ] && {
55 if [ -f /etc/mdadm.conf ]; then
59 if [ -f /etc/multipath.conf ] && [ -x /sbin/multipath ]; then
60 modprobe dm-multipath >/dev/null 2>&1
62 if [ -x /sbin/kpartx ]; then
63 /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a -p p"
67 if [ -x /sbin/lvm ]; then
68 if /sbin/lvm vgscan > /dev/null 2>&1 ; then
69 run_cmd "Setting up Logical Volume Management" /sbin/lvm vgchange -a y
73 if [ -f /etc/crypttab ]; then
77 show "Checking network-attached filesystems"; started
78 initlog -c "fsck -A -T -R -a -t opts=_netdev"
81 if [ "$rc" -gt 1 ]; then
84 nls "*** An error occurred during the file system check."
85 nls "*** Dropping you to a shell; the system will reboot"
86 nls "*** when you leave the shell."
88 PS1="$(nls '(Repair filesystem)# ')"; export PS1
89 [ "$SELINUX" = "1" ] && disable_selinux
90 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
99 run_cmd "Mounting other filesystems" mount -a -t nonfs,nfs4,cifs,ncpfs,gfs,devpts
101 touch /var/lock/subsys/netfs
105 # Unmount loopback stuff first
106 if [ "$(id -u)" != "0" ]; then
111 __umount_loopback_loop
112 if [ -n "$NETDEVMTAB" ]; then
113 __umount_loop '$4 ~ /_netdev/ && $2 != "/" {print $2}' \
115 "$(nls "Unmounting network block filesystems")" \
116 "$(nls "Unmounting network block filesystems (retry)")"
118 if [ -n "$NFSMTAB" ]; then
119 __umount_loop '$3 ~ /^nfs/ && $3 != "nfsd" && $2 != "/" {print $2}' \
121 "$(nls "Unmounting NFS filesystems")" \
122 "$(nls "Unmounting NFS filesystems (retry)")" \
125 [ -n "$CIFSMTAB" ] && run_cmd "Unmounting CIFS filesystems" umount -a -t cifs
126 [ -n "$NCPMTAB" ] && run_cmd "Unmounting NCP filesystems" umount -a -t ncp,ncpfs
127 rm -f /var/lock/subsys/netfs
131 [ -r /var/lock/subsys/netfs ] || RETVAL=3
133 if [ ! -f /proc/mounts ]; then
134 nls "/proc filesystem unavailable"
138 [ -n "$NFSFSTAB" ] && {
139 nls "Configured NFS mountpoints: "
140 for fs in $NFSFSTAB; do echo $fs; done
142 [ -n "$CIFSFSTAB" ] && {
143 nls "Configured CIFS mountpoints: "
144 for fs in $CIFSFSTAB; do echo $fs; done
146 [ -n "$NCPFSTAB" ] && {
147 nls "Configured NCP mountpoints: "
148 for fs in $NCPFSTAB; do echo $fs; done
150 [ -n "$NETDEVFSTAB" ] && {
151 nls "Configured network block devices: "
152 for fs in $NETDEVFSTAB; do echo $fs; done
154 [ -n "$NFSMTAB" ] && {
155 nls "Active NFS mountpoints: "
156 for fs in $NFSMTAB; do echo $fs; done
158 [ -n "$CIFSMTAB" ] && {
159 nls "Active CIFS mountpoints: "
160 for fs in $CIFSMTAB; do echo $fs; done
162 [ -n "$NCPMTAB" ] && {
163 nls "Active NCP mountpoints: "
164 for fs in $NCPMTAB; do echo $fs; done
166 [ -n "$NETDEVMTAB" ] && {
167 nls "Active network block devices: "
168 for fs in $NETDEVMTAB; do echo $fs; done
173 # See how we were called.
192 msg_usage "$0 {start|stop|restart|reload|status}"