192.168.254.105:/srv/nfsshare
我全新安装了 Centos 7。我似乎无法从 Centos 客户端自动挂载 NFS 共享。
然而,手动安装共享效果很好。
/etc/auto.master已被完全注释掉以简化问题,除了以下行:
/- /etc/auto.nfsshare
/etc/auto.nfsshare 包含以下行:
/tests/nfsshare -fstype=nfs,credentials=/etc/credentials.txt 192.168.254.105:/srv/nfsshare
/etc/credentials.txt持有:
user=user
password=password
预期的行为是,当我 时ls -l /tests/nfsshare
,我会看到我的文件服务器的一些文件/srv/nfsshare目录保存。
它不是。相反,它什么也没显示。
日志来自须藤journalctl --unit=autofs.service启动时显示此信息(启用调试):
Nov 20 00:25:38 localhost.localdomain systemd[1]: Starting Automounts filesystems on demand...
Nov 20 00:25:38 localhost.localdomain automount[21204]: Starting automounter version 5.0.7-48.el7, master map auto.master
Nov 20 00:25:38 localhost.localdomain automount[21204]: using kernel protocol version 5.02
Nov 20 00:25:38 localhost.localdomain automount[21204]: lookup_nss_read_master: reading master files auto.master
Nov 20 00:25:38 localhost.localdomain automount[21204]: parse_init: parse(sun): init gathered global options: (null)
Nov 20 00:25:38 localhost.localdomain automount[21204]: spawn_mount: mtab link detected, passing -n to mount
Nov 20 00:25:38 localhost.localdomain automount[21204]: spawn_umount: mtab link detected, passing -n to mount
Nov 20 00:25:38 localhost.localdomain automount[21204]: lookup_read_master: lookup(file): read entry /-
Nov 20 00:25:38 localhost.localdomain automount[21204]: master_do_mount: mounting /-
Nov 20 00:25:38 localhost.localdomain automount[21204]: automount_path_to_fifo: fifo name /run/autofs.fifo--
Nov 20 00:25:38 localhost.localdomain automount[21204]: lookup_nss_read_map: reading map file /etc/auto.nfsshare
Nov 20 00:25:38 localhost.localdomain automount[21204]: parse_init: parse(sun): init gathered global options: (null)
Nov 20 00:25:38 localhost.localdomain automount[21204]: spawn_mount: mtab link detected, passing -n to mount
Nov 20 00:25:38 localhost.localdomain automount[21204]: spawn_umount: mtab link detected, passing -n to mount
Nov 20 00:25:38 localhost.localdomain automount[21204]: mounted direct on /tests/nfsshare with timeout 300, freq 75 seconds
Nov 20 00:25:38 localhost.localdomain automount[21204]: do_mount_autofs_direct: mounted trigger /tests/nfsshare
Nov 20 00:25:38 localhost.localdomain automount[21204]: st_ready: st_ready(): state = 0 path /-
Nov 20 00:25:38 localhost.localdomain systemd[1]: Started Automounts filesystems on demand.
当我尝试通过以下方式强制安装 nfs 共享时,我的日志中会出现以下内容ls -l /测试/nfsshare:
Nov 20 00:48:05 localhost.localdomain automount[22030]: handle_packet: type = 5
Nov 20 00:48:05 localhost.localdomain automount[22030]: handle_packet_missing_direct: token 21, name /tests/nfsshare, request pid 22057
Nov 20 00:48:05 localhost.localdomain automount[22030]: attempting to mount entry /tests/nfsshare
Nov 20 00:48:05 localhost.localdomain automount[22030]: lookup_mount: lookup(file): looking up /tests/nfsshare
Nov 20 00:48:05 localhost.localdomain automount[22030]: lookup_mount: lookup(file): /tests/nfsshare -> -fstype=nfs,credentials=/etc/credenti...fsshare
Nov 20 00:48:05 localhost.localdomain automount[22030]: parse_mount: parse(sun): expanded entry: -fstype=nfs,credentials=/etc/credentials.tx...fsshare
Nov 20 00:48:05 localhost.localdomain automount[22030]: parse_mount: parse(sun): gathered options: fstype=nfs,credentials=/etc/credentials.txt
Nov 20 00:48:05 localhost.localdomain automount[22030]: [90B blob data]
Nov 20 00:48:05 localhost.localdomain automount[22030]: dev_ioctl_send_fail: token = 21
Nov 20 00:48:05 localhost.localdomain automount[22030]: failed to mount /tests/nfsshare
Nov 20 00:48:05 localhost.localdomain automount[22030]: handle_packet: type = 5
Nov 20 00:48:05 localhost.localdomain automount[22030]: handle_packet_missing_direct: token 22, name /tests/nfsshare, request pid 22057
Nov 20 00:48:05 localhost.localdomain automount[22030]: dev_ioctl_send_fail: token = 22
此外,ls -l /测试/nfsshare实际上会产生错误:
ls: cannot access nfsshare/: No such file or directory
我该如何解决这个问题?如前所述,手动安装共享工作正常。
编辑:根据要求,输出ls -la /etc/auto.nfsshare
-rw-r--r--. 1 root root 99 Nov 20 00:25 /etc/auto.nfsshare
答案1
我有同样的问题。
配置很好,但目录不存在,尽管似乎已创建。
我的特定情况下的解决方案是该文件是 UTF-8 文件,autofs 无法读取该文件(这就是您在日志记录中收到 Blob 消息的原因)。
重新创建该文件,并确保它是 ascii 文件。在我改变之后,一切都完美无缺。
答案2
到目前为止,我还没有遇到过受用户名/密码保护的 NFS 共享。
无论如何,您可以在这里充分利用 systemd 功能(例如,您希望在 /tests/nfsshare 中挂载基本 NFS 共享)。
192.168.254.105:/srv/nfsshare /tests/nfsshare nfs users,_netdev,x-systemd.automount 0 0