xref: /netbsd-src/usr.sbin/autofs/auto_master.5 (revision b94e44675e4c2360dbf55042b06acad015836368)
1*b94e4467Stkusumi.\"	$NetBSD: auto_master.5,v 1.8 2019/11/21 15:24:17 tkusumi Exp $
2b985414bSchristos.\" Copyright (c) 2017 The NetBSD Foundation, Inc.
3b985414bSchristos.\" Copyright (c) 2016 The DragonFly Project
4b985414bSchristos.\" Copyright (c) 2014 The FreeBSD Foundation
5b985414bSchristos.\" All rights reserved.
6b985414bSchristos.\"
7b985414bSchristos.\" This code is derived from software contributed to The NetBSD Foundation
8b985414bSchristos.\" by Tomohiro Kusumi.
9b985414bSchristos.\"
10b985414bSchristos.\" This software was developed by Edward Tomasz Napierala under sponsorship
11b985414bSchristos.\" from the FreeBSD Foundation.
12b985414bSchristos.\"
13b985414bSchristos.\" Redistribution and use in source and binary forms, with or without
14b985414bSchristos.\" modification, are permitted provided that the following conditions
15b985414bSchristos.\" are met:
16b985414bSchristos.\" 1. Redistributions of source code must retain the above copyright
17b985414bSchristos.\"    notice, this list of conditions and the following disclaimer.
18b985414bSchristos.\" 2. Redistributions in binary form must reproduce the above copyright
19b985414bSchristos.\"    notice, this list of conditions and the following disclaimer in the
20b985414bSchristos.\"    documentation and/or other materials provided with the distribution.
21b985414bSchristos.\"
22b985414bSchristos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
23b985414bSchristos.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24b985414bSchristos.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25b985414bSchristos.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
26b985414bSchristos.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27b985414bSchristos.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28b985414bSchristos.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29b985414bSchristos.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30b985414bSchristos.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31b985414bSchristos.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32b985414bSchristos.\" SUCH DAMAGE.
33b985414bSchristos.\"
34b985414bSchristos.\" $FreeBSD$
35b985414bSchristos.\"
36560993f9Stkusumi.Dd November 16, 2019
37b985414bSchristos.Dt AUTO_MASTER 5
38b985414bSchristos.Os
39b985414bSchristos.Sh NAME
40b985414bSchristos.Nm auto_master
41b985414bSchristos.Nd auto_master and map file format
42b985414bSchristos.Sh DESCRIPTION
43b985414bSchristosThe automounter configuration consists of the
44b985414bSchristos.Nm
45b985414bSchristosconfiguration file, which assigns file system paths to map names,
46b985414bSchristosand maps, which contain actual mount information.
47b985414bSchristosThe
48b985414bSchristos.Nm
49b985414bSchristosconfiguration file is used by the
50b985414bSchristos.Xr automount 8
51b985414bSchristoscommand.
52b985414bSchristosMap files are read by the
53b985414bSchristos.Xr automountd 8
54b985414bSchristosdaemon.
55b985414bSchristos.Sh AUTO_MASTER SYNTAX
56b985414bSchristosThe
57b985414bSchristos.Nm
58b985414bSchristosfile consists of lines with two or three entries separated by whitespace
5967dee3c7Swizand terminated by a newline character:
60b985414bSchristos.Bd -literal -offset indent
61ad8c206fSuwe.Ar mountpoint Ar map_name Op Fl Ar options
62b985414bSchristos.Ed
63b985414bSchristos.Pp
64ad8c206fSuwe.Ar mountpoint
65b985414bSchristosis either a fully specified path, or
66ad8c206fSuwe.Pa /- .
67b985414bSchristosWhen
68ad8c206fSuwe.Ar mountpoint
69b985414bSchristosis a full path,
70ad8c206fSuwe.Ar map_name
71b985414bSchristosmust reference an indirect map.
72b985414bSchristosOtherwise,
73ad8c206fSuwe.Ar map_name
74b985414bSchristosmust reference a direct map.
75b985414bSchristosSee
76b985414bSchristos.Sx "MAP SYNTAX"
77b985414bSchristosbelow.
78b985414bSchristos.Pp
79ad8c206fSuwe.Ar map_name
80b985414bSchristosspecifies map to use.
81b985414bSchristosIf
82ad8c206fSuwe.Ar map_name
83b985414bSchristosbegins with
84b985414bSchristos.Li - ,
85b985414bSchristosit specifies a special map.
86b985414bSchristosSee
87b985414bSchristos.Sx "MAP SYNTAX"
88b985414bSchristosbelow.
89b985414bSchristosIf
90ad8c206fSuwe.Ar map_name
91b985414bSchristosis not a fully specified path
92b985414bSchristos.Pq it does not start with Li / ,
93b985414bSchristos.Xr automountd 8
94b985414bSchristoswill search for that name in
9567dee3c7Swiz.Pa /etc .
96b985414bSchristosOtherwise it will use the path as given.
97b985414bSchristosIf the file indicated by
98ad8c206fSuwe.Ar map_name
99b985414bSchristosis executable,
100b985414bSchristos.Xr automountd 8
101b985414bSchristoswill assume it is an executable map.
102b985414bSchristosSee
103b985414bSchristos.Sx "MAP SYNTAX"
104b985414bSchristosbelow.
105b985414bSchristosOtherwise, the file is opened and the contents parsed.
106b985414bSchristos.Pp
107ad8c206fSuwe.Op Fl Ar options
108b985414bSchristosis an optional field that starts with
109ad8c206fSuwe.Fl
110b985414bSchristosand can contain generic file system mount options.
111b985414bSchristos.Pp
11267dee3c7SwizThe following example specifies that the
11367dee3c7Swiz.Pa /etc/auto_example
11467dee3c7Swizindirect map will be mounted on
11567dee3c7Swiz.Pa /example .
116b985414bSchristos.Bd -literal -offset indent
117b985414bSchristos/example auto_example
118b985414bSchristos.Ed
119b985414bSchristos.Sh MAP SYNTAX
120b985414bSchristosMap files consist of lines with a number of entries separated by whitespace
121b985414bSchristosand terminated by newline character:
122b985414bSchristos.Bd -literal -offset indent
123ad8c206fSuwe.Ar key Oo Fl Ar options Oc Oo Ar mountpoint Oo Fl Ar options Oc Oc Ar location Op ...
124b985414bSchristos.Ed
125b985414bSchristos.Pp
126b985414bSchristosIn most cases, it can be simplified to:
127b985414bSchristos.Bd -literal -offset indent
128ad8c206fSuwe.Ar key Oo Fl Ar options Oc Ar location
129b985414bSchristos.Ed
130b985414bSchristos.Pp
131ad8c206fSuwe.Ar key
132b985414bSchristosis the path component used by
133b985414bSchristos.Xr automountd 8
134b985414bSchristosto find the right map entry to use.
135b985414bSchristosIt is also used to form the final mountpoint.
136b985414bSchristosA wildcard
137b985414bSchristos.Pq Ql *
138b985414bSchristoscan be used for the key.
139b985414bSchristosIt matches every directory that does not match other keys.
14067dee3c7SwizThose directories will not be visible to the user until accessed.
141b985414bSchristos.Pp
142b985414bSchristosThe
143b985414bSchristos.Ar options
144b985414bSchristosfield, if present, must begin with
145ad8c206fSuwe.Fl .
146b985414bSchristosWhen mounting the file system, options supplied to
147b985414bSchristos.Nm
148b985414bSchristosand options specified in the map entry are concatenated together.
149b985414bSchristosThe special option
150ad8c206fSuwe.Ic fstype
151b985414bSchristosis used to specify file system type.
152b985414bSchristosIt is not passed to the mount program as an option.
153b985414bSchristosInstead, it is passed as an argument to
154b985414bSchristos.Cm "mount -t".
155b985414bSchristosThe default
156ad8c206fSuwe.Ic fstype
157b985414bSchristosis
158b985414bSchristos.Ql nfs .
159b985414bSchristosThe special option
160ad8c206fSuwe.Ic nobrowse
161b985414bSchristosis used to disable creation of top-level directories for special
162b985414bSchristosand executable maps.
163b985414bSchristos.Pp
164b985414bSchristosThe optional
165ad8c206fSuwe.Ar mountpoint
16667dee3c7Swizfield is used to specify multiple mount points for a single key.
167b985414bSchristos.Pp
168b985414bSchristosThe
169b985414bSchristos.Ar location
170b985414bSchristosfield specifies the file system to be mounted.
171b985414bSchristosAmpersands
172b985414bSchristos.Pq Ql &
173b985414bSchristosin the
174b985414bSchristos.Ar location
175b985414bSchristosfield are replaced with the value of
176b985414bSchristos.Ar key .
177b985414bSchristosThis is typically used with wildcards, like:
178b985414bSchristos.Bd -literal -offset indent
17944fdebe4Suwe*	192.168.1.1:/share/&
180b985414bSchristos.Ed
181b985414bSchristos.Pp
182b985414bSchristosThe
183b985414bSchristos.Ar location
184b985414bSchristosfield may contain references to variables, like:
185b985414bSchristos.Bd -literal -offset indent
18644fdebe4Suwesys	192.168.1.1:/sys/${OSNAME}
187b985414bSchristos.Ed
188b985414bSchristos.Pp
189b985414bSchristosDefined variables are:
190b985414bSchristos.Pp
191ad8c206fSuwe.Bl -tag -width "Dv OSNAME" -compact
192ad8c206fSuwe.It Dv ARCH
193b985414bSchristosExpands to the output of
194b985414bSchristos.Li "uname -p" .
195ad8c206fSuwe.It Dv CPU
19667dee3c7SwizSame as
197ad8c206fSuwe.Dv ARCH .
198560993f9Stkusumi.It Dv DOLLAR
199560993f9StkusumiA literal $ sign.
200ad8c206fSuwe.It Dv HOST
201b985414bSchristosExpands to the output of
202b985414bSchristos.Li "uname -n" .
203ad8c206fSuwe.It Dv OSNAME
204b985414bSchristosExpands to the output of
205b985414bSchristos.Li "uname -s" .
206ad8c206fSuwe.It Dv OSREL
207b985414bSchristosExpands to the output of
208b985414bSchristos.Li "uname -r" .
209ad8c206fSuwe.It Dv OSVERS
210b985414bSchristosExpands to the output of
211b985414bSchristos.Li "uname -v" .
212b985414bSchristos.El
213b985414bSchristos.Pp
214b985414bSchristosAdditional variables can be defined with the
215b985414bSchristos.Fl D
216b985414bSchristosoption of
217b985414bSchristos.Xr automount 8
218b985414bSchristosand
219b985414bSchristos.Xr automountd 8 .
220b985414bSchristos.Pp
221b985414bSchristosTo pass a location that begins with
222ad8c206fSuwe.Pa / ,
223b985414bSchristosprefix it with a colon.
224b985414bSchristosFor example,
225b985414bSchristos.Li :/dev/cd0 .
226b985414bSchristos.Pp
227b985414bSchristosThis example, when put into
228b985414bSchristos.Pa /etc/auto_example ,
229b985414bSchristosand with
230b985414bSchristos.Nm
231b985414bSchristosreferring to the map as described above, specifies that the NFS share
232b985414bSchristos.Li 192.168.1.1:/share/example/x
233b985414bSchristoswill be mounted on
234b985414bSchristos.Pa /example/x/
235b985414bSchristoswhen any process attempts to access that mountpoint, with
236ad8c206fSuwe.Ic intr
237b985414bSchristosand
238ad8c206fSuwe.Ic nfsv4
239b985414bSchristosmount options, described in
240b985414bSchristos.Xr mount_nfs 8 :
241b985414bSchristos.Bd -literal -offset indent
24244fdebe4Suwex -intr,nfsv4 192.168.1.1:/share/example/x
243b985414bSchristos.Ed
244b985414bSchristos.Pp
245b985414bSchristosAutomatically mount an SMB share on access, as a guest user,
246b985414bSchristoswithout prompting for a password:
247b985414bSchristos.Bd -literal -offset indent
24844fdebe4Suweshare -fstype=smbfs,-N ://@server/share
249b985414bSchristos.Ed
250b985414bSchristos.Pp
251b985414bSchristosAutomatically mount the CD drive on access:
252b985414bSchristos.Bd -literal -offset indent
25344fdebe4Suwecd -fstype=cd9660 :/dev/cd0
254b985414bSchristos.Ed
255b985414bSchristos.Sh SPECIAL MAPS
256b985414bSchristosSpecial maps have names beginning with
257b985414bSchristos.Li - .
258b985414bSchristosSupported special maps are:
259b985414bSchristos.Pp
260ad8c206fSuwe.Bl -tag -width ".Ic -noauto" -compact
261ad8c206fSuwe.It Ic -hosts
262b985414bSchristosQuery the remote NFS server and map exported shares.
263b985414bSchristosThis map is traditionally mounted on
264b985414bSchristos.Pa /net .
265b985414bSchristosAccess to files on a remote NFS server is provided through the
266ad8c206fSuwe.Pa /net/ Ns Ar nfs-server-ip Ns / Ns Ar share-name Ns /
267b985414bSchristosdirectory without any additional configuration.
268b985414bSchristosDirectories for individual NFS servers are not present until the first access,
269b985414bSchristoswhen they are automatically created.
270ad8c206fSuwe.It Ic -media
271b985414bSchristosQuery devices that are not yet mounted, but contain valid file systems.
272b985414bSchristosGenerally used to access files on removable media.
273ad8c206fSuwe.It Ic -noauto
274b985414bSchristosMount file systems configured in
275b985414bSchristos.Xr fstab 5
276b985414bSchristosas "noauto".
277b985414bSchristosThis needs to be set up as a direct map.
278ad8c206fSuwe.It Ic -null
279b985414bSchristosPrevent
280b985414bSchristos.Xr automountd 8
281b985414bSchristosfrom mounting anything on the mountpoint.
282b985414bSchristos.El
283b985414bSchristos.Pp
284b985414bSchristosIt is possible to add custom special maps by adding them, as executable
285b985414bSchristosmaps named
286b985414bSchristos.Pa special_foo ,
287b985414bSchristosto the
288b985414bSchristos.Pa /etc/autofs/
289b985414bSchristosdirectory.
290b985414bSchristos.Sh EXECUTABLE MAPS
291b985414bSchristosIf the map file specified in
292b985414bSchristos.Nm
293b985414bSchristoshas the execute bit set,
294b985414bSchristos.Xr automountd 8
295b985414bSchristoswill execute it and parse the standard output instead of parsing
296b985414bSchristosthe file contents.
297b985414bSchristosWhen called without command line arguments, the executable is
298b985414bSchristosexpected to output a list of available map keys separated by
299b985414bSchristosnewline characters.
300b985414bSchristosOtherwise, the executable will be called with a key name as
301b985414bSchristosa command line argument.
302b985414bSchristosOutput from the executable is expected to be the entry for that key,
303b985414bSchristosnot including the key itself.
304b985414bSchristos.Sh INDIRECT VERSUS DIRECT MAPS
305b985414bSchristosIndirect maps are referred to in
306b985414bSchristos.Nm
307b985414bSchristosby entries with a fully qualified path as a mount point, and must contain only
308b985414bSchristosrelative paths as keys.
309b985414bSchristosDirect maps are referred to in
310b985414bSchristos.Nm
311b985414bSchristosby entries with
312b985414bSchristos.Li /-
313b985414bSchristosas the mountpoint, and must contain only fully qualified paths as keys.
314b985414bSchristosFor indirect maps, the final mount point is determined by concatenating the
315b985414bSchristos.Nm
316b985414bSchristosmountpoint with the map entry key and optional map entry mountpoint.
317b985414bSchristosFor direct maps, the final mount point is determined by concatenating
318b985414bSchristosthe map entry key with the optional map entry mountpoint.
319b985414bSchristos.Pp
320b985414bSchristosThe example above could be rewritten using direct map, by placing this in
321b985414bSchristos.Nm :
322b985414bSchristos.Bd -literal -offset indent
32344fdebe4Suwe/- auto_example
324b985414bSchristos.Ed
325b985414bSchristos.Pp
32667dee3c7Swizand this in the
32767dee3c7Swiz.Pa /etc/auto_example
328b985414bSchristosmap file:
329b985414bSchristos.Bd -literal -offset indent
33044fdebe4Suwe/example/x -intr,nfsv4 192.168.1.1:/share/example/x
33144fdebe4Suwe/example/share -fstype=smbfs,-N ://@server/share
33244fdebe4Suwe/example/cd -fstype=cd9660 :/dev/cd0
333b985414bSchristos.Ed
334b985414bSchristos.Sh DIRECTORY SERVICES
335b985414bSchristosBoth
336b985414bSchristos.Nm
337b985414bSchristosand maps may contain entries consisting of a plus sign and map name:
338b985414bSchristos.Bd -literal -offset indent
33944fdebe4Suwe+auto_master
340b985414bSchristos.Ed
341b985414bSchristos.Pp
342b985414bSchristosThose entries cause
343b985414bSchristos.Xr automountd 8
344b985414bSchristosdaemon to retrieve the named map from directory services (like LDAP)
345b985414bSchristosand include it where the entry was.
346b985414bSchristos.Pp
347b985414bSchristosIf the file containing the map referenced in
348b985414bSchristos.Nm
349b985414bSchristosis not found, the map will be retrieved from directory services instead.
350b985414bSchristos.Pp
351b985414bSchristosTo retrieve entries from directory services,
352b985414bSchristos.Xr automountd 8
353b985414bSchristosdaemon runs
354b985414bSchristos.Pa /etc/autofs/include ,
355b985414bSchristoswhich is usually a shell script, with map name as the only command line
356b985414bSchristosparameter.
357b985414bSchristosThe script should output entries formatted according to
358b985414bSchristos.Nm
359b985414bSchristosor automounter map syntax to standard output.
360b985414bSchristosAn example script to use LDAP is included in
361b985414bSchristos.Pa /etc/autofs/include_ldap .
362b985414bSchristosIt can be symlinked to
363b985414bSchristos.Pa /etc/autofs/include .
364b985414bSchristos.Sh FILES
365b985414bSchristos.Bl -tag -width ".Pa /etc/auto_master" -compact
366b985414bSchristos.It Pa /etc/auto_master
367b985414bSchristosThe default location of the
368ad8c206fSuwe.Nm
369b985414bSchristosfile.
370b985414bSchristos.It Pa /etc/autofs/
371b985414bSchristosDirectory containing shell scripts to implement special maps and directory
372b985414bSchristosservices.
373b985414bSchristos.El
374b985414bSchristos.Sh SEE ALSO
375b985414bSchristos.Xr autofs 5 ,
376b985414bSchristos.Xr automount 8 ,
377b985414bSchristos.Xr automountd 8 ,
378b985414bSchristos.Xr autounmountd 8
379b985414bSchristos.Sh AUTHORS
38025223566Suwe.An -nosplit
381b985414bSchristosThe
382b985414bSchristos.Nm
383b985414bSchristosconfiguration file functionality was developed by
384b985414bSchristos.An Edward Tomasz Napierala Aq Mt trasz@FreeBSD.org
3853d7c1190Swizunder sponsorship from the
3863d7c1190Swiz.Fx
3873d7c1190SwizFoundation.
388b985414bSchristos.Pp
389b985414bSchristosThe
390b985414bSchristos.Nm
391b985414bSchristosconfiguration file functionality was ported to
392b985414bSchristos.Dx
393b985414bSchristosand
394b985414bSchristos.Nx
395b985414bSchristosby
396*b94e4467Stkusumi.An Tomohiro Kusumi Aq Mt tkusumi@netbsd.org .
397b985414bSchristos.Sh BUGS
39867dee3c7SwizThe
39967dee3c7Swiz.Li -media
40067dee3c7Swizspecial map is currently unsupported on
401b985414bSchristos.Nx .
402