我现在有几台 CentOS 7 客户端计算机正在针对 OpenLDAP 进行身份验证。下一步是让 autofs 工作。我已经这样做了,但我的地图会一次加载所有用户。我想避免这种情况。假设我有两个用户
user1
user2
它们都有一个 NFS 共享,我想使用 autofs 映射它们。
/home -fstype=nfs,rw domain.com:/homes
有效,但我得到了所有人。我认为我可以使用变量或通配符来实现这一点。所以我尝试了以下映射
/home/${USER} -fstype=nfs,rw domain.com:/homes/${USER}
/home/${USER}/Music -fstype=nfs,rw domain.com:/homes/${USER}/&
但 CentOS 似乎不喜欢我的变量。我试过了
/home/${USER} -fstype=nfs,rw domain.com:/homes/${USER}
/home/$USER -fstype=nfs,rw domain.com:/homes/$USER
/home/* -fstype=nfs,rw domain.com:/homes
有人能告诉我我错过了什么吗?
谢谢你!
编辑日志
Dec 8 22:22:13 workstation automount[1897]: setautomntent: lookup(sss): setautomntent: No such file or directory
Dec 8 22:22:13 workstation automount[1897]: do_mount_autofs_direct: failed to create mount directory /home/${USER}
答案1
来自 autofs 手册页:
Map Key Substitution
An & character in the location is expanded to the value of the key field that matched the line (which probably only makes sense together with a wildcard key).
Wildcard Key
A map key of * denotes a wild-card entry. This entry is consulted if the specified key does not exist in the map. A typical wild-card entry looks like this:
* server:/export/home/&
The special character '&' will be replaced by the provided key. So, in the example above, a lookup for the key 'foo' would yield a mount of server:/export/home/foo.
我是用手机打字的,所以格式有点问题,请谅解。