How to export and mount an NFS filesystem on AIX

 

In this example /opt on the NFS server is already exported to the NFS client node1 and we need to also export /opt to NFS client node2.

Information about currently exported filesystems can be viewed by typing.

exportfs

Make a copy of the file /etc/exports before using this procedure in case you make a mistake and need to go back to the old export list.

On the NFS server we need to export the directory that the client will NFS mount as follows.

/usr/sbin/mknfsexp -d '/opt' -B -S 'sys,krb5p,krb5i,krb5,dh' -t 'rw' -c 'node1,node2' -r 'node1,node2'

0513-059 The nfsd Subsystem has been started. Subsystem PID is 8284.
0513-059 The rpc.mountd Subsystem has been started. Subsystem PID is 23782.
0513-059 The rpc.statd Subsystem has been started. Subsystem PID is 5192.
0513-059 The rpc.lockd Subsystem has been started. Subsystem PID is 20804.
Exported /opt

If the NFS daemons are not running then they are started as shown above.

The -d option specifies the directory to export in this case /opt.
The -B option adds an entry to the /etc/exports file and the exportfs command is executed to export the directory, this flag is the default.
The -S option sets the security options i.e. sys=UNIX authentication, dh=DES athentication, krb5*=Kerberos athentication.
The -t 'rw' option specifies that the directory is read-write.
The -c option restricts access to only the NFS clients node1 and node2.
The -r option gives root users on NFS clients node1 and node2 access to the directory.

Warning - If you are exporting a directory to a host (node2) that is already exported to another host (node1) then the export information for node1 will be overwritten unless you include node1 as an argument to mknfsexp as shown above. In this example /opt was already exported to node1 but we needed to include node1 otherwise node1 would have been overwritten and removed.

On the NFS client create the directory that the remotely exported directory is to be mounted on as follows.

mkdir /mnt/opt

This directory can be any directory required and /mnt/opt is just an example.

To mount the remotely exported directory onto /mnt/opt do the following.

mount node2:/opt /mnt/opt