xref: /freebsd/sbin/mount/mount.8 (revision 77b7cdf1999ee965ad494fddd184b18f532ac91a)
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. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     @(#)mount.8	8.8 (Berkeley) 6/16/94
33.\" $FreeBSD$
34.\"
35.Dd April 7, 2003
36.Dt MOUNT 8
37.Os
38.Sh NAME
39.Nm mount
40.Nd mount file systems
41.Sh SYNOPSIS
42.Nm
43.Op Fl adfpruvw
44.Op Fl F Ar fstab
45.Op Fl t Ar ufs | external_type
46.Nm
47.Op Fl dfpruvw
48.Ar special | node
49.Nm
50.Op Fl dfpruvw
51.Op Fl o Ar options
52.Op Fl t Ar ufs | external_type
53.Ar special node
54.Sh DESCRIPTION
55The
56.Nm
57utility calls the
58.Xr mount 2
59system call to prepare and graft a
60.Ar "special device"
61or 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 a
79All the file systems described in
80.Xr fstab 5
81are mounted.
82Exceptions are those marked as
83.Dq noauto ,
84excluded by the
85.Fl t
86flag (see below), or if they are already mounted (except the
87root file system which is always remounted to preserve
88traditional single user mode behavior).
89.It Fl d
90Causes everything to be done except for the actual system call.
91This option is useful in conjunction with the
92.Fl v
93flag to
94determine what the
95.Nm
96command is trying to do.
97.It Fl F Ar fstab
98Specify the
99.Pa fstab
100file to use.
101.It Fl f
102Forces the revocation of write access when trying to downgrade
103a file system mount status from read-write to read-only.
104Also
105forces the R/W mount of an unclean file system (dangerous; use with
106caution).
107.It Fl o
108Options are specified with a
109.Fl o
110flag followed by a comma separated string of options.
111In case of conflicting options being specified, the rightmost option
112takes effect.
113The following options are available:
114.Bl -tag -width indent
115.It Cm async
116All
117.Tn I/O
118to the file system should be done asynchronously.
119This is a
120.Em dangerous
121flag to set,
122and should not be used unless you are prepared to recreate the file
123system should your system crash.
124.It Cm current
125When used with the
126.Fl u
127flag, this is the same as specifying the options currently in effect for
128the mounted file system.
129.It Cm force
130The same as
131.Fl f ;
132forces the revocation of write access when trying to downgrade
133a file system mount status from read-write to read-only.
134Also
135forces the R/W mount of an unclean file system (dangerous; use with caution).
136.It Cm fstab
137When used with the
138.Fl u
139flag, this is the same as specifying all the options listed in the
140.Xr fstab 5
141file for the file system.
142.It Cm noasync
143Metadata I/O should be done synchronously, while data I/O should be done
144asynchronously.
145This is the default.
146.It Cm noatime
147Do not update the file access time when reading from a file.
148This option
149is useful on file systems where there are large numbers of files and
150performance is more critical than updating the file access time (which is
151rarely ever important).
152This option is currently only supported on local file systems.
153.It Cm noauto
154This file system should be skipped when
155.Nm
156is run with the
157.Fl a
158flag.
159.It Cm noclusterr
160Disable read clustering.
161.It Cm noclusterw
162Disable write clustering.
163.It Cm nodev
164Do not interpret character or block special devices on the file system.
165This option is useful for a server that has file systems containing
166special devices for architectures other than its own.
167This option is set automatically when the user does not have super-user
168privileges.
169.It Cm noexec
170Do not allow execution of any binaries on the mounted file system.
171This option is useful for a server that has file systems containing
172binaries for architectures other than its own.
173.It Cm nosuid
174Do not allow set-user-identifier or set-group-identifier bits to take effect.
175Note: this option is worthless if a public available suid or sgid
176wrapper like
177.Xr suidperl 1
178is installed on your system.
179It is set automatically when the user does not have super-user privileges.
180.It Cm nosymfollow
181Do not follow symlinks
182on the mounted file system.
183.It Cm rdonly
184The same as
185.Fl r ;
186mount the file system read-only (even the super-user may not write it).
187.It Cm sync
188All
189.Tn I/O
190to the file system should be done synchronously.
191.It Cm snapshot
192This option allows a snapshot of the specified file system to be taken.
193The
194.Fl u
195flag is required with this option.
196Note that snapshot files must be created in the file system that is being
197snapshotted.
198You may create up to 20 snapshots per file system.
199Active snapshots are recorded in the superblock, so they persist across unmount
200and remount operations and across system reboots.
201When you are done with a snapshot, it can be removed with the
202.Xr rm 1
203command.
204Snapshots may be removed in any order, however you may not get back all the
205space contained in the snapshot as another snapshot may claim some of the blocks
206that it is releasing.
207Note that the schg flag is set on snapshots to ensure that not even the root
208user can write to them.
209The unlink command makes an exception for snapshot files in that it allows them
210to be removed even though they have the schg flag set, so it is not necessary to
211clear the schg flag before removing a snapshot file.
212.Pp
213Once you have taken a snapshot, there are three interesting things that you can
214do with it:
215.Pp
216.Bl -enum -compact
217.It
218Run
219.Xr fsck 8
220on the snapshot file.
221Assuming that the file system was clean when it was mounted, you should always
222get a clean (and unchanging) result from running fsck on the snapshot.
223This is essentially what the background fsck process does.
224.Pp
225.It
226Run
227.Xr dump 8
228on the snapshot.
229You will get a dump that is consistent with the file system as of the timestamp
230of the snapshot.
231.Pp
232.It
233Mount the snapshot as a frozen image of the file system.
234To mount the snapshot
235.Pa /var/snapshot/snap1 :
236.Bd -literal
237mdconfig -a -t vnode -f /var/snapshot/snap1 -u 4
238mount -r /dev/md4 /mnt
239.Ed
240.Pp
241You can now cruise around your frozen
242.Pa /var
243file system at
244.Pa /mnt .
245Everything will be in the same state that it was at the time the snapshot was
246taken.
247The one exception is that any earlier snapshots will appear as zero length
248files.
249When you are done with the mounted snapshot:
250.Bd -literal
251umount /mnt
252mdconfig -d -u 4
253.Ed
254.Pp
255Further details can be found in the file at
256.Pa /usr/src/sys/ufs/ffs/README.snapshot .
257.El
258.It Cm suiddir
259A directory on the mounted file system will respond to the SUID bit
260being set, by setting the owner of any new files to be the same
261as the owner of the directory.
262New directories will inherit the bit from their parents.
263Execute bits are removed from
264the file, and it will not be given to root.
265.Pp
266This feature is designed for use on fileservers serving PC users via
267ftp, SAMBA, or netatalk.
268It provides security holes for shell users and as
269such should not be used on shell machines, especially on home directories.
270This option requires the SUIDDIR
271option in the kernel to work.
272Only UFS file systems support this option.
273See
274.Xr chmod 2
275for more information.
276.It Cm update
277The same as
278.Fl u ;
279indicate that the status of an already mounted file system should be changed.
280.It Cm union
281Causes the namespace at the mount point to appear as the union
282of the mounted file system root and the existing directory.
283Lookups will be done in the mounted file system first.
284If those operations fail due to a non-existent file the underlying
285directory is then accessed.
286All creates are done in the mounted file system.
287.El
288.Pp
289Any additional options specific to a file system type that is not
290one of the internally known types (see the
291.Fl t
292option) may be passed as a comma separated list; these options are
293distinguished by a leading
294.Dq \&-
295(dash).
296Options that take a value are specified using the syntax -option=value.
297For example, the
298.Nm
299command:
300.Bd -literal -offset indent
301mount -t unionfs -o -b /sys $HOME/sys
302.Ed
303.Pp
304causes
305.Nm
306to execute the equivalent of:
307.Bd -literal -offset indent
308/sbin/mount_unionfs -b /sys $HOME/sys
309.Ed
310.Pp
311Additional options specific to file system types
312which are not internally known
313(see the description of the
314.Fl t
315option below)
316may be described in the manual pages for the associated
317.Pa /sbin/mount_ Ns Sy XXX
318utilities.
319.It Fl p
320Print mount information in
321.Xr fstab 5
322format.
323Implies also the
324.Fl v
325option.
326.It Fl r
327The file system is to be mounted read-only.
328Mount the file system read-only (even the super-user may not write it).
329The same as the
330.Cm rdonly
331argument to the
332.Fl o
333option.
334.It Fl t Ar ufs | external_type
335The argument following the
336.Fl t
337is used to indicate the file system type.
338The type
339.Ar ufs
340is the default.
341The
342.Fl t
343option can be used
344to indicate that the actions should only be taken on
345file systems of the specified type.
346More than one type may be specified in a comma separated list.
347The list of file system types can be prefixed with
348.Dq no
349to specify the file system types for which action should
350.Em not
351be taken.
352For example, the
353.Nm
354command:
355.Bd -literal -offset indent
356mount -a -t nonfs,nullfs
357.Ed
358.Pp
359mounts all file systems except those of type
360.Tn NFS
361and
362.Tn NULLFS .
363.Pp
364If the type is not one of the internally known types,
365.Nm
366will attempt to execute a program in
367.Pa /sbin/mount_ Ns Sy XXX
368where
369.Sy XXX
370is replaced by the type name.
371For example, nfs file systems are mounted by the program
372.Pa /sbin/mount_nfs .
373.Pp
374Most file systems will be dynamically loaded by the kernel
375if not already present, and if the kernel module is available.
376.It Fl u
377The
378.Fl u
379flag indicates that the status of an already mounted file
380system should be changed.
381Any of the options discussed above (the
382.Fl o
383option)
384may be changed;
385also a file system can be changed from read-only to read-write
386or vice versa.
387An attempt to change from read-write to read-only will fail if any
388files on the file system are currently open for writing unless the
389.Fl f
390flag is also specified.
391The set of options is determined by applying the options specified
392in the argument to
393.Fl o
394and finally applying the
395.Fl r
396or
397.Fl w
398option.
399.It Fl v
400Verbose mode.
401.It Fl w
402The file system object is to be read and write.
403.El
404.Sh DIAGNOSTICS
405Various, most of them are self-explanatory.
406.Pp
407.Dl XXXXX file system is not available
408.Pp
409The kernel does not support the respective file system type.
410Note that
411support for a particular file system might be provided either on a static
412(kernel compile-time), or dynamic basis (loaded as a kernel module by
413.Xr kldload 8 ) .
414.Sh ENVIRONMENT
415.Bl -tag -width PATH_FSTAB
416.It Pa PATH_FSTAB
417If the environment variable
418.Pa PATH_FSTAB
419is set all operations are performed against the specified file.
420.Pa PATH_FSTAB
421will not be honored if the process environment or memory address space is
422considred
423.Dq tainted .
424(See
425.Fn issetugid
426for more information.)
427.El
428.Sh FILES
429.Bl -tag -width /etc/fstab -compact
430.It Pa /etc/fstab
431file system table
432.El
433.Sh SEE ALSO
434.Xr mount 2 ,
435.Xr fstab 5 ,
436.Xr kldload 8 ,
437.Xr mount_cd9660 8 ,
438.Xr mount_devfs 8 ,
439.Xr mount_ext2fs 8 ,
440.Xr mount_fdescfs 8 ,
441.Xr mount_hpfs 8 ,
442.Xr mount_linprocfs 8 ,
443.Xr mount_msdosfs 8 ,
444.Xr mount_nfs 8 ,
445.Xr mount_ntfs 8 ,
446.Xr mount_nullfs 8 ,
447.Xr mount_nwfs 8 ,
448.Xr mount_portalfs 8 ,
449.Xr mount_procfs 8 ,
450.Xr mount_smbfs 8 ,
451.Xr mount_std 8 ,
452.Xr mount_udf 8 ,
453.Xr mount_umapfs 8 ,
454.Xr mount_unionfs 8 ,
455.Xr umount 8
456.Sh BUGS
457It is possible for a corrupted file system to cause a crash.
458.Sh CAVEATS
459After a successful
460.Nm ,
461the permissions on the original mount point determine if
462.Pa ..\&
463is accessible from the mounted file system.
464The minimum permissions for
465the mount point for traversal across the mount point in both
466directions to be possible for all users is 0111 (execute for all).
467.Sh HISTORY
468A
469.Nm
470utility appeared in
471.At v1 .
472