大网数据广告活动
服务器运维问答

How to make NFS server start if a disk mountpoint export fails to mount?

· 52CE 我爱测

Consider the following /etc/exports : /verbatim 192.168.0.0/255.255.255.0(rw,sync,no_subtree_check) /sandisk 192.168.0.0/255.255.255.0(rw,sync,no_subtree_check) /verbatim and /sandisk are mountpoints of external hard drives defin…

问题原文

原帖链接 · bagratte · CC BY-SA 4.0

Consider the following /etc/exports:

/verbatim 192.168.0.0/255.255.255.0(rw,sync,no_subtree_check)
/sandisk 192.168.0.0/255.255.255.0(rw,sync,no_subtree_check)

/verbatim and /sandisk are mountpoints of external hard drives defined in /etc/fstab as follows:

/dev/disk/by-uuid/06b24834-a749-4d93-b0d5-a6da71eaf224 /verbatim ext4 defaults 0 1
/dev/disk/by-uuid/d7dbea69-0332-4d12-b905-b9a116e28422 /sandisk ext4 defaults 0 1

Now, if any of these hard drives fails to mount - for example when it's powered off or uplugged - NFS server fails to start. These are what I believe the relevant entries in journal:

Sep 23 09:45:26 lilo systemd[1]: dev-disk-by\x2duuid-06b24834\x2da749\x2d4d93\x2db0d5\x2da6da71eaf224.device: Job dev-disk-by\x2duuid-06b24834\x2da749\x2d4d93\x2db0d5\x2da6da71eaf224.device/start timed out.
Sep 23 09:45:26 lilo systemd[1]: Timed out waiting for device SAMSUNG_HD204UI 1.
Sep 23 09:45:26 lilo systemd[1]: Dependency failed for File System Check on /dev/disk/by-uuid/06b24834-a749-4d93-b0d5-a6da71eaf224.
Sep 23 09:45:26 lilo systemd[1]: Dependency failed for /verbatim.
Sep 23 09:45:26 lilo systemd[1]: Dependency failed for NFS server and services.
Sep 23 09:45:26 lilo systemd[1]: nfs-server.service: Job nfs-server.service/start failed with result 'dependency'.
Sep 23 09:45:26 lilo systemd[1]: verbatim.mount: Job verbatim.mount/start failed with result 'dependency'.
Sep 23 09:45:26 lilo systemd[1]: systemd-fsck@dev-disk-by\x2duuid-06b24834\x2da749\x2d4d93\x2db0d5\x2da6da71eaf224.service: Job systemd-fsck@dev-disk-by\x2duuid-06b24834\x2da749\x2d4d93\x2db0d5\x2da6da71eaf224.service/start failed with result 'dependency'.
Sep 23 09:45:26 lilo systemd[1]: dev-disk-by\x2duuid-06b24834\x2da749\x2d4d93\x2db0d5\x2da6da71eaf224.device: Job dev-disk-by\x2duuid-06b24834\x2da749\x2d4d93\x2db0d5\x2da6da71eaf224.device/start failed with result 'timeout'.

Is there any way I can configure NFS server to start and serve the other drives (sandisk) even if some drives can't be mounted (verbatim)?

已采纳解答

原帖链接 · bagratte · CC BY-SA 4.0

Use mountpoint or mp in /etc/exports :

mountpoint=path
mp
This option makes it possible to only export a directory if it has successfully been mounted. If no path is given (e.g. mountpoint or mp) then the export point must also be a mount point. If it isn't then the export point is not exported. This allows you to be sure that the directory underneath a mountpoint will never be exported by accident if, for example, the filesystem failed to mount due to a disc error.

If a path is given (e.g. mountpoint=/path or mp=/path) then the nominated path must be a mountpoint for the exportpoint to be exported.

/verbatim 192.168.0.0/255.255.255.0(rw,sync,no_subtree_check,mountpoint)
/sandisk 192.168.0.0/255.255.255.0(rw,sync,no_subtree_check,mountpoint)

Also, consider using auto,nofail in /etc/fstab so that operating system boots if external disks are unplugged or powered off:

/dev/disk/by-uuid/06b24834-a749-4d93-b0d5-a6da71eaf224 /verbatim ext4 auto,nofail 0 1
/dev/disk/by-uuid/d7dbea69-0332-4d12-b905-b9a116e28422 /sandisk ext4 auto,nofail 0 1

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-09-23)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。