Update lfs-uefi.txt
[linux_from_scratch_hints.git] / OLD / nfs.txt
blob7417a2fc3eaea31612609fd32fad2c8fbc856019
1 TITLE:          Running an NFS Server on LFS
2 LFS VERSION:    any
3 AUTHOR:         Ian Chilton <ian@ichilton.co.uk>
5 SYNOPSIS:
6         A while ago, I wrote an LFS-Hint on setting up an NFS server on an LFS system. There is now a much better way to do it, using the NFS code in the later kernels.
8 HINT:
9 KERNEL VERSION: 2.2.18+ or 2.4.0+
11 NOTE:
12 This is not a complete guide to using NFS...it is only ment as a quick
13 introduction to compiling the packages.
15 ** There are some important security issues when using NFS **
16 Please read: http://nfs.sourceforge.net/nfs-howto  for more info before
17 you start using NFS.
19 The author holds no responsibility for any loss or damage etc etc..
22 First, we need TCP Wrappers:
24 Download the following:
25 http://files.ichilton.co.uk/nfs/tcp_wrappers_7.6.diff.gz
26 http://files.ichilton.co.uk/nfs/tcp_wrappers_7.6.tar.gz
28 Then do:
29 tar xzvf tcp_wrappers_7.6.tar.gz
30 cd tcp_wrappers_7.6
31 zcat ../tcp_wrappers_7.6.diff.gz | patch -p1
32 make REAL_DAEMON_DIR=/usr/sbin linux
33 cp libwrap.a /usr/lib
34 cp tcpd.h /usr/include
35 cp safe_finger /usr/sbin
36 cp tcpd /usr/sbin
37 cp tcpdchk /usr/sbin
38 cp tcpdmatch /usr/sbin
39 cp try-from /usr/sbin
42 Next we need the Portmapper:
44 Download the following:
45 http://files.ichilton.co.uk/nfs/portmap_5-1.diff.gz
46 http://files.ichilton.co.uk/nfs/portmap_5.orig.tar.gz
48 tar xzvf portmap_5.orig.tar.gz
49 cd portmap_5beta
50 zcat ../portmap_5-1.diff.gz | patch -p1
51 make
52 make install
55 Now we do NFS Utils:
57 Download:
58 http://download.sourceforge.net/nfs/nfs-utils-0.2.1.tar.gz
60 tar zxvf nfs-utils-0.2.1.tar.gz
61 cd nfs-utils-0.2.1
62 ./configure --prefix=/usr
63 make
64 make install
67 That's all the software we need. You should do the above on all clients
68 and the server. You should also update to the latest util-linux package
69 on the clients. This is available from:
70 ftp://ftp.win.tue.nl/pub/linux/utils/util-linux/
73 Now, we need to recompile the kernel.
75 In the Filesystems -> Network Filesystems section on the kernel config,
76 you should have the following:
78 * NFS filesystem support
79    - NFS Version 3 filesystem support
81 * NFS server support
82    - NFS Version 3 server support
83    - NFS server TCP support
86 For the server, you should enable these:
88 * NFS filesystem support
89    - NFS Version 3 filesystem support
92 For the clients, you should enable these:
93 * NFS server support
94    - NFS Version 3 server support
97 Recompile and boot the new kernel.
100 Then, we need an /etc/exports file.
102 An example 'share' is:
104 /home/ian 192.168.0.1(rw)
107 The format is obvious:  /home/ian is the directory to share,
108 192.168.0.1 is the client to share to, and rw is read-write mode.
111 Then, on the server, start NFS...this is my startup script:
113 #!/bin/sh
114 # Begin /etc/init.d/nfs
116 source /etc/init.d/functions
118 case "$1" in
119         start)
120                 echo -n "Starting RPC Portmapper"
121                 loadproc /sbin/portmap
122                 echo -n "Starting NFS"
123                 loadproc /usr/sbin/rpc.mountd
124                 loadproc /usr/sbin/rpc.nfsd 8
125                 loadproc /usr/sbin/rpc.statd
126                 ;;
128         stop)
129                 echo -n "Stopping NFS"
130                 killproc /usr/sbin/rpc.nfsd
131                 killproc /usr/sbin/rpc.mountd
133                 echo -n "Stopping Portmapper"
134                 killproc /sbin/portmap
135                 ;;
137         reload)
138                 echo "Reloading NFS"
139                 /usr/sbin/exportfs -ra
140                 ;;
142         restart)
143                 $0 stop
144                 /usr/bin/sleep 1
145                 $0 start
146                 ;;
148         *)
149                 echo "Usage: $0 {start|stop|reload|restart}"
150                 exit 1
151         ;;
153 esac
155 # End /etc/init.d/nfs
159 On the workstations, you just need this:
161 #!/bin/sh
162 # Begin /etc/init.d/nfsclient
164 source /etc/init.d/functions
166 case "$1" in
167         start)
168                 echo -n "Starting RPC Portmapper"
169                 loadproc /sbin/portmap
170                 echo -n "Starting statd for NFS" 
171                 loadproc /usr/sbin/rpc.statd
172                 ;;
174         stop)
175                 echo -n "Stopping Portmapper"
176                 killproc /sbin/portmap
177                 ;;
180         restart)
181                 $0 stop
182                 /usr/bin/sleep 1
183                 $0 start
184                 ;;
186         *)
187                 echo "Usage: $0 {start|stop}"
188                 exit 1
189         ;;
191 esac
193 # End /etc/init.d/nfsclient
196 Now all that remains is to mount the remote directory on the client:
198 mount server:/home/ian /mntdir
199 (or, I use mount -o rsize=8192,wsize=8192,hard,intr server:/home/ian
200 /mntdir)
202 See the new version of the NFS-HOWTO
203 (http://nfs.sourceforge.net/nfs-howto) for more information.