15. NFS

Network File Services (NFS) will allow a user to use any computer on a network to hold files from another computer (a shared file service)

    /       (root)
     \
  /export     Consider these as mount points
       \
/export/home

With NFS, you can have a user on one computer, and have their /export/home be on a server, and all this would be invisible to the user.

To do this do: mount [hostname you want to mount to]:[what you want to mount], e.g. mount myserver:/export/home export/home

Rules for mounting:

To tell if a mount point is busy use: fuser [dir name (mount point)]. So for example, you type: fuser /var/adm Your output would look like this:

/var/adm: 2946c 1211c

The numbers are the processes running on that directory. To see those two specifically, do ps –ef | egrep “2946|1211”.

To see what the process for mount

Server Client
/export/home /export/home
File system: UFS (or hsfs,pcfs,tmpfs) NFS
The above means it is on local hard drive The above means it is a networked file

The UFS or hsfs,pcfs,tmpfs is called a back file system because the server controls it.

For NFS the following must apply:

Server Client
0 daemons on 0 daemons on

Temporary

share [dir to share] (only good until reboot) mount [servername:what to mount] [where to mount]

Or to make the changes permanent do the following:

Permanent

edit /etc/dfs/dfstab edit /etc/vfstab

In /etc/dfs/dfstab (tab is for table except in vfstab) you need to have share -f (file type or file system) nfs and name of directory to be shared as an entry in this table

To undo a shared directory, use the command unshare on the server or umount on the client.

The following are different types of commands for mount and share:

Server Client
share mount
shareall mountall
ushare umount
ushareall umountall
share commands are for where you want to mount from mount commands are for where you want to mount

The last three will do all of it when you edit vfstab or dfstab. So every entry in vfstab(mount) or dfstab (share) that isn’t /etc/vfstab shows mount info.
Note: When dealing with vfstab or dfstab line up an organize the file, so you don’t make mistakes.

So using the above example, mount server:/export/home /mnt/home will share the home directories (because /export/home is on a different slice) you only share 1 partition per share and mount. When you share something you share the whole partition and everything below, so you can share / (root) and mount /export or /etc without having to re-share it.

df -k or mount shows mount points, and in the mount printout you will see what is shared and where.

Server daemons for NFS are very big processes. /etc/init.d/mfs.server start or stop will begin or end NFS service.

The subroutine in nfs.server contains the following subroutine:

if grep “-f nfs” /etc/dfs/dfstab
then start daemons
fi

note: You must have an entry in this dfstab that says –f nfs

Client daemons will start (statd and lockd).

Server daemons will start, the ones to look for are mountd and nfsd which will check for shares and mounts (dfshares and dfmounts which can be clients)

ps -ef | grep nfs – will show running nfs daemons.

note: make sure you start and put entry in dfstab

(shortcut – to share a home directory, telnet to the server your sharing with and add the users name to that server and put in same uid and check “do not create home dir”)

dfshares [servername] will show shares

uname -n – shows what server you are on

which [command name] - shows the path


  Go to Chapter 14       Go to Index        Go to Chapter 16