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 2016-03-15 "Linux" "Linux Programmer's Manual"
42 mount \- mount filesystem
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 filesystem 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 filesystems.
63 Since Linux 2.4 a single filesystem 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:
89 .\" All mounts are private by default. Previously shared mounts
90 .\" can be re-marked PRIVATE.
92 .\" Mount points that are marked SHARED propagate mount events
93 .\" to one another after being cloned.
94 .\" mount --make-rshared ==> MS_SHARED | MS_REC
96 .\" A previously shared mount point can be marked SLAVE, 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
102 .\" These settings are visible in /proc/$$/mountinfo
104 .\" These need to be documented on this page.
107 .\" * Documentation/filesystems/sharedsubtree.txt
109 .\" * http://lwn.net/Articles/159077/
111 .\" * https://www.kernel.org/doc/ols/2006/ols2006v2-pages-209-222.pdf
112 .\" Shared-Subtree Concept, Implementation, and Applications in Linux
113 .\" Al Viro viro@ftp.linux.org.uk
114 .\" Ram Pai linuxram@us.ibm.com
116 .\" * http://www.ibm.com/developerworks/linux/library/l-mount-namespaces/index.html
117 .\" Applying mount namespaces
119 .\" Uncover practical applications for advanced Linux mounts features
120 .\" Serge E. Hallyn (sergeh@us.ibm.com), Software Engineer, IBM
121 .\" Ram Pai (linuxram@us.ibm.com), Software Engineer, IBM
122 .\" Date: 17 Sep 2007
124 .\" FIXME 2.6.25 Added MS_I_VERSION, which needs to be documented.
127 .BR MS_BIND " (Linux 2.4 onward)"
128 .\" since 2.4.0-test9
129 Perform a bind mount, making a file or a directory subtree visible at
130 another point within a filesystem.
131 Bind mounts may cross filesystem boundaries and span
138 arguments are ignored.
139 Up until Linux 2.6.26,
142 .\" with the exception of the "hidden" MS_REC mountflags bit
143 (the bind mount has the same mount options as
144 the underlying mount point).
146 .BR MS_DIRSYNC " (since Linux 2.5.19)"
147 Make directory changes on this filesystem synchronous.
148 (This property can be obtained for individual directories
152 .BR MS_LAZYTIME " (since Linux 4.0)"
153 .\" commit 0ae45f63d4ef8d8eeec49c7d8b44a1775fff13e8
154 .\" commit fe032c422c5ba562ba9c2d316f55e258e03259c6
155 .\" commit a26f49926da938f47561f386be56a83dd37a496d
156 Reduce on-disk updates of inode timestamps (atime, mtime, ctime)
157 by maintaining these changes only in memory.
158 The on-disk timestamps are updated only when:
161 the inode needs to be updated for some change unrelated to file timestamps;
163 the application employs
169 an undeleted inode is evicted from memory; or
171 more than 24 hours have passed since the inode was written to disk.
174 This mount option significantly reduces writes
175 needed to update the inode's timestamps, especially mtime and atime.
176 However, in the event of a system crash, the atime and mtime fields
177 on disk might be out of date by up to 24 hours.
179 Examples of workloads where this option could be of significant benefit
180 include frequent random writes to preallocated files,
181 as well as cases where the
183 mount option is also enabled.
184 (The advantage of combining
190 will return the correctly updated atime, but the atime updates
191 will be flushed to disk only in the cases listed above.)
194 Permit mandatory locking on files in this filesystem.
195 (Mandatory locking must still be enabled on a per-file basis,
198 .\" FIXME Describe the MS_MOVE flag in more detail
203 specifies an existing mount point and
205 specifies the new location.
206 The move is atomic: at no point is the subtree unmounted.
208 .IR filesystemtype ", " mountflags ", and " data
209 arguments are ignored.
212 Do not update access times for (all types of) files on this filesystem.
215 Do not allow access to devices (special files) on this filesystem.
218 Do not update access times for directories on this filesystem.
219 This flag provides a subset of the functionality provided by
227 Do not allow programs to be executed from this filesystem.
228 .\" (Possibly useful for a filesystem that contains non-Linux executables.
229 .\" Often used as a security feature, e.g., to make sure that restricted
230 .\" users cannot execute files uploaded using ftp or so.)
233 Do not honor set-user-ID and set-group-ID bits when executing
234 programs from this filesystem.
235 .\" (This is a security feature to prevent users executing set-user-ID and
236 .\" set-group-ID programs from removable disk devices.)
239 Mount filesystem read-only.
241 .\" FIXME Document MS_REC, available since 2.4.11.
242 .\" This flag has meaning in conjunction with MS_BIND and
243 .\" also with the shared subtree flags.
245 .BR MS_RELATIME " (since Linux 2.6.20)"
246 When a file on this filesystem is accessed,
247 update the file's last access time (atime) only if the current value
248 of atime is less than or equal to the file's last modification time (mtime)
249 or last status change time (ctime).
250 This option is useful for programs, such as
252 that need to know when a file has been read since it was last modified.
253 Since Linux 2.6.30, the kernel defaults to the behavior provided
256 was specified), and the
258 flag is required to obtain traditional semantics.
259 In addition, since Linux 2.6.30,
260 the file's last access time is always updated if it
261 is more than 1 day old.
262 .\" Matthew Garrett notes in the patch that added this behavior
263 .\" that this lets utilities such as tmpreaper (which deletes
264 .\" files based on last access time) work correctly.
267 Remount an existing mount.
268 This allows you to change the
272 of an existing mount without having to unmount and remount the filesystem.
274 should be the same value specified in the initial
285 arguments should match the values used in the original
287 call, except for those parameters that are being deliberately changed.
295 before kernel 2.6.16, the following could also be changed:
299 and, additionally, before kernel 2.4.10, the following could also be changed:
304 .BR MS_SILENT " (since Linux 2.6.17)"
305 Suppress the display of certain
307 warning messages in the kernel log.
308 This flag supersedes the misnamed and obsolete
310 flag (available since Linux 2.4.12), which has the same meaning.
312 .BR MS_STRICTATIME " (since Linux 2.6.30)"
313 Always update the last access time (atime) when files on this
314 filesystem are accessed.
315 (This was the default behavior before Linux 2.6.30.)
316 Specifying this flag overrides the effect of setting the
323 Make writes on this filesystem synchronous (as though
328 was specified for all file opens to this filesystem).
330 From Linux 2.4 onward, the
331 .BR MS_NODEV ", " MS_NOEXEC ", and " MS_NOSUID
332 flags are settable on a per-mount-point basis.
333 From kernel 2.6.16 onward,
337 are also settable on a per-mount-point basis.
340 flag is also settable on a per-mount-point basis.
344 argument is interpreted by the different filesystems.
345 Typically it is a string of comma-separated options
346 understood by this filesystem.
349 for details of the options available for each filesystem type.
351 On success, zero is returned.
352 On error, \-1 is returned, and
354 is set appropriately.
356 The error values given below result from filesystem type independent
358 Each filesystem type may have its own special errors and its
359 own special behavior.
360 See the Linux kernel source code for details.
363 A component of a path was not searchable.
365 .BR path_resolution (7).)
366 Or, mounting a read-only filesystem was attempted without giving the
371 is located on a filesystem mounted with the
374 .\" mtk: Probably: write permission is required for MS_BIND, with
375 .\" the error EPERM if not present; CAP_DAC_OVERRIDE is required.
380 Or, it cannot be remounted read-only,
381 because it still holds files open for writing.
382 Or, it cannot be mounted on
386 is still busy (it is the working directory of some thread,
387 the mount point of another device, has open files, etc.).
390 One of the pointer arguments points outside the user address space.
394 had an invalid superblock.
399 was not already mounted on
405 was not a mount point, or was \(aq/\(aq.
408 Too many links encountered during pathname resolution.
409 Or, a move was attempted, while
415 (In case no block device is required:)
416 Table of dummy devices is full.
419 A pathname was longer than
424 not configured in the kernel.
427 A pathname was empty or had a nonexistent component.
430 The kernel could not allocate a free page to copy filenames or data into.
434 is not a block device (and a device was required).
443 The major number of the block device
448 The caller does not have the required privileges.
457 were added to glibc headers in version 2.12.
458 .\" FIXME . Definitions of the so-far-undocumented MS_UNBINDABLE, MS_PRIVATE,
459 .\" MS_SHARED, and MS_SLAVE were (also) only added to glibc headers in 2.12.
461 This function is Linux-specific and should not be used in
462 programs intended to be portable.
471 was added to \fI<mman.h>\fP.
473 Before Linux 2.4 an attempt to execute a set-user-ID or set-group-ID program
474 on a filesystem mounted with
478 Since Linux 2.4 the set-user-ID and set-group-ID bits are
479 just silently ignored in this case.
480 .\" The change is in patch-2.4.0-prerelease.
481 .SS Per-process namespaces
482 Starting with kernel 2.4.19, Linux provides
483 per-process mount namespaces.
484 A mount namespace is the set of filesystem mounts that
485 are visible to a process.
486 Mount-point namespaces can be (and usually are)
487 shared between multiple processes,
488 and changes to the namespace (i.e., mounts and unmounts) by one process
489 are visible to all other processes sharing the same namespace.
490 (The pre-2.4.19 Linux situation can be considered as one in which
491 a single namespace was shared by every process on the system.)
493 A child process created by
495 shares its parent's mount namespace;
496 the mount namespace is preserved across an
499 A process can obtain a private mount namespace if:
500 it was created using the
504 in which case its new namespace is initialized to be a
506 of the namespace of the process that called
513 which causes the caller's mount namespace to obtain a private copy
514 of the namespace that it was previously sharing with other processes,
515 so that future mounts and unmounts by the caller are invisible
516 to other processes (except child processes that the caller
517 subsequently creates) and vice versa.
521 file exposes the list of mount points in the mount
522 namespace of the process with the specified ID; see
528 .BR path_resolution (7),