xref: /freebsd/sbin/mount/mount.8 (revision bc7512cc58af2e8bbe5bbf5ca0059b1daa1da897)
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.\"     @(#)mount.8	8.8 (Berkeley) 6/16/94
29.\" $FreeBSD$
30.\"
31.Dd March 17, 2022
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 Cm Ar type Ns Op Cm , 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 Cm Ar type Ns Op Cm , 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_parse_args 3
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 automounted
162This flag indicates that the file system was mounted by
163.Xr automountd 8 .
164Automounted file systems are automatically unmounted by
165.Xr autounmountd 8 .
166.It Cm autoro
167Mount the file system read-write.
168If that fails with an error that suggests that the media could be read-only,
169then automatically try to mount the file system read-only.
170.It Cm current
171When used with the
172.Fl u
173flag, this is the same as specifying the options currently in effect for
174the mounted file system.
175.It Cm emptydir
176Require that the mount point directory be empty.
177.It Cm force
178The same as
179.Fl f ;
180forces the revocation of write access when trying to downgrade
181a file system mount status from read-write to read-only.
182Also
183forces the R/W mount of an unclean file system (dangerous; use with caution).
184.It Cm fstab
185When used with the
186.Fl u
187flag, this is the same as specifying all the options listed in the
188.Xr fstab 5
189file for the file system.
190.It Cm late
191This file system should be skipped when
192.Nm
193is run with the
194.Fl a
195flag but without the
196.Fl l
197flag.
198.It Cm mountprog Ns = Ns Aq Ar program
199Force
200.Nm
201to use the specified program to mount the file system, instead of calling
202.Xr nmount 2
203directly.
204For example:
205.Bd -literal
206mount -t foofs -o mountprog=/mydir/fooprog /dev/cd0 /mnt
207.Ed
208.It Cm multilabel
209Enable multi-label Mandatory Access Control, or MAC, on the specified file
210system.
211If the file system supports multilabel operation, individual labels will
212be maintained for each object in the file system, rather than using a
213single label for all objects.
214An alternative to the
215.Fl l
216flag in
217.Xr tunefs 8 .
218See
219.Xr mac 4
220for more information, which cause the multilabel mount flag to be set
221automatically at mount-time.
222.It Cm nfsv4acls
223Enable NFSv4 ACLs, which can be customized via the
224.Xr setfacl 1
225and
226.Xr getfacl 1
227commands.
228This flag is mutually exclusive with
229.Cm acls
230flag.
231.It Cm noasync
232Metadata I/O should be done synchronously, while data I/O should be done
233asynchronously.
234This is the default.
235.It Cm noatime
236Do not update the file access time when reading from a file.
237This option
238is useful on file systems where there are large numbers of files and
239performance is more critical than updating the file access time (which is
240rarely ever important).
241This option is currently only supported on local file systems.
242.It Cm noauto
243This file system should be skipped when
244.Nm
245is run with the
246.Fl a
247flag.
248.It Cm noclusterr
249Disable read clustering.
250.It Cm noclusterw
251Disable write clustering.
252.It Cm nocover
253Do not mount if the requested mount point is already
254the root of a mount point.
255.It Cm noexec
256Do not allow execution of any binaries on the mounted file system.
257This option is useful for a server that has file systems containing
258binaries for architectures other than its own.
259Note: This option was not designed as a security feature and no
260guarantee is made that it will prevent malicious code execution; for
261example, it is still possible to execute scripts which reside on a
262.Cm noexec
263mounted partition.
264.It Cm nosuid
265Do not allow set-user-identifier or set-group-identifier bits to take effect.
266Note: this option is worthless if a public available suid or sgid
267wrapper like
268.Xr suidperl 1
269is installed on your system.
270It is set automatically when the user does not have super-user privileges.
271.It Cm nosymfollow
272Do not follow symlinks
273on the mounted file system.
274.It Cm ro
275The same as
276.Fl r ;
277mount the file system read-only (even the super-user may not write it).
278.It Cm snapshot
279Take a snapshot of the specified filesystem.
280When this option is used, all other options are ignored.
281The
282.Fl u
283flag is required with this option.
284.Pp
285Snapshot files must be created in the file system that is being
286snapshotted.
287You may create up to 20 snapshots per file system.
288Active snapshots are recorded in the superblock, so they persist across unmount
289and remount operations and across system reboots.
290When you are done with a snapshot, it can be removed with the
291.Xr rm 1
292command.
293Snapshots may be removed in any order, however you may not get back all the
294space contained in the snapshot as another snapshot may claim some of the blocks
295that it is releasing.
296Note that the schg flag is set on snapshots to ensure that not even the root
297user can write to them.
298The unlink command makes an exception for snapshot files in that it allows them
299to be removed even though they have the schg flag set, so it is not necessary to
300clear the schg flag before removing a snapshot file.
301.Pp
302Once you have taken a snapshot, there are three interesting things that you can
303do with it:
304.Pp
305.Bl -enum -compact
306.It
307Run
308.Xr fsck 8
309on the snapshot file.
310Assuming that the file system was clean when it was mounted, you should always
311get a clean (and unchanging) result from running fsck on the snapshot.
312This is essentially what the background fsck process does.
313.Pp
314.It
315Run
316.Xr dump 8
317on the snapshot.
318You will get a dump that is consistent with the file system as of the timestamp
319of the snapshot.
320.Pp
321.It
322Mount the snapshot as a frozen image of the file system.
323To mount the snapshot
324.Pa /var/snapshot/snap1 :
325.Bd -literal
326mdconfig -a -t vnode -f /var/snapshot/snap1 -u 4
327mount -r /dev/md4 /mnt
328.Ed
329.Pp
330You can now cruise around your frozen
331.Pa /var
332file system at
333.Pa /mnt .
334Everything will be in the same state that it was at the time the snapshot was
335taken.
336The one exception is that any earlier snapshots will appear as zero length
337files.
338When you are done with the mounted snapshot:
339.Bd -literal
340umount /mnt
341mdconfig -d -u 4
342.Ed
343.El
344.It Cm suiddir
345A directory on the mounted file system will respond to the SUID bit
346being set, by setting the owner of any new files to be the same
347as the owner of the directory.
348New directories will inherit the bit from their parents.
349Execute bits are removed from
350the file, and it will not be given to root.
351.Pp
352This feature is designed for use on fileservers serving PC users via
353ftp, SAMBA, or netatalk.
354It provides security holes for shell users and as
355such should not be used on shell machines, especially on home directories.
356This option requires the SUIDDIR
357option in the kernel to work.
358Only UFS file systems support this option.
359See
360.Xr chmod 2
361for more information.
362.It Cm sync
363All I/O to the file system should be done synchronously.
364.It Cm update
365The same as
366.Fl u ;
367indicate that the status of an already mounted file system should be changed.
368.It Cm union
369Causes the namespace at the mount point to appear as the union
370of the mounted file system root and the existing directory.
371Lookups will be done in the mounted file system first.
372If those operations fail due to a non-existent file the underlying
373directory is then accessed.
374All creates are done in the mounted file system.
375.It Cm untrusted
376The file system is untrusted and the kernel should use more
377extensive checks on the file-system's metadata before using it.
378This option is intended to be used when mounting file systems
379from untrusted media such as USB memory sticks or other
380externally-provided media.
381.El
382.Pp
383Any additional options specific to a file system type that is not
384one of the internally known types (see the
385.Fl t
386option) may be passed as a comma separated list; these options are
387distinguished by a leading
388.Dq \&-
389(dash).
390For example, the
391.Nm
392command:
393.Bd -literal -offset indent
394mount -t cd9660 -o -e /dev/cd0 /cdrom
395.Ed
396.Pp
397causes
398.Nm
399to execute the equivalent of:
400.Bd -literal -offset indent
401/sbin/mount_cd9660 -e /dev/cd0 /cdrom
402.Ed
403.Pp
404Options that take a value are specified using the -option=value syntax:
405.Bd -literal -offset indent
406mount -t msdosfs -o -u=fred,-g=wheel /dev/da0s1 /mnt
407.Ed
408.Pp
409is equivalent to
410.Bd -literal -offset indent
411/sbin/mount_msdosfs -u fred -g wheel /dev/da0s1 /mnt
412.Ed
413.Pp
414Additional options specific to file system types
415which are not internally known
416(see the description of the
417.Fl t
418option below)
419may be described in the manual pages for the associated
420.Pa /sbin/mount_ Ns Sy XXX
421utilities.
422.It Fl p
423Print mount information in
424.Xr fstab 5
425format.
426Implies also the
427.Fl v
428option.
429.It Fl r
430The file system is to be mounted read-only.
431Mount the file system read-only (even the super-user may not write it).
432The same as the
433.Cm ro
434argument to the
435.Fl o
436option.
437.It Fl t Oo Cm no Oc Ns Cm Ar type Ns Op Cm , Ns Ar type ...
438The argument following the
439.Fl t
440is used to indicate the file system type.
441The type
442.Cm ufs
443is the default.
444The
445.Fl t
446option can be used
447to indicate that the actions should only be taken on
448file systems of the specified type.
449More than one type may be specified in a comma separated list.
450The list of file system types can be prefixed with
451.Cm no
452to specify the file system types for which action should
453.Em not
454be taken.
455For example, the
456.Nm
457command:
458.Bd -literal -offset indent
459mount -a -t nonfs,nullfs
460.Ed
461.Pp
462mounts all file systems except those of type NFS and NULLFS.
463.Pp
464The default behavior of
465.Nm
466is to pass the
467.Fl t
468option directly to the
469.Xr nmount 2
470system call in the
471.Li fstype
472option.
473.Pp
474However, for the following file system types:
475.Cm cd9660 ,
476.Cm mfs ,
477.Cm msdosfs ,
478.Cm nfs ,
479.Cm nullfs ,
480.Cm smbfs ,
481.Cm udf ,
482and
483.Cm unionfs
484.Nm
485will not call
486.Xr nmount 2
487directly and will instead attempt to execute a program in
488.Pa /sbin/mount_ Ns Ar type
489where
490.Ar type
491is replaced by the file system type name.
492For example,
493.Cm nfs
494file systems are mounted by the program
495.Pa /sbin/mount_nfs .
496.Pp
497Most file systems will be dynamically loaded by the kernel
498if not already present, and if the kernel module is available.
499.It Fl u
500The
501.Fl u
502flag indicates that the status of an already mounted file
503system should be changed.
504Any of the options discussed above (the
505.Fl o
506option)
507may be changed;
508also a file system can be changed from read-only to read-write
509or vice versa.
510An attempt to change from read-write to read-only will fail if any
511files on the file system are currently open for writing unless the
512.Fl f
513flag is also specified.
514The set of options is determined by applying the options specified
515in the argument to
516.Fl o
517and finally applying the
518.Fl r
519or
520.Fl w
521option.
522.It Fl v
523Verbose mode.
524If the
525.Fl v
526is used alone, show all file systems, including those that were mounted with the
527.Dv MNT_IGNORE
528flag and show additional information about each file system (including fsid
529when run by root).
530.It Fl w
531The file system object is to be read and write.
532.El
533.Sh ENVIRONMENT
534.Bl -tag -width ".Ev PATH_FSTAB"
535.It Ev PATH_FSTAB
536If the environment variable
537.Ev PATH_FSTAB
538is set, all operations are performed against the specified file.
539.Ev PATH_FSTAB
540will not be honored if the process environment or memory address space is
541considered
542.Dq tainted .
543(See
544.Xr issetugid 2
545for more information.)
546.El
547.Sh FILES
548.Bl -tag -width /etc/fstab -compact
549.It Pa /etc/fstab
550file system table
551.El
552.Sh DIAGNOSTICS
553Various, most of them are self-explanatory.
554.Pp
555.Dl XXXXX file system is not available
556.Pp
557The kernel does not support the respective file system type.
558Note that
559support for a particular file system might be provided either on a static
560(kernel compile-time), or dynamic basis (loaded as a kernel module by
561.Xr kldload 8 ) .
562.Sh SEE ALSO
563.Xr getfacl 1 ,
564.Xr setfacl 1 ,
565.Xr nmount 2 ,
566.Xr acl 3 ,
567.Xr libxo 3 ,
568.Xr xo_parse_args 3 ,
569.Xr mac 4 ,
570.Xr cd9660 5 ,
571.Xr devfs 5 ,
572.Xr ext2fs 5 ,
573.Xr fstab 5 ,
574.Xr procfs 5 ,
575.Xr tmpfs 5 ,
576.Xr automount 8 ,
577.Xr fstyp 8 ,
578.Xr kldload 8 ,
579.Xr mount_cd9660 8 ,
580.Xr mount_msdosfs 8 ,
581.Xr mount_nfs 8 ,
582.Xr mount_nullfs 8 ,
583.Xr mount_smbfs 8 ,
584.Xr mount_udf 8 ,
585.Xr mount_unionfs 8 ,
586.Xr umount 8 ,
587.Xr zfs 8 ,
588.Xr zpool 8
589.Sh HISTORY
590A
591.Nm
592utility appeared in
593.At v1 .
594.Sh CAVEATS
595After a successful
596.Nm ,
597the permissions on the original mount point determine if
598.Pa ..\&
599is accessible from the mounted file system.
600The minimum permissions for
601the mount point for traversal across the mount point in both
602directions to be possible for all users is 0111 (execute for all).
603.Pp
604Use of the
605.Nm
606is preferred over the use of the file system specific
607.Pa mount_ Ns Sy XXX
608commands.
609In particular,
610.Xr mountd 8
611gets a
612.Dv SIGHUP
613signal (that causes an update of the export list)
614only when the file system is mounted via
615.Nm .
616.Sh BUGS
617It is possible for a corrupted file system to cause a crash.
618