NFS
Automount:
Master map file
# cat /etc/auto_master # local mount point map name mount options # All machines listed in /etc/hosts are automatically mounted (a subdirectory) under /net /net -hosts -nosuid # directories listed in /etc/auto_home is mounted under /home (Indirect Map) /home auto_home # Direct map file /- auto_direct # comment out if you use NIS+ and centrally maintained files #+auto_master
Indirect Map file
An Indirect map configuration file lists the pathnames and relative mount points, /home in this case
# cat /etc/auto_home #key Mount_Options Location user_1 mach_1:/export/home/user_1 user_2 mach_2:/export/home/user_2 user_3 mach_3:/export/home/user_3
The above can be replace by a single line like bellow
* mach_3:/export/home/&
In the above example, instead of mounting user home directories on /home/user_1 to mount on /home/users/user_1, add the following line in the auto_home file
#key Mount_Options Location user_1 /users mach1:/export/home/user_1
Direct Map files
# cat auto_direct /home/research -rw filbert:/home/research
NFS mount options
rw ro --> read write / read only bg|fg --> Try in the background / foreground if the mount attempt fails retry=n --> number of times to retry the mount operation port=<number> -- Set server UDP/TCP port number to <number>. Default is 2049 proto=<udp|tcp> soft|hard --> Return an error if the server does not respond / or continue till the server responds intr|noinrt --> Allow keyboard interrupts to kill a process on a hung hard mounted file system
exportfs options
ro --> read only access rw=host1:host2: --> read write access to host1 and host2 anon=uid --> use "uid" as the effective user if the request comes from unknown UID root=host1:host2 --> Give root access to the root users from host1 and host2
TIP:
Problem: Can not change the ownership of files in NFS mounted directory
Solution: This problem occurs usually with NFS ver 4.0. NFS V.4 needs the the user name to be present both on the server and client. Otherwise, it will not let you chage the owner ship of files. We can overcome this problem by mounting the file systems as nfs v.3.
In Solaris:
# mount - nfs -o rw,vers=3 server:<directory> /<mount_point>
In Linux
# mount -o rw,nfsvers=3 server:<directory> /<mount_point>