1.\"	$NetBSD: mount.8,v 1.92 2024/04/03 07:00:06 wiz Exp $
2.\"
3.\" Copyright (c) 1980, 1989, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"     @(#)mount.8	8.8 (Berkeley) 6/16/94
31.\"
32.Dd April 2, 2024
33.Dt MOUNT 8
34.Os
35.Sh NAME
36.Nm mount
37.Nd mount file systems
38.Sh SYNOPSIS
39.Nm
40.Op Fl Aadfruvw
41.Op Fl t Ar type
42.Nm
43.Op Fl dfruvw
44.Brq Ar special | Ar node
45.Nm
46.Op Fl dfruvw
47.Op Fl o Ar options
48.Op Fl t Ar type
49.Ar special node
50.Sh DESCRIPTION
51The
52.Nm
53command invokes a file system-specific program to prepare and graft the
54.Ar special
55device on to the file system tree at the point
56.Ar node ,
57or to update options for an already-mounted file system.
58.Pp
59These programs are named
60.Dq mount_<fstype>
61where
62.Dq <fstype>
63refers to the file system-specific type; for example
64for NFS the mount program is called
65.Xr mount_nfs 8 .
66.Pp
67The
68.Ar node
69argument is always interpreted as a directory in the name space of
70currently mounted file systems.
71The
72.Ar special
73argument is interpreted in different ways
74by the programs that handle different file system types;
75for example,
76.Xr mount_ffs 8
77interprets it as a device node,
78.Xr mount_null 8
79interprets it as a directory name,
80.Xr mount_nfs 8
81interprets it as reference to a remote host and a directory on that host,
82and
83.Xr mount_tmpfs 8
84ignores it.
85.Pp
86The system maintains a list of currently mounted file systems.
87This list is printed if
88.Nm
89is invoked with no arguments, and with no options that require some
90other behaviour.
91.Pp
92If exactly one of
93.Ar special
94or
95.Ar node
96is provided, then the missing information
97(including the file system type)
98is taken from the
99.Xr fstab 5
100file.
101The provided argument is looked up first in the
102.Dq fs_file ,
103then in the
104.Dq fs_spec
105column.
106If the matching entry in
107.Xr fstab 5
108has the string
109.Dq Li from_mount
110as its
111.Dq fs_spec
112field, the device or remote file system already mounted at
113the location specified by
114.Dq fs_spec
115will be used.
116.\" XXX The above paragraph doesn't address the use of "-u"
117.Pp
118If both
119.Ar special
120and
121.Ar node
122are provided, then
123.Xr fstab 5
124is not used.
125In this case, if the file system type is not specified
126via the
127.Fl t
128flag, then
129.Nm
130may determine the type from the disk label (see
131.Xr disklabel 8 ) .
132In addition, if
133.Ar special
134contains a colon
135.Pq Ql \&:
136or at sign
137.Pq Ql \&@ ,
138then the
139.Li nfs
140type is inferred.
141Otherwise, a
142.Xr dk 4
143wedge may be referred to by its name with a
144.Ar special
145argument of the form
146.Dq NAME=<value> .
147.Pp
148In
149.Nx ,
150the file system mounting policy is dictated by the running security models.
151The default security model may allow unprivileged mounting; see
152.Xr secmodel_suser 9
153and
154.Xr secmodel_extensions 9
155for details.
156.Pp
157The options are as follows:
158.Bl -tag -width indent
159.It Fl A
160Causes
161.Nm
162to try to mount all of the file systems listed in the
163.Xr fstab 5
164file except those for which the
165.Dq noauto
166option is specified.
167.It Fl a
168Similar to the
169.Fl A
170flag, except that if a file system (other than the root file system)
171appears to be already mounted,
172.Nm
173will not try to mount it again.
174.Nm
175assumes that a file system is already mounted if a file system with
176the same type is mounted on the given mount point.
177More stringent checks are not possible because some file system types
178report strange values for the mounted-from device for mounted file
179systems.
180.It Fl d
181Causes everything to be done except for the invocation of
182the file system-specific program.
183This option is useful in conjunction with the
184.Fl v
185flag to determine what the
186.Nm
187command is trying to do.
188.It Fl f
189Forces the revocation of write access when trying to downgrade
190a file system mount status from read-write to read-only.
191.It Fl o
192Options are specified with a
193.Fl o
194flag followed by a comma separated string of options.
195The following options are available:
196.Bl -tag -width nocoredump
197.It Cm async
198All I/O to the file system should be done asynchronously.
199In the event of a crash,
200.Em "it is impossible for the system to verify the integrity of data on a file system mounted with this option" .
201You should only use this option if you have an application-specific data
202recovery mechanism, or are willing to recreate the file system from scratch.
203.It Cm noasync
204Clear
205.Cm async
206mode.
207.It Cm automounted
208This flag indicates that the file system was mounted by
209.Xr automountd 8 .
210Automounted file systems are automatically unmounted by
211.Xr autounmountd 8 .
212.It Cm discard
213Use DISCARD/TRIM commands if disk and driver support it.
214.Pp
215.Em EXPERIMENTAL
216- negatively influences filesystem performance by increasing fragmentation,
217causes free block map inconsistency on unclean shutdown,
218and is incompatible with
219.Cm log .
220If
221.Cm log
222option is also used,
223.Cm discard
224is automatically disabled.
225.It Cm extattr
226Enable extended attributes, if the filesystem supports them and
227does not enable them by default.
228Currently this is only the case for UFS1.
229.It Cm force
230The same as
231.Fl f ;
232forces the revocation of write access when trying to downgrade
233a file system mount status from read-write to read-only.
234.It Cm getargs
235Retrieves the file system specific mount arguments for the given
236mounted file system and prints them.
237.It Cm hidden
238By setting the
239.Dv MNT_IGNORE
240flag,
241causes the mount point to be excluded from the
242list of file systems shown by default with
243.Xr df 1 .
244.It Cm noatime
245Never update the access time field for files.
246This option is useful for optimizing read performance on file systems,
247and avoiding excess writes on flash-based file systems.
248.It Cm noauto
249This file system should be skipped when mount is run with the
250.Fl a
251flag.
252.It Cm nocoredump
253Do not allow programs to create crash dumps (core files) on the file system.
254This option can be used to help protect sensitive
255data by keeping core files (which may contain sensitive data)
256from being created on insecure file systems.
257Only core files that would be created by program crashes are
258prevented by use of this flag; the behavior of
259.Xr savecore 8
260is not affected.
261.It Cm nodev
262Do not interpret character or block special devices on the file system.
263This option is useful for a server that has file systems containing
264special devices for architectures other than its own.
265.It Cm nodevmtime
266Do not update modification times on device special files.
267This option is useful on laptops
268or other systems that perform power management.
269.It Cm noexec
270Do not allow execution of any binaries on the mounted file system.
271This option is useful for a server that has file systems containing
272binaries for architectures other than its own.
273.It Cm nosuid
274Do not allow set-user-identifier or set-group-identifier bits to take effect.
275.It Cm port
276(NFS only) Use the specified NFS port.
277.It Cm rdonly
278The same as
279.Fl r ;
280mount the file system read-only (even the super-user may not write it).
281.It Cm reload
282Reload all incore data for a file system.
283This is used mainly after running
284.Xr fsck 8
285on the root file system and finding things to fix.
286The file system must be mounted read-only.
287All cached meta-data are invalidated, superblock and summary information
288is re-read from disk, all cached inactive vnodes and file data are
289invalidated and all inode data are re-read for all active vnodes.
290.It Cm rump
291Instead of running
292.Dq mount_<fstype>
293to mount the file system, run
294.Dq rump_<fstype> .
295This uses a userspace server to mount the file system and does not
296require kernel support for the specific file system type.
297See the
298.Fl t
299flag and respective rump_type manual page for more information.
300.It Cm log
301(FFS only)
302Mount the file system with
303.Xr wapbl 4
304meta-data journaling, also known simply as logging.
305It provides rapid metadata updates and eliminates the need to check
306file system consistency after a system outage.
307It requires the
308.Dv WAPBL
309option to be enabled in the running kernel.
310See
311.Xr wapbl 4
312for more information.
313This option requires the
314.Dq UFS2
315.Pq level 4
316superblock layout, which is the default for newly created FFSv1 and
317FFSv2 file systems.
318To update an old file system with an earlier superblock format,
319use the
320.Fl c
321option of
322.Xr fsck_ffs 8 .
323.Pp
324.Cm log
325cannot be used together with
326.Cm discard .
327.Pp
328A file system mounted with
329.Cm log
330can be mounted also with
331.Cm async ,
332but such filesystem behaves the same as if
333.Cm async
334was not specified - meta-data writes use the log, hence its integrity
335is still guaranteed.
336.It Cm symperm
337Recognize permission of symbolic link when reading or traversing link.
338.It Cm sync
339All I/O to the file system should be done synchronously.
340This is not equivalent to the normal mode in which only
341metadata is written synchronously.
342.It Cm nosync
343Clear
344.Cm sync
345mode.
346.It Cm union
347Causes the namespace at the mount point to appear as the union
348of the mounted file system root
349(referred to as the
350.Em upper
351layer), and the existing directory
352(referred to as the
353.Em lower
354layer).
355Name lookups will be done in the upper layer first.
356If a name does not exist in the upper layer, then the name
357will be looked up in the lower layer.
358If a name exists in both the upper and lower layers, then only
359the upper instance is accessible.
360Creation of new files is done in the upper layer,
361except in the case of the fdesc file system (see
362.Xr mount_fdesc 8 ) .
363.Pp
364Note that the
365.Cm union
366option can be applied to any type of file system,
367and is fundamentally different from
368.Xr mount_union 8 ,
369which is a particular type of file system.
370Also note that the
371.Cm union
372option affects the file system name space only at the mount point
373itself; it does not apply recursively to subdirectories.
374.It Cm update
375The same as
376.Fl u ;
377indicate that the status of an already mounted file system should be changed.
378.El
379.Pp
380Any additional options specific to a given file system type (see the
381.Fl t
382option) may be passed as a comma separated list; these options are
383distinguished by a leading
384.Dq \&-
385(dash).
386Options that take a value are specified using the syntax -option=value.
387For example, the mount command:
388.Bd -literal -offset indent
389mount -t mfs -o nosuid,-N,-s=32m swap /tmp
390.Ed
391.Pp
392causes
393.Nm
394to execute the equivalent of:
395.Bd -literal -offset indent
396/sbin/mount_mfs -o nosuid -N -s 32m swap /tmp
397.Ed
398.It Fl r
399The file system is to be mounted read-only.
400Mount the file system read-only (even the super-user may not write it).
401The same as the
402.Dq rdonly
403argument to the
404.Fl o
405option.
406.It Fl t Ar type
407The argument following the
408.Fl t
409is used to indicate the file system type.
410The type
411.Ar ffs
412is the default.
413The
414.Fl t
415option can be used to indicate that the actions
416should only be taken on file systems of the specified type.
417More than one type may be specified in a comma separated list.
418The list of file system types can be prefixed with
419.Dq no
420to specify the file system types for which action should
421.Em not
422be taken.
423For example, the
424.Nm
425command:
426.Bd -literal -offset indent
427mount -a -t nonfs,mfs
428.Ed
429.Pp
430mounts all file systems except those of type NFS and MFS.
431.Pp
432.Nm
433will attempt to execute a program in
434.Pa /sbin/mount_ Ns Em XXX
435where
436.Em XXX
437is replaced by the type name.
438For example, nfs file systems are mounted by the program
439.Pa /sbin/mount_nfs .
440.It Fl u
441The
442.Fl u
443flag indicates that the status of an already mounted file
444system should be changed.
445Any of the options discussed above (the
446.Fl o
447option)
448may be changed;
449also a file system can be changed from read-only to read-write
450or vice versa.
451An attempt to change from read-write to read-only will fail if any
452files on the file system are currently open for writing unless the
453.Fl f
454flag is also specified.
455The set of options is determined by first extracting the options
456for the file system from the
457.Xr fstab 5
458file, then applying any options specified by the
459.Fl o
460argument,
461and finally applying the
462.Fl r
463or
464.Fl w
465option.
466.It Fl v
467Verbose mode.
468If this flag is specified more than once, then the
469file system-specific mount arguments are printed for the given mounted
470file system.
471.It Fl w
472The file system object is to be read and write.
473.El
474.Pp
475The options specific to the various file system types are
476described in the manual pages for those file systems'
477.Dq mount_<fstype>
478commands;
479for instance, the options specific to Berkeley
480Fast File System (FFS) are described in the
481.Xr mount_ffs 8
482manual page.
483.Pp
484The particular type of file system in each partition of a disk can
485be found by examining the disk label with the
486.Xr disklabel 8
487command.
488.Sh FILES
489.Bl -tag -width /etc/fstab -compact
490.It Pa /etc/fstab
491file system table
492.El
493.Sh EXAMPLES
494Some useful examples:
495.Bl -tag -offset indent -width "MS-DOS"
496.It CD-ROM
497mount -t cd9660 -r /dev/cd0a /cdrom
498.It MS-DOS
499mount -t msdos /dev/fd0a /floppy
500.It NFS
501mount -t nfs nfs-server-host:/directory/path /mount-point
502.It MFS (32 megabyte)
503mount -t mfs -o nosuid,-s=32m swap /tmp
504.El
505.Pp
506The
507.Dq noauto
508directive in
509.Pa /etc/fstab
510can be used to make it easy to manually mount and unmount removable
511media using just the mountpoint filename, with an entry like this:
512.Pp
513.Dl /dev/cd0a  /cdrom  cd9660 ro,noauto 0 0
514.Pp
515That would allow a simple command like
516.Qq mount /cdrom
517or
518.Qq umount /cdrom
519for media using the ISO-9660 file system format in the first
520CD-ROM drive.
521.Sh DIAGNOSTICS
522The error
523.Dq Operation not supported by device
524indicates that the mount for the specified file system type cannot be
525completed because the kernel lacks support for the said file system.
526See
527.Xr options 4 .
528.Pp
529The error
530.Dq Operation not permitted
531may indicate that the mount options include privileged options and/or
532do not include options that exclude privileged options.
533One should try using at least
534.Dq nodev
535and
536.Dq nosuid
537in such cases:
538.Bd -literal -offset indent
539mount -t cd9660 -o nodev,nosuid /dev/cd0a /mnt
540.Ed
541.Sh SEE ALSO
542.Xr df 1 ,
543.Xr mount 2 ,
544.Xr options 4 ,
545.Xr wapbl 4 ,
546.Xr fstab 5 ,
547.Xr automount 8 ,
548.Xr automountd 8 ,
549.Xr autounmountd 8 ,
550.Xr disklabel 8 ,
551.Xr fsck 8 ,
552.Xr mount_ados 8 ,
553.Xr mount_cd9660 8 ,
554.Xr mount_chfs 8 ,
555.Xr mount_ext2fs 8 ,
556.Xr mount_fdesc 8 ,
557.Xr mount_ffs 8 ,
558.Xr mount_filecore 8 ,
559.Xr mount_kernfs 8 ,
560.Xr mount_lfs 8 ,
561.Xr mount_mfs 8 ,
562.Xr mount_msdos 8 ,
563.Xr mount_nfs 8 ,
564.Xr mount_ntfs 8 ,
565.Xr mount_null 8 ,
566.Xr mount_overlay 8 ,
567.Xr mount_portal 8 ,
568.Xr mount_procfs 8 ,
569.Xr mount_tmpfs 8 ,
570.Xr mount_udf 8 ,
571.Xr mount_umap 8 ,
572.Xr mount_union 8 ,
573.Xr rump_cd9660 8 ,
574.Xr rump_efs 8 ,
575.Xr rump_ext2fs 8 ,
576.Xr rump_ffs 8 ,
577.Xr rump_hfs 8 ,
578.Xr rump_lfs 8 ,
579.Xr rump_msdos 8 ,
580.Xr rump_nfs 8 ,
581.Xr rump_ntfs 8 ,
582.Xr rump_sysvbfs 8 ,
583.Xr rump_tmpfs 8 ,
584.Xr rump_udf 8 ,
585.Xr umount 8
586.Sh HISTORY
587A
588.Nm
589command appeared in
590.At v1 .
591