如何在 Fedora 17 上掛載 NFS 3 磁碟區?

如何在 Fedora 17 上掛載 NFS 3 磁碟區?

我安裝了該軟體包nfs-utils並通過以下方式進行了嘗試:

# mount -t nfs server:/mnt /mnt
mount.nfs: rpc.statd is not running but is required for remote locking.
mount.nfs: Either use '-o nolock' to keep locks local, or start statd.
mount.nfs: an incorrect mount option was specified

好吧,可能需要透過 systemd 啟動它,對吧?

# systemctl start nfs-lock.service 
Job failed. See system journal and 'systemctl status' for details.
# journalctl
Jun 15 23:22:18 host rpc.statd[24339]: Version 1.2.6 starting
Jun 15 23:22:18 host rpc.statd[24339]: Opening /var/run/rpc.statd.pid failed:
                                         Permission denied
[..]
Jun 15 23:22:18 host systemd[1]: nfs-lock.service: control process exited, 
                                         code=exited status=1
Jun 15 23:22:18 host systemd[1]: Unit nfs-lock.service entered failed state.

看起來像是 SELinux 相關的問題?

Jun 15 23:22:18 host setroubleshoot[3211]: analyze_avc()
   avc=scontext=system_u:system_r:rpcd_t:s0
   tcontext=unconfined_u:object_r:var_run_t:s0
   access=['unlink'] tclass=file tpath=rpc.statd.pid
Jun 15 23:22:18 host setroubleshoot[3211]: SELinux is preventing
   /usr/sbin/rpc.statd from unlink access on the file rpc.statd.pid.
Jun 15 23:22:18 host setroubleshoot[3211]: analyze_avc()
   avc=scontext=system_u:system_r:rpcd_t:s0
   tcontext=unconfined_u:object_r:var_run_t:s0
   access=['write'] tclass=file tpath=rpc.statd.pid
Jun 15 23:22:18 host setroubleshoot[3211]: SELinux is preventing
   /usr/sbin/rpc.statd from write access on the file rpc.statd.pid.

好的 - 現在的問題是:我必須更改什麼 SELinux 設定或什麼檔案標籤?

# systemctl status nfs-lock.service
nfs-lock.service - NFS file locking service.
      Loaded: loaded (/usr/lib/systemd/system/nfs-lock.service; enabled)
      Active: failed (Result: exit-code) since Fri, 15 Jun 2012 23:22:18 +0200;
              13min ago
     Process: 24338 ExecStart=/sbin/rpc.statd $STATDARG
              (code=exited, status=1/FAILURE)
     Process: 24334 ExecStartPre=/usr/lib/nfs-utils/scripts/nfs-lock.preconfig
              (code=exited, status=0/SUCCESS)
      CGroup: name=systemd:/system/nfs-lock.service

包裹是否丟失 - 或者我使用了錯誤的服務?

答案1

不確定這是否有幫助,因為我沒有看到任何 SElinux 錯誤。

安裝 Fedora 17 後,我升級到最新版本,但沒有重新啟動。由於幾個 gnome 軟體包的更新,我確實登出並重新登入。 (我沒有註意到更新systemd也包含了更新。)

為了掛載 NFS 共享,我安裝nfs-utils並嘗試啟動 rpcbind 服務:

sudo systemctl start rpcbind.service

我收到以下錯誤:

Failed to issue method call: Unit var-run.mount failed to load: No such file or directory. See system logs and 'systemctl status var-run.mount' for details.

var-run.mount 最近似乎已被刪除,yum whatprovides表明它systemd-44-8.fc17仍然存在。

其他幾個 NFS 服務也拋出了相同的錯誤。

就我而言,只需重新啟動就有幫助。因此,您可能需要更新至最新的軟體包並重新啟動。 (如果有人知道如何讓 systemd 重新讀取其配置而無需重新啟動,請告訴我。)

答案2

在 Fedora 17 中,您必須啟動的服務名稱是“nfslock”,因此:

systemctl start nfslock

安裝 nfs-utils 後它已經啟用

答案3

看起來nfs-lock.service透過 systemd 啟動並不是從命令列進行 NFS 3 掛載的真正先決條件。

剛剛執行

# mount -t nfs server:/mnt /mnt

nfs-utils(安裝套件後)會導致出現「已載入rpc.statd- 沒有進一步的 SELinux」錯誤訊息。並且掛載的 NFS 導出可以毫無問題地使用。

看起來核心只是按需啟動 rpc.statd (和朋友),而不是與 systemd 互動:

# pgrep -l rpc
3063 rpc.statd
22599 rpciod
24280 rpcbind

相關內容