xref: /freebsd/sbin/mount/mount.8 (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
1.\" Copyright (c) 1980, 1989, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd October 4, 2023
29.Dt MOUNT 8
30.Os
31.Sh NAME
32.Nm mount
33.Nd mount file systems
34.Sh SYNOPSIS
35.Nm
36.Op Fl -libxo
37.Op Fl adflpruvw
38.Op Fl F Ar fstab
39.Op Fl o Ar options
40.Op Fl t Oo Cm no Oc Ns Cm Ar type Ns Op Cm , Ns Ar type ...
41.Nm
42.Op Fl -libxo
43.Op Fl dfpruvw
44.Ar special | node
45.Nm
46.Op Fl -libxo
47.Op Fl dfpruvw
48.Op Fl o Ar options
49.Op Fl t Oo Cm no Oc Ns Cm Ar type Ns Op Cm , Ns Ar type ...
50.Ar special node
51.Sh DESCRIPTION
52The
53.Nm
54utility calls the
55.Xr nmount 2
56system call to prepare and graft a
57.Ar special
58device or the remote node (rhost:path) on to the file system tree 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
68The system maintains a list of currently mounted file systems.
69If no arguments are given to
70.Nm ,
71this list is printed.
72.Pp
73The options are as follows:
74.Bl -tag -width indent
75.It Fl -libxo
76Generate output via
77.Xr libxo 3
78in a selection of different human and machine readable formats.
79See
80.Xr xo_parse_args 3
81for details on command line arguments.
82.It Fl a
83All the file systems described in
84.Xr fstab 5
85are mounted.
86Exceptions are those marked as
87.Dq Li noauto ,
88those marked as
89.Dq Li late
90(unless the
91.Fl l
92option was specified),
93those excluded by the
94.Fl t
95flag (see below), or if they are already mounted (except the
96root file system which is always remounted to preserve
97traditional single user mode behavior).
98.It Fl d
99Causes everything to be done except for the actual system call.
100This option is useful in conjunction with the
101.Fl v
102flag to
103determine what the
104.Nm
105command is trying to do.
106.It Fl F Ar fstab
107Specify the
108.Pa fstab
109file to use.
110.It Fl f
111Forces the revocation of write access when trying to downgrade
112a file system mount status from read-write to read-only.
113Also
114forces the R/W mount of an unclean file system (dangerous; use with
115caution).
116.It Fl L
117When used in conjunction with the
118.Fl a
119option, mount
120.Em only
121those file systems which are marked as
122.Dq Li late .
123.It Fl l
124When used in conjunction with the
125.Fl a
126option, also mount those file systems which are marked as
127.Dq Li late .
128.It Fl n
129For compatibility with some other implementations, this flag is
130currently a no-op.
131.It Fl o
132Options are specified with a
133.Fl o
134flag followed by a comma separated string of options.
135In case of conflicting options being specified, the rightmost option
136takes effect.
137The following options are available:
138.Bl -tag -width indent
139.It Cm acls
140Enable POSIX.1e Access Control Lists, or ACLs, which can be customized via the
141.Xr setfacl 1
142and
143.Xr getfacl 1
144commands.
145This flag is mutually exclusive with
146.Cm nfsv4acls
147flag.
148.It Cm async
149All I/O to the file system should be done asynchronously.
150This is a
151.Em dangerous
152flag to set, since it does not guarantee that the file system structure
153on the disk will remain consistent.
154For this reason, the
155.Cm async
156flag should be used sparingly, and only when some data recovery
157mechanism is present.
158.It Cm automounted
159This flag indicates that the file system was mounted by
160.Xr automountd 8 .
161Automounted file systems are automatically unmounted by
162.Xr autounmountd 8 .
163.It Cm autoro
164Mount the file system read-write.
165If that fails with an error that suggests that the media could be read-only,
166then automatically try to mount the file system read-only.
167.It Cm current
168When used with the
169.Fl u
170flag, this is the same as specifying the options currently in effect for
171the mounted file system.
172.It Cm emptydir
173Require that the mount point directory be empty.
174.It Cm force
175The same as
176.Fl f ;
177forces the revocation of write access when trying to downgrade
178a file system mount status from read-write to read-only.
179Also
180forces the R/W mount of an unclean file system (dangerous; use with caution).
181.It Cm fstab
182When used with the
183.Fl u
184flag, this is the same as specifying all the options listed in the
185.Xr fstab 5
186file for the file system.
187.It Cm late
188This file system should be skipped when
189.Nm
190is run with the
191.Fl a
192flag but without the
193.Fl l
194flag.
195.It Cm mountprog Ns = Ns Aq Ar program
196Force
197.Nm
198to use the specified program to mount the file system, instead of calling
199.Xr nmount 2
200directly.
201For example:
202.Bd -literal
203mount -t foofs -o mountprog=/mydir/fooprog /dev/cd0 /mnt
204.Ed
205.It Cm multilabel
206Enable multi-label Mandatory Access Control, or MAC, on the specified file
207system.
208If the file system supports multilabel operation, individual labels will
209be maintained for each object in the file system, rather than using a
210single label for all objects.
211An alternative to the
212.Fl l
213flag in
214.Xr tunefs 8 .
215See
216.Xr mac 4
217for more information, which cause the multilabel mount flag to be set
218automatically at mount-time.
219.It Cm nfsv4acls
220Enable NFSv4 ACLs, which can be customized via the
221.Xr setfacl 1
222and
223.Xr getfacl 1
224commands.
225This flag is mutually exclusive with
226.Cm acls
227flag.
228.It Cm noasync
229Metadata I/O should be done synchronously, while data I/O should be done
230asynchronously.
231This is the default.
232.It Cm noatime
233Do not update the file access time when reading from a file.
234This option
235is useful on file systems where there are large numbers of files and
236performance is more critical than updating the file access time (which is
237rarely ever important).
238This option is currently only supported on local file systems.
239.It Cm noauto
240This file system should be skipped when
241.Nm
242is run with the
243.Fl a
244flag.
245.It Cm noclusterr
246Disable read clustering.
247.It Cm noclusterw
248Disable write clustering.
249.It Cm nocover
250Do not mount if the requested mount point is already
251the root of a mount point.
252.It Cm noexec
253Do not allow execution of any binaries on the mounted file system.
254This option is useful for a server that has file systems containing
255binaries for architectures other than its own.
256Note: This option was not designed as a security feature and no
257guarantee is made that it will prevent malicious code execution; for
258example, it is still possible to execute scripts which reside on a
259.Cm noexec
260mounted partition.
261.It Cm nosuid
262Do not allow set-user-identifier or set-group-identifier bits to take effect.
263Note: this option is worthless if a public available suid or sgid
264wrapper is installed on your system.
265It is set automatically when the user does not have super-user privileges.
266.It Cm nosymfollow
267Do not follow symlinks
268on the mounted file system.
269.It Cm ro
270The same as
271.Fl r ;
272mount the file system read-only (even the super-user may not write it).
273.It Cm snapshot
274Take a snapshot of the specified filesystem.
275When this option is used, all other options are ignored.
276The
277.Fl u
278flag is required with this option.
279.Pp
280Snapshot files must be created in the file system that is being
281snapshotted.
282You may create up to 20 snapshots per file system.
283Active snapshots are recorded in the superblock, so they persist across unmount
284and remount operations and across system reboots.
285When you are done with a snapshot, it can be removed with the
286.Xr rm 1
287command.
288Snapshots may be removed in any order, however you may not get back all the
289space contained in the snapshot as another snapshot may claim some of the blocks
290that it is releasing.
291Note that the schg flag is set on snapshots to ensure that not even the root
292user can write to them.
293The unlink command makes an exception for snapshot files in that it allows them
294to be removed even though they have the schg flag set, so it is not necessary to
295clear the schg flag before removing a snapshot file.
296.Pp
297Once you have taken a snapshot, there are three interesting things that you can
298do with it:
299.Pp
300.Bl -enum -compact
301.It
302Run
303.Xr fsck 8
304on the snapshot file.
305Assuming that the file system was clean when it was mounted, you should always
306get a clean (and unchanging) result from running fsck on the snapshot.
307This is essentially what the background fsck process does.
308.Pp
309.It
310Run
311.Xr dump 8
312on the snapshot.
313You will get a dump that is consistent with the file system as of the timestamp
314of the snapshot.
315.Pp
316.It
317Mount the snapshot as a frozen image of the file system.
318To mount the snapshot
319.Pa /var/snapshot/snap1 :
320.Bd -literal
321mdconfig -a -t vnode -f /var/snapshot/snap1 -u 4
322mount -r /dev/md4 /mnt
323.Ed
324.Pp
325You can now cruise around your frozen
326.Pa /var
327file system at
328.Pa /mnt .
329Everything will be in the same state that it was at the time the snapshot was
330taken.
331The one exception is that any earlier snapshots will appear as zero length
332files.
333When you are done with the mounted snapshot:
334.Bd -literal
335umount /mnt
336mdconfig -d -u 4
337.Ed
338.El
339.It Cm suiddir
340A directory on the mounted file system will respond to the SUID bit
341being set, by setting the owner of any new files to be the same
342as the owner of the directory.
343New directories will inherit the bit from their parents.
344Execute bits are removed from
345the file, and it will not be given to root.
346.Pp
347This feature is designed for use on fileservers serving PC users via
348ftp, SAMBA, or netatalk.
349It provides security holes for shell users and as
350such should not be used on shell machines, especially on home directories.
351This option requires the SUIDDIR
352option in the kernel to work.
353Only UFS file systems support this option.
354See
355.Xr chmod 2
356for more information.
357.It Cm sync
358All I/O to the file system should be done synchronously.
359.It Cm update
360The same as
361.Fl u ;
362indicate that the status of an already mounted file system should be changed.
363.It Cm union
364Causes the namespace at the mount point to appear as the union
365of the mounted file system root and the existing directory.
366Lookups will be done in the mounted file system first.
367If those operations fail due to a non-existent file the underlying
368directory is then accessed.
369All creates are done in the mounted file system.
370.It Cm untrusted
371The file system is untrusted and the kernel should use more
372extensive checks on the file-system's metadata before using it.
373This option is intended to be used when mounting file systems
374from untrusted media such as USB memory sticks or other
375externally-provided media.
376.El
377.Pp
378Any additional options specific to a file system type that is not
379one of the internally known types (see the
380.Fl t
381option) may be passed as a comma separated list; these options are
382distinguished by a leading
383.Dq \&-
384(dash).
385For example, the
386.Nm
387command:
388.Bd -literal -offset indent
389mount -t cd9660 -o -e /dev/cd0 /cdrom
390.Ed
391.Pp
392causes
393.Nm
394to execute the equivalent of:
395.Bd -literal -offset indent
396/sbin/mount_cd9660 -e /dev/cd0 /cdrom
397.Ed
398.Pp
399Options that take a value are specified using the -option=value syntax:
400.Bd -literal -offset indent
401mount -t msdosfs -o -u=fred,-g=wheel /dev/da0s1 /mnt
402.Ed
403.Pp
404is equivalent to
405.Bd -literal -offset indent
406/sbin/mount_msdosfs -u fred -g wheel /dev/da0s1 /mnt
407.Ed
408.Pp
409Additional options specific to file system types
410which are not internally known
411(see the description of the
412.Fl t
413option below)
414may be described in the manual pages for the associated
415.Pa /sbin/mount_ Ns Sy XXX
416utilities.
417.It Fl p
418Print mount information in
419.Xr fstab 5
420format.
421Implies also the
422.Fl v
423option.
424.It Fl r
425The file system is to be mounted read-only.
426Mount the file system read-only (even the super-user may not write it).
427The same as the
428.Cm ro
429argument to the
430.Fl o
431option.
432.It Fl t Oo Cm no Oc Ns Cm Ar type Ns Op Cm , Ns Ar type ...
433The argument following the
434.Fl t
435is used to indicate the file system type.
436The type
437.Cm ufs
438is the default.
439The
440.Fl t
441option can be used
442to indicate that the actions should only be taken on
443file systems of the specified type.
444More than one type may be specified in a comma separated list.
445The list of file system types can be prefixed with
446.Cm no
447to specify the file system types for which action should
448.Em not
449be taken.
450For example, the
451.Nm
452command:
453.Bd -literal -offset indent
454mount -a -t nonfs,nullfs
455.Ed
456.Pp
457mounts all file systems except those of type NFS and NULLFS.
458.Pp
459The default behavior of
460.Nm
461is to pass the
462.Fl t
463option directly to the
464.Xr nmount 2
465system call in the
466.Li fstype
467option.
468.Pp
469However, for the following file system types:
470.Cm cd9660 ,
471.Cm mfs ,
472.Cm msdosfs ,
473.Cm nfs ,
474.Cm nullfs ,
475.Cm smbfs ,
476.Cm udf ,
477and
478.Cm unionfs
479.Nm
480will not call
481.Xr nmount 2
482directly and will instead attempt to execute a program in
483.Pa /sbin/mount_ Ns Ar type
484where
485.Ar type
486is replaced by the file system type name.
487For example,
488.Cm nfs
489file systems are mounted by the program
490.Pa /sbin/mount_nfs .
491.Pp
492Most file systems will be dynamically loaded by the kernel
493if not already present, and if the kernel module is available.
494.It Fl u
495The
496.Fl u
497flag indicates that the status of an already mounted file
498system should be changed.
499Any of the options discussed above (the
500.Fl o
501option)
502may be changed;
503also a file system can be changed from read-only to read-write
504or vice versa.
505An attempt to change from read-write to read-only will fail if any
506files on the file system are currently open for writing unless the
507.Fl f
508flag is also specified.
509The set of options is determined by applying the options specified
510in the argument to
511.Fl o
512and finally applying the
513.Fl r
514or
515.Fl w
516option.
517.It Fl v
518Verbose mode.
519If the
520.Fl v
521is used alone, show all file systems, including those that were mounted with the
522.Dv MNT_IGNORE
523flag and show additional information about each file system (including fsid
524when run by root).
525.It Fl w
526The file system object is to be read and write.
527.El
528.Sh ENVIRONMENT
529.Bl -tag -width ".Ev PATH_FSTAB"
530.It Ev PATH_FSTAB
531If the environment variable
532.Ev PATH_FSTAB
533is set, all operations are performed against the specified file.
534.Ev PATH_FSTAB
535will not be honored if the process environment or memory address space is
536considered
537.Dq tainted .
538(See
539.Xr issetugid 2
540for more information.)
541.El
542.Sh FILES
543.Bl -tag -width /etc/fstab -compact
544.It Pa /etc/fstab
545file system table
546.El
547.Sh DIAGNOSTICS
548Various, most of them are self-explanatory.
549.Pp
550.Dl XXXXX file system is not available
551.Pp
552The kernel does not support the respective file system type.
553Note that
554support for a particular file system might be provided either on a static
555(kernel compile-time), or dynamic basis (loaded as a kernel module by
556.Xr kldload 8 ) .
557.Sh SEE ALSO
558.Xr getfacl 1 ,
559.Xr setfacl 1 ,
560.Xr nmount 2 ,
561.Xr acl 3 ,
562.Xr libxo 3 ,
563.Xr xo_parse_args 3 ,
564.Xr mac 4 ,
565.Xr cd9660 5 ,
566.Xr devfs 5 ,
567.Xr ext2fs 5 ,
568.Xr fstab 5 ,
569.Xr procfs 5 ,
570.Xr tarfs 5 ,
571.Xr tmpfs 5 ,
572.Xr automount 8 ,
573.Xr fstyp 8 ,
574.Xr kldload 8 ,
575.Xr mount_cd9660 8 ,
576.Xr mount_msdosfs 8 ,
577.Xr mount_nfs 8 ,
578.Xr mount_nullfs 8 ,
579.Xr mount_smbfs 8 ,
580.Xr mount_udf 8 ,
581.Xr mount_unionfs 8 ,
582.Xr umount 8 ,
583.Xr zfs 8 ,
584.Xr zpool 8
585.Sh HISTORY
586A
587.Nm
588utility appeared in
589.At v1 .
590.Sh CAVEATS
591After a successful
592.Nm ,
593the permissions on the original mount point determine if
594.Pa ..\&
595is accessible from the mounted file system.
596The minimum permissions for
597the mount point for traversal across the mount point in both
598directions to be possible for all users is 0111 (execute for all).
599.Pp
600Use of the
601.Nm
602is preferred over the use of the file system specific
603.Pa mount_ Ns Sy XXX
604commands.
605In particular,
606.Xr mountd 8
607gets a
608.Dv SIGHUP
609signal (that causes an update of the export list)
610only when the file system is mounted via
611.Nm .
612.Sh BUGS
613It is possible for a corrupted file system to cause a crash.
614