如果 CIFS 共享依赖于 ip 路由,则无法在启动时挂载 CIFS 共享(从 /etc/fstab)

如果 CIFS 共享依赖于 ip 路由,则无法在启动时挂载 CIFS 共享(从 /etc/fstab)

上一个Debian Linux 10我在以下位置定义了 CIFS 共享/etc/fstab

//192.168.120.1/Share /mnt/Share cifs credentials=/etc/fstab-share.password,auto,nofail 0 0

系统启动时不会安装此共享,因为:

$ systemctl status mnt-Share.mount
● mnt-Share.mount - /mnt/Share
   Loaded: loaded (/etc/fstab; generated)
   Active: failed (Result: exit-code) since Mon 2021-10-04 18:48:21 CEST; 23s ago
    Where: /mnt/Share
     What: //192.168.130.130/UnifiRecorder
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)

Oct 04 18:48:21 home-docker systemd[1]: Mounting /mnt/Share...
Oct 04 18:48:21 home-docker mount[397]: mount error(101): Network is unreachable
Oct 04 18:48:21 home-docker mount[397]: Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
Oct 04 18:48:21 home-docker systemd[1]: mnt-Share.mount: Mount process exited, code=exited, status=32/n/a
Oct 04 18:48:21 home-docker systemd[1]: mnt-Share.mount: Failed with result 'exit-code'.
Oct 04 18:48:21 home-docker systemd[1]: Failed to mount /mnt/Share.

但是,如果我systemctl start mnt-Share.mount登录后运行,一切都很好:

$ systemctl status mnt-Share.mount
● mnt-Share.mount - /mnt/Share
   Loaded: loaded (/etc/fstab; generated)
   Active: active (mounted) since Mon 2021-10-04 18:48:59 CEST; 1s ago
    Where: /mnt/Share
     What: //192.168.130.130/UnifiRecorder
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)
    Tasks: 0 (limit: 4915)
   Memory: 372.0K
   CGroup: /system.slice/mnt-Share.mount

Oct 04 18:48:59 home-docker systemd[1]: Mounting /mnt/Share...
Oct 04 18:48:59 home-docker systemd[1]: Mounted /mnt/Share.

我确实设置了到达我的 NAS 的特定路线/etc/network/interfaces

# The primary network interface
allow-hotplug ens18
iface ens18 inet dhcp
    up ip route add 192.168.120.0/24 via 192.168.1.1

我怀疑静电ip路由设置得太晚了,对吗?我可以以/etc/fstab某种方式正确配置依赖项吗?

相关内容