1 OPS535 Advanced TCP/IP Network Administration NFS Servers and Clients Raymond Chan Seneca College of Applied Technology 2005
2 What is NFS? NFS stands for Network File System NFS is one way for sharing disks over a network NFS is an Client/Server Application NFS enables filesystems physically residing on one computer system to be used by other computers in the network, appearing to users on the remote host as just another local disk.
3 NFS Servers Server and Client are used to describe the roles a process plays when interacts with other process. If a file system resides on a computer's disk and that a process running on the same computer makes the file system available to other processes (either running on the same computer or on a different computer), that process acts as a server. The processes that are accessing that file system
4 NFS Clients NFS Clients access files on the server by mounting the server's share file systems do not make a copy of the file system use a series of remote procedure calls (RPC) to access the file system transparently on the server's disk
5 Can be shared: Whole directory tree Partial directory tree NFS File Systems A file hierarchy including a single file Can not be shared: A file hierarchy that overlaps one that is already shared
6 NFS Environment NFS has been implemented on: Different hardware architectures Intel x86 Sun's SPARC Different operating systems MS-DOS VMS
7 NFS Benefits Centralize file storage Reduces store costs Provides data consistency Transparent remote access Supports heterogeneous operating environments Reduces system administration overhead
8 NFS Versions Version 2 The first widely used version Available on a large variety of platform All Solaris prior to 2.5 support only version 2 Version 3 Allows the server to cache client write request in memory Checks file access permission before file opened Removes the 8-Kbytes transfer size limit
9 NFS Administration Sharing and unsharing File Systems Modifying administrative files to update the lists of file systems your computer shares or mounts Setting up NFS Services Checking the status of the NFS Services Diagnosing and fixing NFS related problems
10 NFS administrative files Linux: /etc/exports Sun:/etc/dfs/dfstab Used by the system to tell NFS server which file systems on the local system are to be shared to the various computers on the network and under what conditions and restrictions. Linux: /etc/fstab Sun: /etc/vfstab Used by the system to tell NFS client which shared file system by a NFS server should be attached to which directory of the the local file system.
11 Share the file system Changes made to /etc/exports(l),etc/dfs/dfstab(s) will take effect after Rebooting the system, or Executing the exportfs -a (Linux) or shareall (Sun) command, or Restarting the NFS daemons
12 Server Componets nfsd handles file access requests from client process nfslogd provides operational logging (Sun only) mountd handles mount requests from client systems lockd manages file locking statd provides crash and recovery functions for the lock manager Portmapper(Linux), rpcbind(sun) facilitates initial connection between client and server
13 Client Components Normally implemented as file system driver (usually part of the kernel) mount command /etc/fstab(linux), /etc/vfstab(sun) allow remote filesystems to be automatically mounted at boot time.
14 Mounting File Systems Changes made to /etc/fstab(l), /etc/vfstab(s) will take effect after the system is rebooted, or an appropriate mount command is executed, or Activated by the automounter
15 Syntax for mounting NFS mount -t nfs [ -o options ] nfs_server:/r_dir /l_dir -t nfs : file system type -o options : ro rw, suid nosuid, bg, retry=n, timeo=n, retrans=n, soft hard, intr, rsize=n, wsize=n nfs_server : nfs server's host name/ip address r_dir : exported directory on nfs server l_dir : local directory on nfs client
16 NFS mount options ro, rw : mount for read only or read and write retran=n : retransmit a request n times before giving up hard : continue trying to connect even after the retrans value is met soft : quit after retrans value is met
17 Mount options (2) intr : allow an interrupt to kill a hung process rsize=n : the size of read buffer in bytes wsize=n : the size of the write buffer in bytes suid, nosuid : respect/not respect suid modes on the remote filesystem, if nosuid is used, SUID files on the remote filesystem will not run as root locally.
18 Sharing Local Filesystem(Sun) At boot time Add entries to /etc/dfs/dfstab with the following syntax: share [-F fstype] [-o options] e.g. [-d <text> > <pathname> Share -F nfs -o rw=pod1w1, access=pod1w2:pod1w3,anon=-1 /somefs
19 Sharing Filesystem (2) (Sun) At the command prompt Use the same share command syntax as in / etc/dfs/dfstab files share -F nfs -o rw=pod1w1, access=pod1w2:pod1w3,anon=-1 /somefs Allow pod1w1 to mount it for reading and writing and pod1w2 and pod1w3 to mount it read-only. Requests from users without matching accounts on the local system are denied.
Sharing Local Filesystem(Linux) At boot time Add entries to /etc/exports with the following syntax: share_path_name host(s)( options) e.g. /public 172.16.2.1(rw,root_squash) /share (ro) 20
21 Sharing Filesystem (2) (Linux) At the command prompt Use the exportfs command syntax exportfs [-avi] [-o options,..] client:path e.g. exportfs -o rw,root_squash 192.168.1.2:/public Allow 192.168.1.2 to mount it for reading and writing. Access by other hosts will be denied. e.g. exportfs -o ro :/share Allow any hosts to have read access the /share directory
22 Export Options (Linux) Read Write Options: ro rw User ID, group ID mapping options: root_squash, no_root_squash all_squash, no_root_squash anonuid, anongid Anonymous user: uid=65534, gid=65534
23 Mounting /somefs to /mnt (Sun) mount -F nfs pod1w0:/somefs /mnt mount -F nfs -o ro pod1w0:/somefs /mnt mount -F nfs -o wsize=16384 pod1w0:/somefs / mnt For more examples, see man mount_nfs
Mounting /somefs to /mnt (Linux) 24 mount -t nfs 192.168.1.1:/somefs /mnt mount -t nfs -o ro 192.168.1.1:/somefs /mnt mount -t nfs -o wsize=16384 192.168.1.1:/somefs /mnt For more examples, see man mount