Automating the Mount Process
UNIX uses a special file known as /etc/fstab. This file lists all the partitions which required to be mounted at boot time and the directory where they required to be mounted. With that information parameters can be passed to the mount command.
Format of /etc/fstab:
/dev/device /dir/tomount ftype parameters fs_freq fs_passno
where:
/dev/device- Is the device should be mounted, for example /dev/hda4.
/dir/to/mount - Specifies the location at that the file system should be mounted on the directory tree.
Ftype - Specifies the file system category for mounting.
Parameters - Specifies the parameters which are passed to mount using the -o option. They follow the similar comma-delineated format. An instance entry would look such as rw,intr,bg.
Fs_freq -Used through dump to determine whether a file system needs to be dumped.
Fs_passno -Used through the fsck program to conclude the order of checking the disks at boot time.
The system administrator could tell the Operating System about any filesystem the machine might have access to in the /etc/fstab. It also permits default parameters to be gives for each filesystem.
local mount
/dev/device /dir/to/mount ftype parameters fs_freq fs_passno
/dev/hda1/ /home ext2 rw 0 0
Remote mount
/dev/device /dir/to/mount ftype parameters fs_freq fs_passno
lambent:/home/Krishen /mnt nfs rw 0 0
The Structure of /etc/fstab
The first field (lambent:/home/krishen) is the remote filesystem which is to be described. The second field (/mnt) specifies the mount point where the filesystem will be mounted. The third field (nfs) is the type of filesystem on the device from the first field.
The fourth field (rw) is a options which mount should use when mounting the filesystem.
The fifth field (0) is used by dump (a backup utility) to decide if a filesystem should be backed up. dump will ignore if zero that filesystem.
The sixth field (0) is used by fsck (the filesystem check utility) to determine the order in which filesystems should be checked.
Note: In Solaris/etc/vsftab is the file which lists all the partitions which required to be mounted at boot time and the directory where they required to be mounted.
#vi /etc/vfstab
<device to mount> <device to fsck> < mount point> <fs type> <fsck pass>
<mount at boot> <mount options>
# remote mount
lambent:/home/Krishen - /mnt nfs - yes -
The fields are explaining below:
Device to mount- This is the name of the server sharing the resource the client which are required to mount, if is the resource is an Nfs resource followed via a colon, then thename of the resource to be mounted. (lambent:/home/Krishen). A Lambent is the nameof the server and /home/Krishen is the name of the remote directory.
Device to fsck - Indicates the name of the raw device to fsck; for a remote mount, the parameter is not applicable and the entry should be - .
mountpoint- that is the mount point on that the resource is to be mounted.(/mnt).
fstype - Indicates the file system type of the resource which is to mount.(nfs)
fsckpass- This is the pass number to use for several fsck's. For a remote mount, the parameter is not applicable and the entry should be -
mntopts- Indicates the options passed to the mount command;.
There are options which can be passed to the mountoption field(7th coloum). The most important features are specified:
rw - read/write.
ro - read only.
bg - background mount (place the process into the background and keep trying until success if the mount fails.)
fg - foreground mount (place the process into the background and keep trying until success if the mount fails.)
soft - The soft option provides an error if the server doesn't respond. Don't use soft option on Writable file system.
hard - Continue retrying a request until the server responds. Use hard option on all file systems mounted with read-write permission.
End Note:
showmount queries the mount daemon on a remote host for data about the state of the NFS server on which machine. Inside no options showmount lists the set of clients who are mounting from that host.