如果失败,请重试挂载 NFS 共享

如果失败,请重试挂载 NFS 共享

我有一个从 /etc/fstab 挂载的 NFS 共享,因此它在启动时挂载。但如果 NFS 共享在启动时不可用,我该如何让它重试直到可以挂载它?

答案1

背景/etc/fstab 中的 mount 选项应该按照您的要求执行:

来自 man nfs:

   bg / fg        Determines how the mount(8) command behaves if an attempt to mount an export fails.  The fg option causes mount(8) to exit with an error status if  any  part
                  of  the mount request times out or fails outright.  This is called a "foreground" mount, and is the default behavior if neither the fg nor bg mount option is
                  specified.

                  If the bg option is specified, a timeout or failure causes the mount(8) command to fork a child which continues to attempt to mount the export.   The  parent
                  immediately returns with a zero exit code.  This is known as a "background" mount.

                  If  the  local  mount  point  directory is missing, the mount(8) command acts as if the mount request timed out.  This permits nested NFS mounts specified in
                  /etc/fstab to proceed in any order during system initialization, even if some NFS servers are not yet available.  Alternatively these issues can be addressed
                  using an automounter (refer to automount(8) for details).

相关内容