xref: /illumos-gate/usr/src/man/man8/automount.8 (revision e27085df90712f99e5ea3d44ab0b83c73ac1bf52)
1.\"
2.\" The contents of this file are subject to the terms of the
3.\" Common Development and Distribution License (the "License").
4.\" You may not use this file except in compliance with the License.
5.\"
6.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7.\" or http://www.opensolaris.org/os/licensing.
8.\" See the License for the specific language governing permissions
9.\" and limitations under the License.
10.\"
11.\" When distributing Covered Code, include this CDDL HEADER in each
12.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
13.\" If applicable, add the following below this CDDL HEADER, with the
14.\" fields enclosed by brackets "[]" replaced with your own identifying
15.\" information: Portions Copyright [yyyy] [name of copyright owner]
16.\"
17.\"
18.\" Copyright 1989 AT&T
19.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved
20.\" Copyright 2017 Nexenta Systems, Inc.
21.\"
22.Dd February 25, 2017
23.Dt AUTOMOUNT 8
24.Os
25.Sh NAME
26.Nm automount
27.Nd install automatic mount points
28.Sh SYNOPSIS
29.Nm
30.Op Fl v
31.Op Fl t Ar duration
32.Sh DESCRIPTION
33The
34.Nm
35utility installs
36.Nm autofs
37mount points and associates an automount map with each mount point.
38It starts the
39.Xr automountd 8
40daemon if it finds any non-trivial entries in either local or distributed
41automount maps and if the daemon is not already running.
42The
43.Nm autofs
44file system monitors attempts to access directories within it and notifies the
45.Xr automountd 8
46daemon.
47The daemon uses the map to locate a file system, which it then mounts at the
48point of reference within the
49.Nm autofs
50file system.
51A map can be assigned to an
52.Nm autofs
53mount using an entry in the
54.Pa /etc/auto_master
55map or a direct map.
56.Pp
57If the file system is not accessed within an appropriate interval
58.Pq 10 minutes by default ,
59the
60.Nm automountd
61daemon unmounts the file system.
62.Pp
63The file
64.Pa /etc/auto_master
65determines the locations of all
66.Nm autofs
67mount points.
68By default, this file contains three entries:
69.Bd -literal -offset indent
70# Master map for automounter
71#
72+auto_master
73/net	-hosts -nosuid
74/home	auto_home
75.Ed
76.Pp
77The
78.Sy +auto_master
79entry is a reference to an external NIS master map.
80If one exists, then its entries are read as if they occurred in place of the
81.Sy +auto_master
82entry.
83The remaining entries in the master file specify a directory on which an
84.Nm autofs
85mount will be made followed by the automounter map to be associated with it.
86Optional mount options may be supplied as an optional third field in the each
87entry.
88These options are used for any entries in the map that do not specify mount
89options explicitly.
90The
91.Nm
92command is usually run without arguments.
93It compares the entries
94.Pa /etc/auto_master
95with the current list of
96.Nm autofs
97mounts in
98.Pa /etc/mnttab
99and adds, removes or updates
100.Nm autofs
101mounts to bring the
102.Pa /etc/mnttab
103up to date with the
104.Pa /etc/auto_master .
105At boot time it installs all
106.Nm autofs
107mounts from the master map.
108Subsequently, it may be run to install
109.Nm autofs
110mounts for new entries in the master map or the direct map, or to perform
111unmounts for entries that have been removed from these maps.
112.Ss Automount with Solaris Trusted Extensions
113If a system is configured with Solaris Trusted Extensions, additional
114processing is performed to facilitate multilevel home directory access.
115A list of zones whose labels are dominated by the current zone is generated and
116default
117.Sy auto_home
118automount maps are generated if they do not currently exist.
119These automount maps are named
120.Sy auto_home_ Ns Ar zonename ,
121where
122.Ar zonename
123is the name of each zone's lower-level zone.
124An
125.Nm autofs
126mount of each such
127.Sy auto_home
128map is then performed, regardless of whether it is explicitly or implicitly
129listed in the master map.
130Instead of
131.Nm autofs
132mounting the standard
133.Sy auto_home
134map, the zone uses an
135.Pa auto_home
136file appended with its own zone name.
137Each zone's
138.Sy auto_home
139map is uniquely named so that it can be maintained and shared by all zones using
140a common name server.
141.Pp
142By default, the home directories of lower-level zones are mounted read-only
143under
144.Pa /zone/ Ns Ar zonename Ns Pa /export/home
145when each zone is booted.
146The default
147.Sy auto_home_ Ns Ar zonename
148automount map specifies that path as the source directory for an
149.Nm lofs
150remount onto
151.Pa /zone/ Ns Ar zonename Ns Pa /home/ Ns Ar username .
152For example, the file
153.Pa auto_home_public ,
154as generated from a higher level zone would contain:
155.Bd -literal -offset indent
156+auto_home_public
157*	-fstype=lofs	:/zone/public/export/home/&
158.Ed
159.Pp
160When a home directory is referenced and the name does not match any other keys
161in the
162.Sy auto_home_public
163map, it will match this loopback mount specification.
164If this loopback match occurs and the name corresponds to a valid user whose
165home directory does not exist in the public zone, the directory is automatically
166created on behalf of the user.
167.Sh OPTIONS
168The following options are supported:
169.Bl -tag -width Ds
170.It Fl v
171Verbose mode.
172Notifies of
173.Nm autofs
174mounts, unmounts, or other non-essential information.
175.It Fl t Ar duration
176Specifies a
177.Ar duration ,
178in seconds, that a file system is to remain mounted when not in use.
179The default is
180.Sy 10
181minutes.
182.El
183.Sh USAGE
184.Ss Map Entry Format
185A simple map entry
186.Pq mapping
187takes the form:
188.Bd -literal -offset indent
189.Ar key Oo Fl Ns Ar mount-options Oc Ar location Ns ...
190.Ed
191.Pp
192where
193.Ar key
194is the full pathname of the directory to mount when used in a direct map, or the
195simple name of a subdirectory in an indirect map.
196.Ar mount-options
197is a comma-separated list of
198.Nm mount
199options, and
200.Ar location
201specifies a file system from which the directory may be mounted.
202In the case of a simple NFS mount, the options that can be used are specified in
203.Xr mount_nfs 8 ,
204and
205.Ar location
206takes the form:
207.Pp
208.Dl Ar host Ns \&: Ns Ar pathname
209.Pp
210.Ar host
211is the name of the host from which to mount the file system, and
212.Ar pathname
213is the absolute pathname of the directory to mount.
214.Pp
215Options to other file systems are documented in the other
216.Nm mount_*
217reference manual pages.
218.Ss Replicated File Systems
219Multiple
220.Ar location
221fields can be specified for replicated NFS file systems, in which case
222.Nm
223and the kernel will each try to use that information to increase availability.
224If the read-only flag is set in the map entry,
225.Nm automountd
226mounts a list of locations that the kernel may use, sorted by several criteria.
227Only locations available at mount time will be mounted, and thus be available to
228the kernel.
229When a server does not respond, the kernel will switch to an alternate server.
230The sort ordering of
231.Nm
232is used to determine how the next server is chosen.
233If the read-only flag is not set,
234.Nm
235will mount the best single location, chosen by the same sort ordering, and new
236servers will only be chosen when an unmount has been possible, and a remount is
237done.
238Servers on the same local subnet are given the strongest preference, and servers
239on the local net are given the second strongest preference.
240Among servers equally far away, response times will determine the order if no
241weighting factors
242.Pq see below
243are used.
244.Pp
245If the list includes server locations using both the NFS Version 2 Protocol and
246the NFS Version 3 Protocol,
247.Nm
248will choose only a subset of the server locations on the list, so that all
249entries will be the same protocol.
250It will choose servers with the NFS Version 3 Protocol so long as an NFS Version
2512 Protocol server on a local subnet will not be ignored.
252See the FIXME for additional details.
253.Pp
254If each
255.Ar location
256in the list shares the same
257.Ar pathname
258then a single
259.Ar location
260may be used with a comma-separated list of hostnames:
261.Bd -literal -offset indent
262.Ar hostname Ns \&, Ns Ar hostname Ns ...: Ns Ar pathname
263.Ed
264.Pp
265Requests for a server may be weighted, with the weighting factor appended to
266the server name as an integer in parentheses.
267Servers without a weighting are assumed to have a value of zero
268.Pq most likely to be selected .
269Progressively higher values decrease the chance of being selected.
270In the example,
271.Bd -literal -offset indent
272man -ro	alpha,bravo,charlie(1),delta(4):/usr/man
273.Ed
274.Pp
275hosts
276.Sy alpha
277and
278.Sy bravo
279have the highest priority; host
280.Sy delta
281has the lowest.
282.Pp
283Server proximity takes priority in the selection process.
284In the example above, if the server
285.Sy delta
286is on the same network segment as the client, but the others are on different
287network segments, then
288.Sy delta
289will be selected; the weighting value is ignored.
290The weighting has effect only when selecting between servers with the same
291network proximity.
292The automounter always selects the localhost over other servers on the same
293network segment, regardless of weighting.
294.Pp
295In cases where each server has a different export point, the weighting can
296still be applied.
297For example:
298.Bd -literal -offset indent
299man	-ro	alpha:/usr/man bravo,charlie(1):/usr/share/man \e
300		delta(3):/export/man
301.Ed
302.Pp
303A mapping can be continued across input lines by escaping the NEWLINE with a
304backslash
305.Pq Qq Sy \e .
306Comments begin with a number sign
307.Pq Qq Sy #
308and end at the subsequent NEWLINE.
309.Ss Map Key Substitution
310The ampersand
311.Pq Qq Sy \*(Am
312character is expanded to the value of the
313.Ar key
314field for the entry in which it occurs.
315In this case:
316.Bd -literal -offset indent
317jane	sparcserver:/home/&
318.Ed
319.Pp
320the
321.Sy \*(Am
322expands to
323.Sy jane .
324.Ss Wildcard Key
325The asterisk
326.Pq Qq Sy *
327character, when supplied as the
328.Ar key
329field, is recognized as the catch-all entry.
330Such an entry will match any key not previously matched.
331For instance, if the following entry appeared in the indirect map for
332.Pa /config :
333.Bd -literal -offset indent
334*	&:/export/config/&
335.Ed
336.Pp
337this would allow automatic mounts in
338.Pa /config
339of any remote file system whose location could be specified as:
340.Bd -literal -offset indent
341.Ar hostname Ns \&: Ns Pa /export/config/ Ns Ar hostname
342.Ed
343.Pp
344Note that the wildcard key does not work in conjunction with the
345.Fl browse
346option.
347.Ss Variable Substitution
348Client specific variables can be used within an
349.Nm
350map.
351For instance, if
352.Sy $HOST
353appeared within a map,
354.Nm
355would expand it to its current value for the client's host name.
356Supported variables are:
357.Bl -column "PLATFORM" "arch -k or uname -m"
358.It Sy NAME Ta Sy OUTPUT OF Ta Sy DESCRIPTION (EXAMPLE)
359.It Ev ARCH Ta Nm arch Ta architecture name Pq Qq Sy sun4
360.It Ev CPU Ta Nm uname Fl p Ta processor type Pq Qq Sy sparc
361.It Ev HOST Ta Nm uname Fl n Ta host name Pq Qq Sy myhost
362.It Ev KARCH Ta Nm arch Fl k No or Nm uname Fl m Ta kernel architecture name or
363machine hardware name
364.Pq Qq Sy sun4u
365.It Ev OSNAME Ta Nm uname Fl s Ta OS name Pq Qq Sy SunOS
366.It Ev OSREL Ta Nm name Fl r Ta OS release name Pq Qq Sy 5.3
367.It Ev OSVERS Ta Nm uname Fl v Ta OS version Pq Qq Sy beta1.0
368.It Ev NATISA Ta Nm isainfo Fl n Ta native instruction set architecture for the
369system
370.Pq Qq Sy sparcv9
371.It Ev PLATFORM Ta Nm uname Fl i Ta platform name Pq Qq Sy SUNW,Sun-Fire-V240
372.El
373.Pp
374If a reference needs to be protected from affixed characters, you can surround
375the variable name with curly braces
376.Pq Qq Sy \(lC Ns Sy \(rC .
377.Ss Multiple Mounts
378A multiple mount entry takes the form:
379.Bd -literal -offset indent
380.Ar key Oo Fl Ns Ar mount-options Oc Oo Oo Ar mountpoint Oc
381.Oo Fl Ns Ar mount-options Oc  Ar location Ns ... Oc Ns ...
382.Ed
383.Pp
384The initial
385.Ar mountpoint
386is optional for the first mount and mandatory for all subsequent mounts.
387The optional
388.Ar mountpoint
389is taken as a pathname relative to the directory named by
390.Ar key .
391If
392.Ar mountpoint
393is omitted in the first occurrence, a
394.Ar mountpoint
395of
396.Pa /
397.Pq root
398is implied.
399.Pp
400Given an entry in the indirect map for
401.Pa /src :
402.Bd -literal -offset indent
403beta	-ro \e
404	/		svr1,svr2:/export/src/beta  \e
405	/1.0		svr1,svr2:/export/src/beta/1.0 \e
406	/1.0/man	svr1,svr2:/export/src/beta/1.0/man
407.Ed
408.Pp
409All offsets must exist on the server under
410.Sy beta .
411.Nm
412will automatically mount
413.Pa /src/beta ,
414.Pa /src/beta/1.0 ,
415and
416.Pa /src/beta/1.0/man ,
417as needed, from either
418.Sy svr1
419or
420.Sy svr2 ,
421whichever host is nearest and responds first.
422.Ss Other File System Types
423The automounter assumes NFS mounts as a default file system type.
424Other file system types can be described using the
425.Sy fstype
426mount option.
427Other mount options specific to this file system type can be combined with the
428.Sy fstype
429option.
430The location field must contain information specific to the file system type.
431If the location field begins with a slash, a colon character must be prepended,
432for instance, to mount a CD file system:
433.Bd -literal -offset indent
434cdrom	-fstype=hsfs,ro	:/dev/sr0
435.Ed
436.Pp
437or to perform an
438.Nm autofs
439mount:
440.Bd -literal -offset indent
441src	-fstype=autofs	auto_src
442.Ed
443.Pp
444Use this procedure only if you are not using Volume Manager.
445.Pp
446See the
447.Sx NOTES
448section for information on option inheritance.
449.Ss Indirect Maps
450An indirect map allows you to specify mappings for the subdirectories you wish
451to mount under the
452.Ar directory
453indicated on the command line.
454In an indirect map, each
455.Ar key
456consists of a simple name that refers to one or more file systems that are to be
457mounted as needed.
458.Ss Direct Maps
459Entries in a direct map are associated directly with
460.Nm autofs
461mount points.
462Each
463.Ar key
464is the full pathname of an
465.Nm autofs
466mount point.
467The direct map as a whole is not associated with any single directory.
468.Pp
469Direct maps are distinguished from indirect maps by the
470.Sy \-
471key.
472For example:
473.Bd -literal -offset indent
474# Master map for automounter
475#
476+auto_master
477/net	-hosts		-nosuid,nobrowse
478/home	auto_home	-nobrowse
479/-	auto_direct
480.Ed
481.Ss Included Maps
482The contents of another map can be included within a map with an entry of the
483form
484.Bd -literal -offset indent
485.No + Ns Ar mapname
486.Ed
487.Pp
488If
489.Ar mapname
490begins with a slash, it is assumed to be the pathname of a local file.
491Otherwise, the location of the map is determined by the policy of the name
492service switch according to the entry for the automounter in
493.Pa /etc/nsswitch.conf ,
494such as
495.Bd -literal -offset indent
496automount: files nis
497.Ed
498.Pp
499If the name service is
500.Sy files ,
501then the name is assumed to be that of a local file in
502.Pa /etc .
503If the key being searched for is not found in the included map, the search
504continues with the next entry.
505.Ss Special Maps
506There are two special maps available:
507.Sy -hosts
508and
509.Sy -null .
510The
511.Sy -hosts
512map is used with the
513.Pa /net
514directory and assumes that the map key is the hostname of an NFS server.
515The
516.Nm automountd
517daemon dynamically constructs a map entry from the server's list of exported
518file systems.
519References to a directory under
520.Pa /net/hermes
521will refer to the corresponding directory relative to
522.Sy hermes
523root.
524.Pp
525The
526.Sy -null
527map cancels a previous map for the directory indicated.
528This is most useful in the
529.Pa /etc/auto_master
530for cancelling entries that would otherwise be inherited from the
531.Sy +auto_master
532include entry.
533To be effective, the
534.Sy -null
535entries must be inserted before the included map entry.
536.Ss Executable Maps
537Local maps that have the execute bit set in their file permissions will be
538executed by the automounter and provided with a key to be looked up as an
539argument.
540The executable map is expected to return the content of an automounter map entry
541on its stdout or no output if the entry cannot be determined.
542A direct map cannot be made executable.
543.Ss Configuration and the auto_master Map
544When initiated without arguments,
545.Nm
546consults the master map for a list of
547.Nm autofs
548mount points and their maps.
549It mounts any
550.Nm autofs
551mounts that are not already mounted, and unmounts
552.Nm autofs
553mounts that have been removed from the master map or direct map.
554.Pp
555The master map is assumed to be called
556.Sy auto_master
557and its location is determined by the name service switch policy.
558Normally the master map is located initially as a local file
559.Pa /etc/auto_master .
560.Ss Browsing
561The
562.Nm automountd
563daemon supports browsability of indirect maps.
564This allows all of the potential mount points to be visible, whether or not they
565are mounted.
566The
567.Sy -nobrowse
568option can be added to any indirect
569.Nm autofs
570map to disable browsing.
571For example:
572.Bd -literal -offset indent
573/net	-hosts		-nosuid,nobrowse
574/home	auto_home
575.Ed
576.Pp
577In this case, any
578.Ar hostname Ns s
579would only be visible in
580.Pa /net
581after they are mounted, but all potential mount points would be visible under
582.Pa /home .
583The
584.Sy -browse
585option enables browsability of
586.Nm autofs
587file systems.
588This is the default for all indirect maps.
589.Pp
590The
591.Sy -browse
592option does not work in conjunction with the wildcard key.
593.Ss Restricting Mount Maps
594Options specified for a map are used as the default options for all the entries
595in that map.
596They are ignored when map entries specify their own mount options.
597.Pp
598In some cases, however, it is desirable to force
599.Sy nosuid , nodevices , nosetuid ,
600or
601.Sy noexec
602for a complete mount map and its submounts.
603This can be done by specifying the additional mount option,
604.Sy -restrict .
605.Bd -literal -offset indent
606/home	auto_home	-restrict,nosuid,hard
607.Ed
608.Pp
609The
610.Sy -restrict
611option forces the inheritance of all the restrictive options
612.Sy nosuid , nodevices , nosetuid ,
613and
614.Sy noexec
615as well as the restrict option itself.
616In this particular example, the
617.Sy nosuid
618and
619.Sy restrict
620option are inherited but the
621.Sy hard
622option is not.
623The
624.Sy restrict
625option also prevents the execution of
626.Qq executable maps
627and is enforced for auto mounts established by programs with fewer than all
628privileges available in their zone.
629.Sh FILES
630.Bl -tag -width Ds
631.It Pa /etc/auto_master
632Master automount map.
633.It Pa /etc/auto_home
634Map to support automounted home directories.
635.It Pa /etc/nsswitch.conf
636Name service switch configuration file.
637See
638.Xr nsswitch.conf 5 .
639.El
640.Sh EXIT STATUS
641.Ex -std
642.Sh SEE ALSO
643.Xr isainfo 1 ,
644.Xr ls 1 ,
645.Xr svcs 1 ,
646.Xr uname 1 ,
647.Xr autofs 5 ,
648.Xr attributes 7 ,
649.Xr nfssec 7 ,
650.Xr smf 7 ,
651.Xr automountd 8 ,
652.Xr mount 8 ,
653.Xr mount_nfs 8 ,
654.Xr svcadm 8
655.Sh NOTES
656.Nm autofs
657mount points must not be hierarchically related.
658.Nm
659does not allow an
660.Nm autofs
661mount point to be created within another
662.Nm autofs
663mount.
664.Pp
665Since each direct map entry results in a new
666.Nm autofs
667mount such maps should be kept short.
668.Pp
669Entries in both direct and indirect maps can be modified at any time.
670The new information is used when
671.Nm automountd
672next uses the map entry to do a mount.
673.Pp
674New entries added to a master map or direct map will not be useful until the
675automount command is run to install them as new
676.Nm autofs
677mount points.
678New entries added to an indirect map may be used immediately.
679.Pp
680As of the Solaris 2.6 release, a listing
681.Po see
682.Xr ls 1
683.Pc
684of the
685.Nm autofs
686directory associated with an indirect map shows all potential mountable
687entries.
688The attributes associated with the potential mountable entries are temporary.
689The real file system attributes will only be shown once the file system has been
690mounted.
691.Pp
692Default mount options can be assigned to an entire map when specified as an
693optional third field in the master map.
694These options apply only to map entries that have no mount options.
695Note that map entities with options override the default options, as at this
696time, the options do not concatenate.
697The concatenation feature is planned for a future release.
698.Pp
699When operating on a map that invokes an NFS mount, the default number of
700retries for the automounter is 0, that is, a single mount attempt, with no
701retries.
702Note that this is significantly different from the default
703.Pq 10000
704for the
705.Xr mount_nfs 8
706utility.
707.Pp
708The Network Information Service
709.Pq NIS
710was formerly known as Sun Yellow Pages
711.Pq YP .
712The functionality of the two remains the same.
713.Pp
714The
715.Nm
716service is managed by the service management facility,
717.Xr smf 7 ,
718under the service identifier:
719.Bd -literal -offset indent
720svc:/system/filesystem/autofs:default
721.Ed
722.Pp
723Administrative actions on this service, such as enabling, disabling, or
724requesting restart, can be performed using
725.Xr svcadm 8 .
726The service's status can be queried using the
727.Xr svcs 1
728command.
729