文件映射中使用的映射项 +mapname 将导致自动挂载读取指定的映射,就好像该映射包含在当前文件中一样。如果 mapname 前面没有斜杠,则 autofs 会将映射名视为字符串,并使用名称服务转换器策略查找映射名。如果路径名是绝对路径名,则 automount 将检查该名称的本地映射。如果映射名以破折号 (-) 开头,则 automount 将访问相应的内置映射,如 hosts。
此名称服务转换器文件包含标记为 automount 的 autofs 的一个项,其中包含搜索名称服务的顺序。以下文件是名称服务转换器文件的示例。
# # /etc/nsswitch.nis: # # An example file that could be copied over to /etc/nsswitch.conf; # it uses NIS (YP) in conjunction with files. # # "hosts:" and "services:" in this file are used only if the /etc/netconfig # file contains "switch.so" as a nametoaddr library for "inet" transports. # the following two lines obviate the "+" entry in /etc/passwd and /etc/group. passwd: files nis group: files nis # consult /etc "files" only if nis is down. hosts: nis [NOTFOUND=return] files networks: nis [NOTFOUND=return] files protocols: nis [NOTFOUND=return] files rpc: nis [NOTFOUND=return] files ethers: nis [NOTFOUND=return] files netmasks: nis [NOTFOUND=return] files bootparams: nis [NOTFOUND=return] files publickey: nis [NOTFOUND=return] files netgroup: nis automount: files nis aliases: files nis # for efficient getservbyname() avoid nis services: files nis |
在本示例中,会在搜索 NIS 映射之前先搜索本地映射。因此,可以在本地 /etc/auto_home 映射中为最常访问的起始目录包含几个项。然后,可以使用转换器回退到 NIS 映射以查找其他项。
bill cs.csc.edu:/export/home/bill bonny cs.csc.edu:/export/home/bonny |
搜索包括的映射后,如果找不到匹配项,automount 将继续扫描当前映射。因此,可以在 + 项之后添加更多项。
bill cs.csc.edu:/export/home/bill bonny cs.csc.edu:/export/home/bonny +auto_home |
包括的映射可以是本地文件,也可以是内置映射。请记住,只有本地文件可以包含 + 项。
+auto_home_finance # NIS+ map +auto_home_sales # NIS+ map +auto_home_engineering # NIS+ map +/etc/auto_mystuff # local map +auto_home # NIS+ map +-hosts # built-in hosts map |