xref: /openbsd/sbin/mount/mount.8 (revision 09467b48)
1.\"	$OpenBSD: mount.8,v 1.90 2019/03/10 14:42:21 schwarze Exp $
2.\"	$NetBSD: mount.8,v 1.11 1995/07/12 06:23:21 cgd Exp $
3.\"
4.\" Copyright (c) 1980, 1989, 1991, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"     @(#)mount.8	8.7 (Berkeley) 3/27/94
32.\"
33.Dd $Mdocdate: March 10 2019 $
34.Dt MOUNT 8
35.Os
36.Sh NAME
37.Nm mount
38.Nd mount file systems
39.Sh SYNOPSIS
40.Nm mount
41.Op Fl AadfNruvw
42.Op Fl t Ar type
43.Nm mount
44.Op Fl dfrsuvw
45.Ar special | node
46.Nm mount
47.Op Fl dfruvw
48.Op Fl o Ar options
49.Op Fl t Ar type
50.Ar special node
51.Sh DESCRIPTION
52The
53.Nm
54command invokes a file system specific program to prepare
55and graft the
56.Ar special
57device or remote node (rhost:path) on to the file system
58tree at the point
59.Ar node .
60If either
61.Ar special
62or
63.Ar node
64are not provided, the appropriate information is taken from the
65.Xr fstab 5
66file.
67.Pp
68For disk partitions, the
69.Ar special
70device is either a
71.Xr disklabel 8
72UID (DUID) or an entry in
73.Pa /dev .
74If it is a DUID,
75it will be automatically mapped to the appropriate entry in
76.Pa /dev .
77In either case the partition must be present
78in the disklabel loaded from the device.
79The partition name is the last letter in the entry name.
80For example, /dev/sd0a and 3eb7f9da875cb9ee.a both refer to the
81.Sq a
82partition.
83.Pp
84A mount point
85.Ar node
86must be an existing directory for a mount to succeed
87.Po
88except in the special case of
89.Pa / ,
90of course
91.Pc .
92Only the superuser may mount file systems.
93.Pp
94The system maintains a list of currently mounted file systems.
95If no arguments are given to
96.Nm mount ,
97this list is printed.
98.Pp
99The options are as follows:
100.Bl -tag -width Ds
101.It Fl A
102Causes
103.Nm
104to try to mount all of the file systems listed in the
105.Xr fstab 5
106table except those for which the
107.Dq noauto
108or
109.Dq net
110options are specified.
111.It Fl a
112Similar to the
113.Fl A
114flag, except that if a file system (other than the root file system)
115appears to be already mounted,
116.Nm
117will not try to mount it again.
118.Nm
119assumes that a file system is already mounted if a file system with
120the same type is mounted on the given mount point.
121More stringent checks are not possible because some file system types
122report strange values for the mounted-from device for mounted file
123systems.
124.It Fl d
125Causes everything to be done except for the invocation of
126the file system specific program.
127This option is useful in conjunction with the
128.Fl v
129flag to
130determine what the
131.Nm
132command is trying to do.
133.It Fl f
134Either force mounting of dirty file systems or, in the case of a
135downgrade from read-write to read-only operation, the revocation of
136opened files with write access.
137.It Fl N
138If used with either
139.Fl A
140or
141.Fl a ,
142.Nm
143will only look at file systems which have the
144.Dq net
145option specified.
146By default file systems with the
147.Dq net
148option are ignored.
149.It Fl o Ar options
150Options can be given with (or without) a
151.Sq no
152prefix to invert their meaning.
153The options listed below specify non-default values.
154For example,
155.Sq nosoftdep
156is the default, so
157.Sq softdep
158can be used to mount the file system using soft dependencies.
159Multiple options can be specified in a comma-separated list.
160The available options are as follows:
161.Bl -tag -width 9n
162.It Cm async
163Metadata I/O to the file system should be done asynchronously.
164By default, only regular data is read/written asynchronously.
165.Pp
166This is a
167.Em dangerous
168flag to set since it does not guarantee to keep a consistent
169file system structure on the disk.
170You should not use this flag
171unless you are prepared to recreate the file system should your
172system crash.
173The most common use of this flag is to speed up
174.Xr restore 8
175where it can give a factor of two speed increase.
176.Pp
177The options
178.Ic async
179and
180.Ic softdep
181are mutually exclusive.
182.It Cm force
183The same as
184.Fl f ;
185forces the revocation of write access when trying to downgrade
186a file system mount status from read-write to read-only.
187.It Cm noatime
188Do not update atime on files in the system unless the mtime or ctime
189is being changed as well.
190This option is useful for laptops and news servers where one does
191not want the extra disk activity associated with updating the atime.
192.It Cm nodev
193Do not interpret character or block special devices on the file system.
194This option is useful for a server that has file systems containing
195special devices for architectures other than its own.
196.It Cm noexec
197Do not allow execution of any binaries on the mounted file system.
198This option is useful for a server that has file systems containing
199binaries for architectures other than its own.
200.It Cm noperm
201(FFS only)
202Do not check permissions when creating, accessing or modifying files and
203directories in the mounted file system.
204This allows unprivileged users to construct a file hierarchy containing
205special device nodes and files with arbitrary file mode, owner or group
206without restriction.
207Only the owner, group and mode of the root directory of the filesystem
208will be honored so access to the filesystem can be locked down.
209The noperm option also enables the nodev and noexec options to ensure
210that interpretation of the file modes and special devices cannot be
211used to gain privileges.
212.It Cm norw
213An alias for rdonly.
214.It Cm nosuid
215Do not allow set-user-identifier or set-group-identifier bits to take effect.
216.It Cm rdonly
217The same as
218.Fl r ;
219mount the file system read-only (even the superuser may not write it).
220.It Cm ro
221An alias for rdonly.
222.It Cm softdep
223(FFS only)
224Mount the file system using soft dependencies.
225Instead of metadata being written immediately, it is written in an ordered
226fashion to keep the on-disk state of the file system consistent.
227This results in significant speedups for file create/delete operations.
228This option is ignored when using the
229.Fl u
230flag and a file system is already mounted read/write.
231.Pp
232The options
233.Ic async
234and
235.Ic softdep
236are mutually exclusive.
237.It Cm sync
238Regular data I/O to the file system should be done synchronously.
239By default, only metadata is read/written synchronously.
240.It Cm update
241The same as
242.Fl u ;
243indicate that the status of an already mounted file system should be changed.
244.It Cm wxallowed
245Processes that ask for memory to be made writeable plus executable
246using the
247.Xr mmap 2
248and
249.Xr mprotect 2
250system calls are killed by default.
251This option allows those processes to continue operation.
252It is typically used on the
253.Pa /usr/local
254filesystem.
255.El
256.Pp
257Any additional options specific to a given file system type (see the
258.Fl t
259option) may be passed as a comma separated list; these options are
260distinguished by a leading
261.Dq \&-
262(dash).
263Options that take a value are specified using the syntax -option=value.
264For example:
265.Bd -literal -offset 3n
266# mount -t mfs -o rw,nodev,nosuid,-s=153600 /dev/sd0b /tmp
267.Ed
268.Pp
269That causes
270.Nm
271to execute the equivalent of:
272.Bd -literal -offset 3n
273# /sbin/mount_mfs -o rw,nodev,nosuid -s 153600 /dev/sd0b /tmp
274.Ed
275.Pp
276The equivalent example in
277.Xr fstab 5
278would be:
279.Bd -literal -offset 3n
280swap /tmp mfs rw,nodev,nosuid,-s=153600 0 0
281.Ed
282.It Fl r
283The file system is to be mounted read-only.
284Mount the file system read-only (even the superuser may not write it).
285The same as the
286.Dq rdonly
287argument to the
288.Fl o
289option.
290.It Fl s
291Skip mounting the file system if it is already mounted.
292See the
293.Fl a
294flag for a description of the criteria used to decide if a file system
295is already mounted.
296.It Fl t Ar type
297The argument following the
298.Fl t
299is used to indicate the file system type.
300The type
301.Ar ffs
302is the default.
303The
304.Fl t
305option can be used
306to indicate that the actions should only be taken on
307file systems of the specified type.
308More than one type may be specified in a comma separated list.
309The list of file system types can be prefixed with
310.Dq no
311to specify the file system types for which action should
312.Em not
313be taken.
314For example, the
315.Nm
316command:
317.Bd -literal -offset indent
318# mount -a -t nonfs,mfs
319.Ed
320.Pp
321mounts all file systems except those of type NFS and MFS.
322.Pp
323.Nm
324will attempt to execute a program in
325.Pa /sbin/mount_ Ns Em XXX
326where
327.Em XXX
328is replaced by the type name.
329For example, NFS file systems are mounted by the program
330.Pa /sbin/mount_nfs .
331.It Fl u
332The
333.Fl u
334flag indicates that the status of an already mounted file
335system should be changed.
336Any of the options discussed above (the
337.Fl o
338option)
339may be changed;
340also a file system can be changed from read-only to read-write
341or vice versa.
342An attempt to change from read-write to read-only will fail if any
343files on the file system are currently open for writing unless the
344.Fl f
345flag is also specified.
346Only options specified on the command line with
347.Fl o
348are changed;
349other file system options are unaltered.
350The options set in the
351.Xr fstab 5
352table are ignored.
353.It Fl v
354Verbose mode.
355.It Fl w
356The file system object is to be read and write.
357.El
358.Pp
359The options specific to the various file system types are
360described in the manual pages for those file systems'
361.Nm mount_XXX
362commands.
363For instance, the options specific to Berkeley
364Fast File Systems are described in the
365.Xr mount_ffs 8
366manual page.
367.Sh FILES
368.Bl -tag -width /etc/fstab -compact
369.It Pa /etc/fstab
370file system table
371.El
372.Sh EXAMPLES
373Mount a CD-ROM on node
374.Pa /mnt/cdrom :
375.Pp
376.Dl # mount -t cd9660 -r /dev/cd0a /mnt/cdrom
377.Pp
378Mount an MS-DOS USB stick with DUID 3eb7f9da875cb9ee on node
379.Pa /mnt/key :
380.Pp
381.Dl # mount -t msdos 3eb7f9da875cb9ee.i /mnt/key
382.Pp
383Graft a remote NFS file system on host
384.Ar host ,
385path
386.Pa /path/name ,
387on node
388.Pa /mnt/nfs :
389.Pp
390.Dl # mount host:/path/name /mnt/nfs
391.Pp
392Remount
393.Pa /var
394with option
395.Dq dev :
396.Pp
397.Dl # mount -u -o dev /var
398.Sh SEE ALSO
399.Xr mount 2 ,
400.Xr fstab 5 ,
401.Xr disklabel 8 ,
402.Xr mount_cd9660 8 ,
403.Xr mount_ext2fs 8 ,
404.Xr mount_ffs 8 ,
405.Xr mount_mfs 8 ,
406.Xr mount_msdos 8 ,
407.Xr mount_nfs 8 ,
408.Xr mount_ntfs 8 ,
409.Xr mount_tmpfs 8 ,
410.Xr mount_udf 8 ,
411.Xr mount_vnd 8 ,
412.Xr sysctl 8 ,
413.Xr umount 8
414.Sh HISTORY
415A
416.Nm
417command appeared in
418.At v1 .
419.Sh CAVEATS
420After a successful
421.Nm mount ,
422the permissions on the original mount point determine if
423.Dq \&.\&.
424is accessible from the mounted file system.
425The minimum permissions for
426the mount point for traversal across the mount point in both
427directions to be possible for all users is 0111 (execute for all).
428