systemd:nfs bg 安装在启动时失败

systemd:nfs bg 安装在启动时失败

我在 fstab nfs 挂载条目中使用“bg”选项,因为 nfs 共享在计算机启动时并不总是可用:

sal.fritz.box:/tank1_data /mnt/sal_data nfs fsc,nfsvers=4.2,nofail,bg    0  0

这将转换为以下 systemd“挂载”单元:

# /run/systemd/generator/mnt-sal_data.mount
# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)

[Mount]
Where=/mnt/sal_data
What=sal.fritz.box:/tank1_data
Type=nfs
TimeoutSec=infinity
Options=x-systemd.mount-timeout=infinity,retry=10000,fsc,nfsvers=4.2,nofail,bg,fg

我现在所期望的是,启动时“挂载”进程会等待,直到 nfs 共享变得可用。但是,设备启动后立即显示失败:

● mnt-sal_data.mount - /mnt/sal_data
   Loaded: loaded (/etc/fstab; generated; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2020-10-29 23:18:27 CET; 3min 8s ago
    Where: /mnt/sal_data
     What: sal.fritz.box:/tank1_data
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)
    Tasks: 0
   CGroup: /system.slice/mnt-sal_data.mount

Okt 29 23:18:27 hal2000 systemd[1]: Mounting /mnt/sal_data...
Okt 29 23:18:27 hal2000 systemd[1]: mnt-sal_data.mount: Mount process exited, code=exited status=32
Okt 29 23:18:27 hal2000 systemd[1]: Failed to mount /mnt/sal_data.
Okt 29 23:18:27 hal2000 systemd[1]: mnt-sal_data.mount: Unit entered failed state.

显然,在这种情况下,nfs 共享永远不会挂载。
但是,如果我手动重新启动挂载单元,一切都会按预期工作:挂载过程等待 nfs 共享的可用性...

● mnt-sal_data.mount - /mnt/sal_data
   Loaded: loaded (/etc/fstab; generated; vendor preset: disabled)
   Active: activating (mounting) since Thu 2020-10-29 23:56:19 CET; 9s ago
[...]
  Process: 10713 ExecUnmount=/usr/bin/umount /mnt/sal_data -c (code=exited, status=0/SUCCESS)
Cntrl PID: 10833 (mount)
    Tasks: 2
   CGroup: /system.slice/mnt-sal_data.mount
           ├─10833 /usr/bin/mount sal.fritz.box:/tank1_data /mnt/sal_data -t nfs -o x-systemd.mount-timeout=infinity,retry=10000,fsc,nf>
           └─10834 /sbin/mount.nfs sal.fritz.box:/tank1_data /mnt/sal_data -o rw,retry=10000,fsc,nfsvers=4.2,bg,fg

Okt 29 23:56:19 hal2000 systemd[1]: Mounting /mnt/sal_data...

...共享一旦可用,就会成功安装:

● mnt-sal_data.mount - /mnt/sal_data
   Loaded: loaded (/etc/fstab; generated; vendor preset: disabled)
   Active: active (mounted) since Thu 2020-10-29 23:59:44 CET; 5s ago
[...]
  Process: 10713 ExecUnmount=/usr/bin/umount /mnt/sal_data -c (code=exited, status=0/SUCCESS)
  Process: 10833 ExecMount=/usr/bin/mount sal.fritz.box:/tank1_data /mnt/sal_data -t nfs -o x-systemd.mount-timeout=infinity,retry=1000>
    Tasks: 0
   CGroup: /system.slice/mnt-sal_data.mount

Okt 29 23:56:19 hal2000 systemd[1]: Mounting /mnt/sal_data...
Okt 29 23:59:44 hal2000 systemd[1]: Mounted /mnt/sal_data.

我还更改了“nofail”选项:没有区别。我希望不需要手动重新启动。我想念什么?
我不想使用“自动挂载”功能,因为如果意外访问挂载点,这会导致系统临时挂起。

系统:openSUSE Leap 15.1,systemd 234

问候,斯文

相关内容