在较新的 18.04 系统上,我向 fstab 添加了一些 SMB 挂载,并以交互方式验证它们确实挂载。
当我的系统启动时,它会抱怨 CIFS 挂载错误,然后告诉我我处于紧急模式并继续进行 cloud-init(我认为最终会获得 IP 地址)。如果我绕过紧急挂载,我会发现我的挂载没有问题,可能是在它获得 IP 之后)
我希望得到一些建议,因为我想让这台机器无人值守启动。
journalctl -b
我已附加看似相关的屏幕截图和各种摘录。
Sep 15 20:46:47 watcher kernel: FS-Cache: Netfs 'cifs' registered for caching
Sep 15 20:46:47 watcher kernel: Key type cifs.spnego registered
Sep 15 20:46:47 watcher kernel: Key type cifs.idmap registered
Sep 15 20:46:47 watcher kernel: No dialect specified on mount. Default has changed to a more secure dialect, SMB2.1 or later (e.g. SMB3), from CIFS (SMB1). To use the less secure SMB1 dialect to access old servers which do not support SMB3 (or SMB2.1) specify vers=1.0 on mount.
Sep 15 20:46:47 watcher mount[645]: mount error(101): Network is unreachable
Sep 15 20:46:47 watcher mount[645]: Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
Sep 15 20:46:47 watcher kernel: CIFS VFS: Error connecting to socket. Aborting operation.
Sep 15 20:46:47 watcher kernel: CIFS VFS: cifs_mount failed w/return code = -101
Sep 15 20:46:47 watcher systemd[1]: mnt-downloads.mount: Mount process exited, code=exited status=32
Sep 15 20:46:47 watcher systemd[1]: mnt-downloads.mount: Failed with result 'exit-code'.
Sep 15 20:46:47 watcher systemd[1]: Failed to mount /mnt/downloads.
Sep 15 20:46:47 watcher systemd[1]: Dependency failed for Local File Systems.
...
Sep 15 20:46:53 watcher cloud-init[491]: Cloud-init v. 18.3-9-g2e62cb8a-0ubuntu1~18.04.2 running 'init-local' at Sat, 15 Sep 2018 20:46:53 +0000. Up 21.61 seconds.
Sep 15 20:46:53 watcher systemd[1]: Started Initial cloud-init job (pre-networking).
Sep 15 20:46:53 watcher systemd[1]: Reached target Network (Pre).
Sep 15 20:46:53 watcher systemd[1]: Starting Raise network interfaces...
Sep 15 20:46:53 watcher systemd[1]: Starting Network Service...
Sep 15 20:46:53 watcher systemd-networkd[910]: Enumeration completed
Sep 15 20:46:53 watcher systemd[1]: Started Network Service.
Sep 15 20:46:53 watcher systemd-networkd[910]: lo: Link is not managed by us
Sep 15 20:46:53 watcher systemd-networkd[910]: eno1: IPv6 successfully enabled
Sep 15 20:46:53 watcher systemd[1]: Starting Network Name Resolution...
Sep 15 20:46:53 watcher systemd[1]: Starting Wait for Network to be Configured...
Sep 15 20:46:53 watcher kernel: IPv6: ADDRCONF(NETDEV_UP): eno1: link is not ready
...
Sep 15 20:46:53 watcher systemd[1]: Started Network Name Resolution.
Sep 15 20:46:53 watcher systemd[1]: Reached target Host and Network Name Lookups.
Sep 15 20:46:53 watcher systemd[1]: Started Raise network interfaces.
Sep 15 20:46:53 watcher systemd[1]: Reached target Network.
Sep 15 20:46:57 watcher systemd-networkd[910]: eno1: Gained carrier
Sep 15 20:46:57 watcher kernel: e1000e: eno1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx
Sep 15 20:46:57 watcher kernel: IPv6: ADDRCONF(NETDEV_CHANGE): eno1: link becomes ready
Sep 15 20:46:57 watcher systemd-networkd[910]: eno1: DHCPv4 address 192.168.7.229/24 via 192.168.7.1
Sep 15 20:46:57 watcher systemd-timesyncd[743]: Network configuration changed, trying to establish connection.
Sep 15 20:46:58 watcher systemd-networkd[910]: eno1: Gained IPv6LL
Sep 15 20:46:58 watcher systemd-networkd[910]: eno1: Configured
Sep 15 20:46:58 watcher systemd-timesyncd[743]: Network configuration changed, trying to establish connection.
Sep 15 20:46:58 watcher systemd-networkd-wait-online[942]: managing: eno1
Sep 15 20:46:58 watcher systemd-networkd-wait-online[942]: ignoring: lo
Sep 15 20:46:58 watcher systemd[1]: Started Wait for Network to be Configured.
Sep 15 20:46:58 watcher systemd[1]: Starting Initial cloud-init job (metadata service crawler)...
Sep 15 20:46:58 watcher cloud-init[1030]: Cloud-init v. 18.3-9-g2e62cb8a-0ubuntu1~18.04.2 running 'init' at Sat, 15 Sep 2018 20:46:58 +0000. Up 26.99 seconds.
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: +++++++++++++++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++++++++++++++
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: +--------+------+------------------------------+---------------+--------+-------------------+
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: | Device | Up | Address | Mask | Scope | Hw-Address |
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: +--------+------+------------------------------+---------------+--------+-------------------+
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: | eno1 | True | 192.168.7.229 | 255.255.255.0 | global | xx:xx:xx:xx:xx:c7 |
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: | eno1 | True | fe80::5265:f3ff:fe1c:6dc7/64 | . | link | xx:xx:xx:xx:xx:c7 |
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: | lo | True | 127.0.0.1 | 255.0.0.0 | host | . |
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: | lo | True | ::1/128 | . | host | . |
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: +--------+------+------------------------------+---------------+--------+-------------------+
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: ++++++++++++++++++++++++++++++Route IPv4 info++++++++++++++++++++++++++++++
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: +-------+-------------+-------------+-----------------+-----------+-------+
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: | Route | Destination | Gateway | Genmask | Interface | Flags |
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: +-------+-------------+-------------+-----------------+-----------+-------+
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: | 0 | 0.0.0.0 | 192.168.7.1 | 0.0.0.0 | eno1 | UG |
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: | 1 | 192.168.7.0 | 0.0.0.0 | 255.255.255.0 | eno1 | U |
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: | 2 | 192.168.7.1 | 0.0.0.0 | 255.255.255.255 | eno1 | UH |
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: +-------+-------------+-------------+-----------------+-----------+-------+
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: +++++++++++++++++++Route IPv6 info+++++++++++++++++++
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: +-------+-------------+---------+-----------+-------+
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: | Route | Destination | Gateway | Interface | Flags |
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: +-------+-------------+---------+-----------+-------+
Sep 15 20:46:58 watcher cloud-init[1030]: ci-info: | 1 | fe80::/64 | :: | eno1 | U |
Sep 15 20:46:59 watcher cloud-init[1030]: ci-info: | 3 | local | :: | eno1 | U |
Sep 15 20:46:59 watcher cloud-init[1030]: ci-info: | 4 | ff00::/8 | :: | eno1 | U |
Sep 15 20:46:59 watcher cloud-init[1030]: ci-info: +-------+-------------+---------+-----------+-------+
Sep 15 20:46:59 watcher systemd[1]: Started Initial cloud-init job (metadata service crawler).
Sep 15 20:46:59 watcher systemd[1]: Reached target Cloud-config availability.
Sep 15 20:46:59 watcher systemd[1]: Reached target Network is Online.
Sep 15 20:46:59 watcher systemd[1]: Starting iSCSI initiator daemon (iscsid)...
Sep 15 20:46:59 watcher iscsid[1080]: iSCSI logger with pid=1083 started!
Sep 15 20:46:59 watcher systemd[1]: Started iSCSI initiator daemon (iscsid).
Sep 15 20:46:59 watcher systemd[1]: Starting Availability of block devices...
Sep 15 20:46:59 watcher systemd[1]: Reached target Remote File Systems (Pre).
Sep 15 20:46:59 watcher systemd[1]: Mounting /mnt/video...
Sep 15 20:46:59 watcher kernel: No dialect specified on mount. Default has changed to a more secure dialect, SMB2.1 or later (e.g. SMB3), from CIFS (SMB1). To use the less secure SMB1 dialect to access old servers which do not support SMB3 (or SMB2.1) specify vers=1.0 on mount.
Sep 15 20:46:59 watcher systemd[1]: mnt-docker.mount: Directory /mnt/docker to mount over is not empty, mounting anyway.
Sep 15 20:46:59 watcher systemd[1]: Mounting /mnt/docker...
Sep 15 20:46:59 watcher systemd[1]: Mounting /mnt/Titan...
Sep 15 20:46:59 watcher systemd[1]: Started Availability of block devices.
Sep 15 20:46:59 watcher kernel: No dialect specified on mount. Default has changed to a more secure dialect, SMB2.1 or later (e.g. SMB3), from CIFS (SMB1). To use the less secure SMB1 dialect to access old servers which do not support SMB3 (or SMB2.1) specify vers=1.0 on mount.
Sep 15 20:46:59 watcher kernel: No dialect specified on mount. Default has changed to a more secure dialect, SMB2.1 or later (e.g. SMB3), from CIFS (SMB1). To use the less secure SMB1 dialect to access old servers which do not support SMB3 (or SMB2.1) specify vers=1.0 on mount.
Sep 15 20:46:59 watcher systemd[1]: Mounted /mnt/video.
Sep 15 20:46:59 watcher systemd[1]: Mounted /mnt/docker.
Sep 15 20:46:59 watcher systemd[1]: Mounted /mnt/Titan.
Sep 15 20:46:59 watcher systemd[1]: Reached target Remote File Systems.
答案1
在/etc/fstab
这些条目中,尝试添加选项_netdev
,或者,如果不起作用,请添加
x-systemd.after=network-online.target
答案2
由于遇到过类似的问题,并且由于该_netdev
选项对我的情况没有帮助,所以我想分享另一个非常简单的解决方案,这是我在对 _netdev 参数、Crontab 的 @reboot 参数、sleep 命令和文件 rc.local 进行大量徒劳无功的修改后才找到的):
应该有一个名为的文件夹
/etc/network/if-up.d
您转储到那里的任何脚本都仅在网络链接建立后才会执行。
工作原理:只需添加一个带有常用选项的 fstab 条目(我也必须使用“vers=3.0”,但这是另一回事)。然后用该行编写一个简单的可执行脚本mount -a
并将其转储到上述目录中。
非常简单,并且对我来说非常有效,但它似乎并不是常识。