Boot
儘管配置了 IP 地址,但 NFS 安裝在引導時失敗
我正在嘗試在啟動時在 Raspberry Pi 4 上掛載我的 NFS 共享。它不起作用並且 systemd 抱怨網路無法訪問。手動安裝每個共享按預期工作。我現在嘗試了不同的東西。我沒有使用systemd
/etc/fstab
服務來安裝卷,如下所示:[Unit] Description=Mount NFS share Music After=network-online.target Wants=network-online.target [Mount] What=10.5.0.34:/music Where=home/pi/media_storage/music Options=auto Type=nfs TimeoutSec=60 [Install] WantedBy=remote-fs.target
這兩項服務
systemd-networkd.service
都已systemd-networkd-wait-online.service
啟用。這是journalctl
輸出:Nov 30 16:30:46 NextcloudPi dhcpcd[383]: eth0: IAID 32:23:48:46 Nov 30 16:30:46 NextcloudPi dhcpcd[383]: eth0: adding address fe80::9819:5d1a:3c86:8b41 Nov 30 16:30:46 NextcloudPi dhcpcd[383]: eth0: rebinding lease of 10.5.0.43 Nov 30 16:30:46 NextcloudPi dhcpcd[383]: eth0: probing address 10.5.0.43/24 Nov 30 16:30:46 NextcloudPi dhcpcd[383]: eth0: soliciting an IPv6 router Nov 30 16:30:47 NextcloudPi systemd-networkd[152]: eth0: Gained IPv6LL Nov 30 16:30:47 NextcloudPi systemd-timesyncd[281]: Network configuration changed, trying to establish connection. Nov 30 16:30:47 NextcloudPi systemd-networkd-wait-online[183]: ignoring: lo Nov 30 16:30:47 NextcloudPi systemd[1]: Started Wait for Network to be Configured. Nov 30 16:30:47 NextcloudPi systemd[1]: Reached target Network is Online. Nov 30 16:30:48 NextcloudPi systemd[1]: Mounting Mount NFS share Music... Nov 30 16:30:48 NextcloudPi systemd[1]: Started /etc/rc.local Compatibility. Nov 30 16:30:48 NextcloudPi mount[498]: mount.nfs: Network is unreachable Nov 30 16:30:48 NextcloudPi systemd[1]: mnt-music.mount: Mount process exited, code=exited, status=32/n/a Nov 30 16:30:48 NextcloudPi systemd[1]: mnt-music.mount: Failed with result 'exit-code'. Nov 30 16:30:48 NextcloudPi systemd[1]: Failed to mount Mount NFS share Music. Nov 30 16:30:48 NextcloudPi systemd[1]: Reached target Remote File Systems.
根據
journalctl
介面配置並擁有一個有效的IP地址。為什麼還要mount.nfs
抱怨?
由於
network-online.target
似乎已損壞,因此無論我做什麼,我都開發了一種不同且可靠的解決方案。我創建了一個單一的 systemd 腳本:“ping_barrier”。它會ping NFS 伺服器,直到成功。使
WantedBy=nfs-client.target
NFS 等待此服務完成。[Unit] Description=Ping until Success [Service] Type=oneshot ExecStart=/opt/ping_barrier.sh StandardOutput=journal [Install] WantedBy=nfs-client.target
這是循環的 ping 腳本,直到 ping 命令成功:
#!/bin/bash printf "%s" "waiting for FileServer ..." while ! ping -c 1 -n -w 1 10.5.0.34 &> /dev/null do printf "%c" "." done printf "\n%s\n" "Server is back online"