Redhat

在 redhat 7.2 上自動掛載 nfs 不起作用

  • May 10, 2019

我的 linux 客戶端(redhat 7.2)上有以下 nfd 共享文件夾

master1:/nfs             41932800 6601728  35331072  16% /nfsshare

我們決定使用服務 auto fs 以防此共享文件夾被解除安裝

我們創建了以下服務(根據連結 - https://michlstechblog.info/blog/systemd-automount-nfs-export/

ls -ltr  auto-mnt.service
-rw-r--r-- 1 root root 212 May 10 12:38 auto-mnt.service

會議

more  auto-mnt.service
[Unit]
 Description=nfs mount script
 Requires=network-online.target
 After=network-online.service

[Mount]
 What=master1:/nfs
 Where=/nfsshare
 Options=
 Type=nfs

[Install]
 WantedBy=multi-user.target

systemctl daemon-reload

systemctl start auto-mnt.service
Failed to start auto-mnt.service: Unit auto-mnt.service failed to load: Invalid argument. See system logs and 'systemctl status auto-mnt.service' for details.
[root@ system]# systemctl status auto-mnt.service
● auto-mnt.service - nfs mount script
  Loaded: error (Reason: Invalid argument)
  Active: inactive (dead)

我們不明白為什麼服務抱怨 -

[/etc/systemd/system/auto-mnt.service:6] Unknown section 'Mount'. Ignoring.
auto-mnt.service lacks both ExecStart= and ExecStop= setting. Refusing.

Unknown section 'Mount'. Ignoring

服務語法有什麼問題?

systemd 中的掛載單元配置文件不是服務,它們需要的文件副檔名為.mountnot.service

引用自:https://serverfault.com/questions/966714