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 # nfs uses own script for that
19 if [ ! -f /etc/rc.d/init.d/nfsfs ]; then
20 NFSFSTAB=$(LC_ALL=C awk '!/^#/ && $3 ~ /^nfs/ && $3 != "nfsd" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
21 NFSMTAB=$(LC_ALL=C awk '$3 ~ /^nfs/ && $3 != "nfsd" && $2 != "/" { print $2 }' /proc/mounts)
24 CIFSFSTAB=$(LC_ALL=C awk '!/^#/ && $3 == "cifs" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
25 NCPFSTAB=$(LC_ALL=C awk '!/^#/ && $3 == "ncpfs" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
26 NETDEVFSTAB=$(LC_ALL=C awk '!/^#/ && $4 ~/_netdev/ && $4 !~ /noauto/ { print $1 }' /etc/fstab)
28 NFSMTAB=$(LC_ALL=C awk '$3 ~ /^nfs/ && $3 != "nfsd" && $2 != "/" { print $2 }' /proc/mounts)
29 CIFSMTAB=$(LC_ALL=C awk '$3 == "cifs" { print $2 }' /proc/mounts)
30 NCPMTAB=$(LC_ALL=C awk '$3 == "ncpfs" { print $2 }' /proc/mounts)
31 NETDEVMTAB=$(LC_ALL=C awk '$4 ~ /_netdev/ && $2 != "/" { print $2 }' /etc/mtab)
34 [ ! -f /var/lock/subsys/network ] && exit 0
35 [ "$(id -u)" != "0" ] && exit 4
38 [ ! -f /var/lock/subsys/rpcbind ] && service rpcbind start
39 run_cmd "Mounting NFS filesystems" mount -a -t nfs,nfs4
41 [ -n "$CIFSFSTAB" ] && run_cmd "Mounting CIFS filesystems" mount -a -t cifs
42 [ -n "$NCPFSTAB" ] && run_cmd "Mounting NCP filesystems" mount -a -t ncpfs
43 [ -n "$NETDEVFSTAB" ] &&
45 if [ -f /etc/mdadm.conf ]; then
48 if [ -f /etc/multipath.conf ] && [ -x /sbin/multipath ]; then
49 modprobe dm-multipath >/dev/null 2>&1
51 if [ -x /sbin/kpartx ]; then
52 /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a -p p"
55 if [ -x /sbin/lvm ]; then
56 if /sbin/lvm vgscan > /dev/null 2>&1 ; then
57 run_cmd "Setting up Logical Volume Management" /sbin/lvm vgchange -a y
61 if [ -f /etc/crypttab ]; then
65 show "Checking network-attached filesystems"; started
66 initlog -c "fsck -A -T -R -a -t opts=_netdev"
69 if [ "$rc" -gt 1 ]; then
72 nls "*** An error occurred during the file system check."
73 nls "*** Dropping you to a shell; the system will reboot"
74 nls "*** when you leave the shell."
76 PS1="$(nls '(Repair filesystem)# ')"; export PS1
77 [ "$SELINUX" = "1" ] && disable_selinux
78 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
86 touch /var/lock/subsys/netfs
87 run_cmd "Mounting other filesystems" mount -a -t nonfs,nfs4,cifs,ncpfs,gfs
91 # Unmount loopback stuff first
92 [ "$(id -u)" != "0" ] && exit 4
93 __umount_loopback_loop
94 if [ -n "$NETDEVMTAB" ]; then
95 __umount_loop '$4 ~ /_netdev/ && $2 != "/" {print $2}' \
97 "$(nls "Unmounting network block filesystems")" \
98 "$(nls "Unmounting network block filesystems (retry)")"
100 if [ -n "$NFSMTAB" ]; then
101 __umount_loop '$3 ~ /^nfs/ && $3 != "nfsd" && $2 != "/" {print $2}' \
103 "$(nls "Unmounting NFS filesystems")" \
104 "$(nls "Unmounting NFS filesystems (retry)")" \
107 [ -n "$CIFSMTAB" ] && run_cmd "Unmounting CIFS filesystems" umount -a -t cifs
108 [ -n "$NCPMTAB" ] && run_cmd "Unmounting NCP filesystems" umount -a -t ncp,ncpfs
109 rm -f /var/lock/subsys/netfs
113 if [ -f /proc/mounts ]; then
114 [ -n "$NFSFSTAB" ] && {
115 nls "Configured NFS mountpoints: "
116 for fs in $NFSFSTAB; do echo $fs ; done
118 [ -n "$CIFSFSTAB" ] && {
119 nls "Configured CIFS mountpoints: "
120 for fs in $CIFSFSTAB; do echo $fs ; done
122 [ -n "$NCPFSTAB" ] && {
123 nls "Configured NCP mountpoints: "
124 for fs in $NCPFSTAB; do echo $fs ; done
126 [ -n "$NETDEVFSTAB" ] && {
127 nls "Configured network block devices: "
128 for fs in $NETDEVFSTAB; do echo $fs ; done
130 [ -n "$NFSMTAB" ] && {
131 nls "Active NFS mountpoints: "
132 for fs in $NFSMTAB; do echo $fs ; done
134 [ -n "$CIFSMTAB" ] && {
135 nls "Active CIFS mountpoints: "
136 for fs in $CIFSMTAB; do echo $fs ; done
138 [ -n "$NCPMTAB" ] && {
139 nls "Active NCP mountpoints: "
140 for fs in $NCPMTAB; do echo $fs ; done
142 [ -n "$NETDEVMTAB" ] && {
143 nls "Active network block devices: "
144 for fs in $NETDEVMTAB; do echo $fs ; done
147 nls "/proc filesystem unavailable"
150 [ -r /var/lock/subsys/netfs ] || exit 3
154 # See how we were called.
173 msg_usage "$0 {start|stop|restart|reload|status}"