What are the differences between hard mount and soft mount
- NAS Protocol
What are the 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
“/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.
A Hard mount is generally used for block resources like a local disk or SAN. When a NFS filesystem mount is a Hard mount, 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. We can use the mount option “intr” which allows NFS requests to be interrupted if the server goes down or cannot be reached. Hence the recommended settings are hard and intr options.
- 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.
- There could be a performance impact with the constant connection.
Command to hard mount the directory /home from the remote machine host.server.com on the mount-point /mymountpoint. rw – for resource mounted to be read-write and intr – for keyboard interrupt enabled.
mount -o rw,hard,intr host.server.com/home /mymountpoint
A Soft mount is usually used for network file protocols like 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.
- 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.
- The disadvantage is that if your NFS driver caches data and the soft mount times out, your application may not know which writes to the NFS volumes were actually committed to disk.
- Data corruption or loss of data.
Command to soft mount 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