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