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