1 TITLE: Running an NFS Server on LFS
3 AUTHOR: Ian Chilton <ian@ichilton.co.uk>
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.
9 KERNEL VERSION: 2.2.18+ or 2.4.0+
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
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
29 tar xzvf tcp_wrappers_7.6.tar.gz
31 zcat ../tcp_wrappers_7.6.diff.gz | patch -p1
32 make REAL_DAEMON_DIR=/usr/sbin linux
34 cp tcpd.h /usr/include
35 cp safe_finger /usr/sbin
38 cp tcpdmatch /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
50 zcat ../portmap_5-1.diff.gz | patch -p1
58 http://download.sourceforge.net/nfs/nfs-utils-0.2.1.tar.gz
60 tar zxvf nfs-utils-0.2.1.tar.gz
62 ./configure --prefix=/usr
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
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:
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:
114 # Begin /etc/init.d/nfs
116 source /etc/init.d/functions
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
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
139 /usr/sbin/exportfs -ra
149 echo "Usage: $0 {start|stop|reload|restart}"
155 # End /etc/init.d/nfs
159 On the workstations, you just need this:
162 # Begin /etc/init.d/nfsclient
164 source /etc/init.d/functions
168 echo -n "Starting RPC Portmapper"
169 loadproc /sbin/portmap
170 echo -n "Starting statd for NFS"
171 loadproc /usr/sbin/rpc.statd
175 echo -n "Stopping Portmapper"
176 killproc /sbin/portmap
187 echo "Usage: $0 {start|stop}"
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
202 See the new version of the NFS-HOWTO
203 (http://nfs.sourceforge.net/nfs-howto) for more information.