1 .\" Copyright (C) 1993 Rickard E. Faith <faith@cs.unc.edu>
2 .\" and Copyright (C) 1994 Andries E. Brouwer <aeb@cwi.nl>
3 .\" and Copyright (C) 2002, 2005 Michael Kerrisk <mtk.manpages@gmail.com>
5 .\" %%%LICENSE_START(VERBATIM)
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date. The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein. The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
27 .\" Modified 1996-11-04 by Eric S. Raymond <esr@thyrsus.com>
28 .\" Modified 2001-10-13 by Michael Kerrisk <mtk.manpages@gmail.com>
29 .\" Added note on historical behavior of MS_NOSUID
30 .\" Modified 2002-05-16 by Michael Kerrisk <mtk.manpages@gmail.com>
31 .\" Extensive changes and additions
32 .\" Modified 2002-05-27 by aeb
33 .\" Modified 2002-06-11 by Michael Kerrisk <mtk.manpages@gmail.com>
34 .\" Enhanced descriptions of MS_MOVE, MS_BIND, and MS_REMOUNT
35 .\" Modified 2004-06-17 by Michael Kerrisk <mtk.manpages@gmail.com>
36 .\" 2005-05-18, mtk, Added MNT_EXPIRE, plus a few other tidy-ups.
37 .\" 2008-10-06, mtk: move umount*() material into separate umount.2 page.
38 .\" 2008-10-06, mtk: Add discussion of namespaces.
40 .TH MOUNT 2 2012-07-05 "Linux" "Linux Programmer's Manual"
42 mount \- mount file system
45 .B "#include <sys/mount.h>"
47 .BI "int mount(const char *" source ", const char *" target ,
48 .BI " const char *" filesystemtype ", unsigned long " mountflags ,
49 .BI " const void *" data );
53 attaches the file system specified by
55 (which is often a device name, but can also be a directory name
56 or a dummy) to the directory specified by
59 Appropriate privilege (Linux: the
61 capability) is required to mount file systems.
63 Since Linux 2.4 a single file system can be visible at
64 multiple mount points, and multiple mounts can be stacked
65 on the same mount point.
66 .\" Multiple mounts on same mount point: since 2.3.99pre7.
70 argument supported by the kernel are listed in
72 (e.g., "minix", "ext2", "ext3", "jfs", "xfs", "reiserfs",
73 "msdos", "proc", "nfs", "iso9660").
74 Further types may become available when the appropriate modules
79 argument may have the magic number 0xC0ED (\fBMS_MGC_VAL\fP)
80 in the top 16 bits (this was required in kernel versions prior to 2.4, but
81 is no longer required and ignored if specified),
82 and various mount flags
83 .\" (as defined in \fI<linux/fs.h>\fP for libc4 and libc5
84 .\" and in \fI<sys/mount.h>\fP for glibc2)
85 in the low order 16 bits:
86 .\" FIXME 2.6.15 added flags for "shared subtree" functionality:
87 .\" MS_UNBINDABLE, MS_PRIVATE, MS_SHARED, MS_SLAVE
90 .\" All mounts are private by default. Previously shared mouns
91 .\" can be remarked PRIVATE.
93 .\" Mount points that are marked SHARED propagate mount events
94 .\" to one another after bing cloned.
96 .\" A previously shared mount point can be marked SALVE, meaning
97 .\" it receives propagated events, but does not propagate events.
99 .\" mounts cannot be bound into other places, and will not be
100 .\" propagated into new subtrees
101 .\" mount --make-rshared ==> MS_SHARED | MS_REC
103 .\" These settings are visible in proc/mountinfo
106 .\" These need to be documented on this page.
108 .\" Documentation/filesystems/sharedsubtree.txt
110 .\" http://lwn.net/Articles/159077/
112 .\" http://myweb.sudhaa.com:2022/~ram/sharedsubtree/paper/sharedsubtree.1.pdf
113 .\" Shared-Subtree Concept, Implementation, and Applications in Linux
114 .\" Al Viro viro@ftp.linux.org.uk
115 .\" Ram Pai linuxram@us.ibm.com
117 .\" http://foss.in/2005/slides/sharedsubtree1.pdf
118 .\" Shared Subtree Concept and Implementation in the Linux Kernel
121 .\" http://www.ibm.com/developerworks/linux/library/l-mount-namespaces/index.html
122 .\" Applying mount namespaces
124 .\" Uncover practical applications for advanced Linux mounts features
125 .\" Serge E. Hallyn (sergeh@us.ibm.com), Software Engineer, IBM 
126 .\" Ram Pai (linuxram@us.ibm.com), Software Engineer, IBM
127 .\" Date: 17 Sep 2007
129 .\" 2.6.25 Added MS_I_VERSION, which needs to be documented.
132 .BR MS_BIND " (Linux 2.4 onward)"
133 .\" since 2.4.0-test9
134 Perform a bind mount, making a file or a directory subtree visible at
135 another point within a file system.
136 Bind mounts may cross file system boundaries and span
143 arguments are ignored.
144 Up until Linux 2.6.26,
147 .\" with the exception of the "hidden" MS_REC mountflags bit
148 (the bind mount has the same mount options as
149 the underlying mount point).
151 .BR MS_DIRSYNC " (since Linux 2.5.19)"
152 Make directory changes on this file system synchronous.
153 (This property can be obtained for individual directories
158 Permit mandatory locking on files in this file system.
159 (Mandatory locking must still be enabled on a per-file basis,
162 .\" FIXME Say more about MS_MOVE
167 specifies an existing mount point and
169 specifies the new location.
170 The move is atomic: at no point is the subtree unmounted.
172 .IR filesystemtype ", " mountflags ", and " data
173 arguments are ignored.
176 Do not update access times for (all types of) files on this file system.
179 Do not allow access to devices (special files) on this file system.
182 Do not update access times for directories on this file system.
183 This flag provides a subset of the functionality provided by
191 Do not allow programs to be executed from this file system.
192 .\" (Possibly useful for a file system that contains non-Linux executables.
193 .\" Often used as a security feature, e.g., to make sure that restricted
194 .\" users cannot execute files uploaded using ftp or so.)
197 Do not honor set-user-ID and set-group-ID bits when executing
198 programs from this file system.
199 .\" (This is a security feature to prevent users executing set-user-ID and
200 .\" set-group-ID programs from removable disk devices.)
203 Mount file system read-only.
205 .\" FIXME Document MS_REC, available since 2.4.11.
206 .\" This flag has meaning in conjunction with MS_BIND and
207 .\" also with the shared subtree flags.
209 .BR MS_RELATIME " (Since Linux 2.6.20)"
210 When a file on this file system is accessed,
211 update the file's last access time (atime) only if the current value
212 of atime is less than or equal to the file's last modification time (mtime)
213 or last status change time (ctime).
214 This option is useful for programs, such as
216 that need to know when a file has been read since it was last modified.
217 Since Linux 2.6.30, the kernel defaults to the behavior provided
220 was specified), and the
222 flag is required to obtain traditional semantics.
223 In addition, since Linux 2.6.30,
224 the file's last access time is always updated if it
225 is more than 1 day old.
226 .\" Matthew Garrett notes in the patch that added this behavior
227 .\" that this lets utilities such as tmpreaper (which deletes
228 .\" files based on last acces time) work correctly.
231 Remount an existing mount.
232 This allows you to change the
236 of an existing mount without having to unmount and remount the file system.
238 should be the same value specified in the initial
252 before kernel 2.6.16, the following could also be changed:
256 and, additionally, before kernel 2.4.10, the following could also be changed:
261 .BR MS_SILENT " (since Linux 2.6.17)"
262 Suppress the display of certain
264 warning messages in the kernel log.
265 This flag supersedes the misnamed and obsolete
267 flag (available since Linux 2.4.12), which has the same meaning.
269 .BR MS_STRICTATIME " (Since Linux 2.6.30)"
270 Always update the last access time (atime) when files on this
271 file system are accessed.
272 (This was the default behavior before Linux 2.6.30.)
273 Specifying this flag overrides the effect of setting the
280 Make writes on this file system synchronous (as though
285 was specified for all file opens to this file system).
287 From Linux 2.4 onward, the
288 .BR MS_NODEV ", " MS_NOEXEC ", and " MS_NOSUID
289 flags are settable on a per-mount-point basis.
290 From kernel 2.6.16 onward,
294 are also settable on a per-mount-point basis.
297 flag is also settable on a per-mount-point basis.
301 argument is interpreted by the different file systems.
302 Typically it is a string of comma-separated options
303 understood by this file system.
306 for details of the options available for each filesystem type.
308 On success, zero is returned.
309 On error, \-1 is returned, and
311 is set appropriately.
313 The error values given below result from filesystem type independent
315 Each file-system type may have its own special errors and its
316 own special behavior.
317 See the Linux kernel source code for details.
320 A component of a path was not searchable.
322 .BR path_resolution (7).)
323 Or, mounting a read-only file system was attempted without giving the
328 is located on a file system mounted with the
331 .\" mtk: Probably: write permission is required for MS_BIND, with
332 .\" the error EPERM if not present; CAP_DAC_OVERRIDE is required.
337 Or, it cannot be remounted read-only,
338 because it still holds files open for writing.
339 Or, it cannot be mounted on
343 is still busy (it is the working directory of some thread,
344 the mount point of another device, has open files, etc.).
347 One of the pointer arguments points outside the user address space.
351 had an invalid superblock.
356 was not already mounted on
362 was not a mount point, or was \(aq/\(aq.
365 Too many links encountered during pathname resolution.
366 Or, a move was attempted, while
372 (In case no block device is required:)
373 Table of dummy devices is full.
376 A pathname was longer than
381 not configured in the kernel.
384 A pathname was empty or had a nonexistent component.
387 The kernel could not allocate a free page to copy filenames or data into.
391 is not a block device (and a device was required).
400 The major number of the block device
405 The caller does not have the required privileges.
414 were added to glibc headers in version 2.12.
415 .\" FIXME: Definitions of the so-far-undocumented MS_UNBINDABLE, MS_PRIVATE,
416 .\" MS_SHARED, and MS_SLAVE were (also) only added to glibc headers in 2.12.
418 This function is Linux-specific and should not be used in
419 programs intended to be portable.
428 was added to \fI<mman.h>\fP.
430 Before Linux 2.4 an attempt to execute a set-user-ID or set-group-ID program
431 on a file system mounted with
435 Since Linux 2.4 the set-user-ID and set-group-ID bits are
436 just silently ignored in this case.
437 .\" The change is in patch-2.4.0-prerelease.
438 .SS Per-process namespaces
439 Starting with kernel 2.4.19, Linux provides
440 per-process mount namespaces.
441 A mount namespace is the set of file system mounts that
442 are visible to a process.
443 Mount-point namespaces can be (and usually are)
444 shared between multiple processes,
445 and changes to the namespace (i.e., mounts and unmounts) by one process
446 are visible to all other processes sharing the same namespace.
447 (The pre-2.4.19 Linux situation can be considered as one in which
448 a single namespace was shared by every process on the system.)
450 A child process created by
452 shares its parent's mount namespace;
453 the mount namespace is preserved across an
456 A process can obtain a private mount namespace if:
457 it was created using the
461 in which case its new namespace is initialized to be a
463 of the namespace of the process that called
470 which causes the caller's mount namespace to obtain a private copy
471 of the namespace that it was previously sharing with other processes,
472 so that future mounts and unmounts by the caller are invisible
473 to other processes (except child processes that the caller
474 subsequently creates) and vice versa.
478 file exposes the list of mount points in the mount
479 namespace of the process with the specified ID; see
485 .BR path_resolution (7),