What are the differences between hard mount and soft mount
Applies to
- NFS
- NAS Protocol
Answer
Differences between hard mount and soft mount
Using NFS protocol, the NFS client can mount the filesystem existing on a NFS server, just like a local filesystem.
For example, you will be able to mount /home directory of host.server.com to your client machine as follows:
# mount host.server.com:/home /mymountpoint
The directory “/mymountpoint” should be created in your machine to hold the NFS partition.
Hard mount or Soft mount options define how the NFS client should handle NFS server crash/failure.
Hard Mount
- A
hardmount is generally used for block resources, such as a local disk or SAN. - When a NFS filesystem mount is a
hardmount, an NFS request affecting any part of the mounted resource is issued repeatedly until the request is satisfied (for example, the server crashes and comes back up later). - Once the server is back online, the program will continue to execute undisturbed from the state where it was during server crash.
- The mount option
intrwhich allow NFS requests to be interrupted if the server goes down or cannot be reached. - Hence, the recommended settings are
hardandintroptions.
Advantages:
- In case of connection loss all NFS clients freeze until NFS server comes back online. Hence, no loss of data.
- Data integrity and messaging is assured.
Disadvantage:
- There could be a performance impact with the constant connection.
The below example command hard mounts the directory /home from the remote machine host.server.com on the mount-point /mymountpoint
rw– resource mounted to be read-writeintr– keyboard interrupt enabled
mount -o rw,hard,intr host.server.com/home /mymountpoint
Soft Mount
A Soft mount is usually used for network file protocols, such as NFS or CIFS. When a NFS filesystem mount is a soft mount, a program or application requests a file from the NFS filesystem, NFS client daemons will try to retrieve the data from the NFS server. NFS tries repeatedly to contact the server until either:
- A connection is established
- The NFS retry threshold is met
- The nfstimeout value is reached
Control returns to the calling program if one of these events occur.
But, if it doesn’t get any response from the NFS server (due to any crash, time out or failure of NFS server), the NFS client will report an error to the process on the client machine requesting the file access, then quits.
|
WARNING Unless an application vendor explicitly advises to use soft mount, possible data corruption discourages from using this mount style. |
Advantages:
- The advantage of this mechanism is “fast responsiveness” as it doesn’t wait for the NFS server to respond.
- If the NFS server is unavailable, the kernel will time out the I/O operation after a pre-configured period of time.
Disadvantages:
- The disadvantage is that if your NFS driver caches data and the soft mount times out, the application may not know which writes to the NFS volumes were actually committed to disk.
- Data corruption or loss of data.
The below example command soft mounts from remote machine host.server.com on the mount-point /mymountpoint
mount -o rw,soft host.server.com/home /mymountpoint
To check what kind of a mount is present on the system currently:
[usero1@Linux01 ~]$ nfsstat -m
/home from vrouter:/home
Flags: rw,relatime,vers=4.1,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr= 10.0.0.1,local_lock=none,addr=10.0.0.2
/mnt/test from svm-data-lif1:/vol_unix
Flags: rw,relatime,vers=4.0,rsize=65536,wsize=65536,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr= 10.0.0.1,local_lock=none,addr=10.0.0.2
