-->
Previous Table of Contents Next


Hard Mounts Versus Soft Mounts

Hard mounts and soft mounts determine how an NFS client behaves when an NFS server stops responding. NFS file systems are hard-mounted by default. With either type of mount, if a server stops responding, the client waits until the timeout value specified by the timeo option expires and then resends the request (this is known as a minor timeout). If the requests to the server continue to time out and the total timeout reaches 60 seconds, a major timeout occurs.

If a file system is hard mounted, the client prints a message to the console and starts the mount requests all over again by using a timeout value that’s twice that of the previous cycle. This has the potential to go on forever. The client keeps trying to remount the NFS file system from the server until it gets it.

Soft mounts, on the other hand, just generate an I/O error to the calling process when a major timeout occurs. Linux then continues on its merry way.

Typically, important software packages and utilities that are mounted via NFS should be mounted with hard mounts. This is why hard mounts are the default. You don’t want your system to start acting strange if the Ethernet gets unplugged for a moment; you want Linux to wait and continue when the network is back up. On the other hand, you might want to mount non-critical data, such as remote news spool partitions, as soft mounts so that if the remote host goes down, it won’t hang your current login session.

A typical NFS file system entry in the /etc/fstab file might look like this:


mailserver:/var/spool/mail  /var/spool/mail   nfs timeo=20,intr

This entry mounts the /var/spool/mail file system located on the host mailserver at the local mount point /var/spool/mail. It specifies that the file system type is nfs. Also, it sets the timeout value to 2 seconds (20 tenths of a second) and makes operations on this file system interruptible.

Mounting NFS File Systems Interactively

NFS file systems can be mounted interactively, just like any other type of file system. However, you should be aware that the NFS mount command isn’t very pretty due to all the options that you can specify on the command line.

By using the previous example, the interactive mount command that you use to mount the /var/spool/mail file system becomes


# mount -t nfs -o timeo=20,intr mailserver:/var/spool/mail /var/spool/mail

If you need to specify datagram sizes and timeouts, interactive mount commands can become very complex. It’s highly recommended that you place these mount commands in your /etc/fstab file so that they can be mounted automatically at boot time.

Maintaining File Systems

As the systems administrator, you’re responsible for maintaining the integrity of the file systems themselves. Typically, this means checking the file systems periodically for damaged or corrupted files. Linux automatically checks file systems at boot time if they have a value greater than 0 specified in the pass number field of the /etc/fstab file.


NOTE:  The ext2 file system commonly used under Linux has a special flag known as a clean.bit If the file system has been synchronized and unmounted cleanly, the clean bit is set on the file system. If the clean bit is set on a file system when Linux boots, it’s not checked for integrity.

Using the fsck Command

It’s a good idea to check your file systems occasionally for damaged or corrupt files. Under the Slackware distribution of Linux, you use the fsck (file system check) command to check your file systems. The fsck command is really a “front end” for a series of commands that are designed to check specific file systems. The syntax for the fsck command is as follows:


fsck [-A] [-V] [-t fs-type] [-a] [-l] [-r] [-s] filesys

However, the most basic form of the command is this:


fsck filesys

Table 14.7 describes the command-line options for the fsck command.

Table 14.7 Command-Line Arguments for fsck

Argument Description

-A Goes through the /etc/fstab file and tries to check all file systems in one pass. This option is typically used during the Linux boot sequence to check all normally mounted file systems. If you use -A, you can’t use the filesys argument as well.
-V Verbose mode. Prints additional information about what fsck is doing.
-t fs-type Specifies the type of file system to be checked.
filesys Specifies which file system is to be checked. This argument can be a block special device name, such as /dev/hda1, or a mount point, such as /usr.
-a Automatically repairs any problems found in the file system without asking any questions. Use this option with caution.
-l Lists all the filenames in the file system.
-r Asks for confirmations before repairing the file system.
-s Lists the superblock before checking the file system.

The fsck command is actually a front-end program that calls the command to check the file system that matches the type you specify. To do so, Linux needs to know the file system type that it’s checking. The easiest way to make sure that fsck calls the right command is to specify a file system type with the -t option to fsck. If you don’t use the -t option, Linux tries to figure out the file system type by looking up the file system in /etc/fstab and by using the file type specified there. If fsck can’t find the file type information in /etc/fstab, it assumes that you’re using a Minix file system.


CAUTION:  
The fsck command assumes that the file system you’re checking is a Minix file system if you don’t tell it differently—either with the -t argument or by listing the type in /etc/fstab. Because your Linux file systems are probably of type ext2 and not Minix, you should be careful and make sure that fsck knows the correct type. This is especially important if you’re checking a file system that isn’t listed in the /etc/fstab file.


Previous Table of Contents Next