1 | <sect1 id="postlfs-config-netfs" xreflabel="netfs">
|
---|
2 | <?dbhtml filename="netfs.html" dir="postlfs"?>
|
---|
3 | <title>Configuring for Network Filesystems</title>
|
---|
4 |
|
---|
5 | <para>While <acronym>LFS</acronym> is capable of mounting NFS volumes from
|
---|
6 | the get go, the lfs-bootscripts are not quite ready for this configuration.
|
---|
7 | Network filesystems should be unmounted before the network goes down. The
|
---|
8 | <filename>netfs</filename> script below will prepare your LFS for mounting
|
---|
9 | network filesystems at boot time, and unmounting them when the network
|
---|
10 | is stopped.</para>
|
---|
11 |
|
---|
12 | <para> The following commands will create the <filename>netfs</filename>
|
---|
13 | script:</para>
|
---|
14 |
|
---|
15 | <screen><command>cat > /etc/rc.d/init.d/netfs << "EOF"</command>
|
---|
16 | #!/bin/sh
|
---|
17 | # Begin $rc_base/init.d/netfs
|
---|
18 |
|
---|
19 | # Based on sysklogd script from LFS-3.1 and earlier.
|
---|
20 | # Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
|
---|
21 | # netfs script written by Nathan Coulson - conathan@conet.dyndns.org
|
---|
22 | # and by DJ Lucas - dj@lucasit.com
|
---|
23 |
|
---|
24 | . /etc/sysconfig/rc
|
---|
25 | . $rc_functions
|
---|
26 |
|
---|
27 | case "$1" in
|
---|
28 |
|
---|
29 | start)
|
---|
30 | # The following line mounts all entries in fstab that
|
---|
31 | # have the _netdev option. This is required for network
|
---|
32 | # filesystems to be mounted at boot time.
|
---|
33 | echo "Mounting network volumes..."
|
---|
34 | mount -a -O _netdev
|
---|
35 | evaluate_retval
|
---|
36 | ;;
|
---|
37 |
|
---|
38 | stop)
|
---|
39 | echo -n "Unmounting network volumes..."
|
---|
40 |
|
---|
41 | # The following line obtains a list from the output of
|
---|
42 | # mount for all netfs types and anything that was
|
---|
43 | # mounted with the _netdev option.
|
---|
44 | NETMOUNTS=`mount | grep '_netdev\|smbfs\|ncpfs|\coda\|nfs' \
|
---|
45 | | cut -d " " -f 3 | sed 's/$/ /g'`
|
---|
46 |
|
---|
47 | # Check to see if anything was listed from above
|
---|
48 | # (see if anything is actually needs to be unmounted)
|
---|
49 | if [ x$NETMOUNTS != x ]
|
---|
50 | then
|
---|
51 | # There is something mounted
|
---|
52 | # terminate the echo -n above
|
---|
53 | echo " "
|
---|
54 |
|
---|
55 | # Try and stop processes the nice way
|
---|
56 | # (probably won't work in most cases)
|
---|
57 | fuser -m -SIGTERM $NETMOUNTS > /dev/null
|
---|
58 |
|
---|
59 | # Check and see if it found anything. If it
|
---|
60 | # did, then give 3 seconds for things to exit
|
---|
61 | # the nice way before killing them off.
|
---|
62 | # This one will work all of the time!
|
---|
63 | if [ $? == 0 ]
|
---|
64 | then
|
---|
65 | sleep 3
|
---|
66 | fuser -km $NETMOUNTS > /dev/null
|
---|
67 | fi
|
---|
68 |
|
---|
69 | # unmount our list
|
---|
70 | umount $NETMOUNTS
|
---|
71 | evaluate_retval
|
---|
72 | else
|
---|
73 | # There is nothing mounted
|
---|
74 | echo "No network volumes mounted!"
|
---|
75 | # print a nice '[ OK ]' message
|
---|
76 | evaluate_retval
|
---|
77 | fi
|
---|
78 | ;;
|
---|
79 |
|
---|
80 | *)
|
---|
81 | echo "Usage: $0 {start|stop}"
|
---|
82 | exit 1
|
---|
83 | ;;
|
---|
84 | esac
|
---|
85 |
|
---|
86 | # End $rc_base/init.d/netfs
|
---|
87 | EOF
|
---|
88 | <command>chmod 0755 /etc/rc.d/init.d/netfs</command></screen>
|
---|
89 |
|
---|
90 | <para>While the excessive comments in the script might make people cringe, the
|
---|
91 | important part to note is that network filesystems that should be mounted at
|
---|
92 | boot time, must have the <emphasis role="strong">_netdev</emphasis>
|
---|
93 | option passed to them in <filename>/etc/fstab</filename>.</para>
|
---|
94 |
|
---|
95 | <para>Now put the necessary symlinks in place.</para>
|
---|
96 |
|
---|
97 | <screen><command>ln -sf ../init.d/netfs /etc/rc.d/rc0.d/K47netfs &&
|
---|
98 | ln -sf ../init.d/netfs /etc/rc.d/rc1.d/K47netfs &&
|
---|
99 | ln -sf ../init.d/netfs /etc/rc.d/rc2.d/K47netfs &&
|
---|
100 | ln -sf ../init.d/netfs /etc/rc.d/rc3.d/S28netfs &&
|
---|
101 | ln -sf ../init.d/netfs /etc/rc.d/rc4.d/S28netfs &&
|
---|
102 | ln -sf ../init.d/netfs /etc/rc.d/rc5.d/S28netfs &&
|
---|
103 | ln -sf ../init.d/netfs /etc/rc.d/rc6.d/K47netfs</command></screen>
|
---|
104 |
|
---|
105 | </sect1>
|
---|