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, 2016 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 pathname referring to a device,
56 but can also be the pathname of a directory or file,
57 or a dummy string) to the location (a directory or file)
58 specified by the pathname in
61 Appropriate privilege (Linux: the
63 capability) is required to mount filesystems.
67 argument supported by the kernel are listed in
69 (e.g., "btrfs", "ext4", "jfs", "xfs", "vfat", "fuse",
70 "tmpfs", "cgroup", "proc", "mqueue", "nfs", "cifs", "iso9660").
71 Further types may become available when the appropriate modules
76 argument is interpreted by the different filesystems.
77 Typically it is a string of comma-separated options
78 understood by this filesystem.
81 for details of the options available for each filesystem type.
85 performs one of a number of general types of operation.
86 depending on the bits specified in
88 The choice of operation is determined by testing the bits set in
90 with the tests being conducted in the order listed here:
92 Remount an existing mount:
102 Change the propagation type of an existing mount:
111 Move an existing mount to a new location:
118 includes none of the above flags.
120 Each of these operations is detailed later in this page.
121 Further flags may be specified in
123 to modify the behavior of
127 .SS Additional mount flags
128 The list below describes the additional flags that can be specified in
130 Note that some operation types ignore some or all of these flags,
131 as described later in this page.
133 .\" FIXME 2.6.25 Added MS_I_VERSION, which needs to be documented.
136 .BR MS_DIRSYNC " (since Linux 2.5.19)"
137 Make directory changes on this filesystem synchronous.
138 (This property can be obtained for individual directories
142 .BR MS_LAZYTIME " (since Linux 4.0)"
143 .\" commit 0ae45f63d4ef8d8eeec49c7d8b44a1775fff13e8
144 .\" commit fe032c422c5ba562ba9c2d316f55e258e03259c6
145 .\" commit a26f49926da938f47561f386be56a83dd37a496d
146 Reduce on-disk updates of inode timestamps (atime, mtime, ctime)
147 by maintaining these changes only in memory.
148 The on-disk timestamps are updated only when:
151 the inode needs to be updated for some change unrelated to file timestamps;
153 the application employs
159 an undeleted inode is evicted from memory; or
161 more than 24 hours have passed since the inode was written to disk.
164 This mount option significantly reduces writes
165 needed to update the inode's timestamps, especially mtime and atime.
166 However, in the event of a system crash, the atime and mtime fields
167 on disk might be out of date by up to 24 hours.
169 Examples of workloads where this option could be of significant benefit
170 include frequent random writes to preallocated files,
171 as well as cases where the
173 mount option is also enabled.
174 (The advantage of combining
180 will return the correctly updated atime, but the atime updates
181 will be flushed to disk only in the cases listed above.)
184 Permit mandatory locking on files in this filesystem.
185 (Mandatory locking must still be enabled on a per-file basis,
189 .\" commit 95ace75414f312f9a7b93d873f386987b92a5301
190 this mount option requires the
193 .\" FIXME Describe the MS_MOVE flag in more detail
196 Do not update access times for (all types of) files on this filesystem.
199 Do not allow access to devices (special files) on this filesystem.
202 Do not update access times for directories on this filesystem.
203 This flag provides a subset of the functionality provided by
211 Do not allow programs to be executed from this filesystem.
212 .\" (Possibly useful for a filesystem that contains non-Linux executables.
213 .\" Often used as a security feature, e.g., to make sure that restricted
214 .\" users cannot execute files uploaded using ftp or so.)
217 Do not honor set-user-ID and set-group-ID bits or file capabilities
218 when executing programs from this filesystem.
219 .\" (This is a security feature to prevent users executing set-user-ID and
220 .\" set-group-ID programs from removable disk devices.)
223 Mount filesystem read-only.
225 .BR MS_REC " (since Linux 2.4.11)"
226 Used in conjunction with
228 to create a recursive bind mount,
229 and in conjunction with the propagation type flags to recursively change
230 the propagation type of all of the mounts in a subtree.
231 See below for further details.
233 .BR MS_RELATIME " (since Linux 2.6.20)"
234 When a file on this filesystem is accessed,
235 update the file's last access time (atime) only if the current value
236 of atime is less than or equal to the file's last modification time (mtime)
237 or last status change time (ctime).
238 This option is useful for programs, such as
240 that need to know when a file has been read since it was last modified.
241 Since Linux 2.6.30, the kernel defaults to the behavior provided
244 was specified), and the
246 flag is required to obtain traditional semantics.
247 In addition, since Linux 2.6.30,
248 the file's last access time is always updated if it
249 is more than 1 day old.
250 .\" Matthew Garrett notes in the patch that added this behavior
251 .\" that this lets utilities such as tmpreaper (which deletes
252 .\" files based on last access time) work correctly.
254 .BR MS_SILENT " (since Linux 2.6.17)"
255 Suppress the display of certain
257 warning messages in the kernel log.
258 This flag supersedes the misnamed and obsolete
260 flag (available since Linux 2.4.12), which has the same meaning.
262 .BR MS_STRICTATIME " (since Linux 2.6.30)"
263 Always update the last access time (atime) when files on this
264 filesystem are accessed.
265 (This was the default behavior before Linux 2.6.30.)
266 Specifying this flag overrides the effect of setting the
273 Make writes on this filesystem synchronous (as though
278 was specified for all file opens to this filesystem).
280 From Linux 2.4 onward, the
281 .BR MS_NODEV ", " MS_NOEXEC ", and " MS_NOSUID
282 flags are settable on a per-mount-point basis.
283 From kernel 2.6.16 onward,
287 are also settable on a per-mount-point basis.
290 flag is also settable on a per-mount-point basis.
292 .SS Remounting an existing mount
293 An existing mount may be remounted by specifying
297 This allows you to change the
301 of an existing mount without having to unmount and remount the filesystem.
303 should be the same value specified in the initial
311 arguments are ignored.
317 arguments should match the values used in the original
319 call, except for those parameters that are being deliberately changed.
335 .\" commit ffbc6f0ead47fa5a1dc9642b0331cb75c20a640e
344 then the remount operation preserves the existing values of these flags
345 (rather than defaulting to
348 Since Linux 2.6.26, this flag can also be used to make
349 .\" See https://lwn.net/Articles/281157/
350 an existing bind mount read-only by specifying
354 MS_REMOUNT | MS_BIND | MS_RDONLY
358 setting of the bind mount can be changed in this manner.
360 .SS Creating a bind mount
365 (available since Linux 2.4),
366 .\" since 2.4.0-test9
367 then perform a bind mount.
368 A bind mount makes a file or a directory subtree visible at
369 another point within the single directory hierarchy.
370 Bind mounts may cross filesystem boundaries and span
378 arguments are ignored.
380 The remaining bits in the
382 argument are also ignored, with the exception of
384 (The bind mount has the same mount options as
385 the underlying mount point.)
386 However, see the discussion of remounting above,
387 for a method of making an existing bind mount read-only.
389 By default, when a directory is bind mounted,
390 only that directory is mounted;
391 if there are any submounts under the directory tree,
392 they are not bind mounted.
395 flag is also specified, then a recursive bind mount operation is performed:
396 all submounts under the
398 subtree (other than unbindable mounts)
399 are also bind mounted at the corresponding location in the
403 .SS Changing the propagation type of an existing mount
412 (all available since Linux 2.6.15),
413 then the propagation type of an existing mount is changed.
414 If more than one of these flags is specified, an error results.
416 The only flags that can be used with changing the propagation type are
426 arguments are ignored.
428 The meanings of the propagation type flags are as follows:
431 Make this mount point shared.
432 Mount and unmount events immediately under this mount point will propagate
433 to the other mount points that are members of this mount's peer group.
434 Propagation here means that the same mount or unmount will automatically
435 occur under all of the other mount points in the peer group.
436 Conversely, mount and unmount events that take place under
437 peer mount points will propagate to this mount point.
440 Make this mount point private.
441 Mount and unmount events do not propagate into or out of this mount point.
442 This is the default propagation type for newly created mount points.
445 If this is a shared mount point that is a member of a peer group
446 that contains other members, convert it to a slave mount.
447 If this is a shared mount point that is a member of a peer group
448 that contains no other members, convert it to a private mount.
449 Otherwise, the propagation type of the mount point is left unchanged.
451 When a mount point is a slave,
452 mount and unmount events propagate into this mount point from
453 the (master) shared peer group of which it was formerly a member.
454 Mount and unmount events under this mount point do not propagate to any peer.
456 A mount point can be the slave of another peer group
457 while at the same time sharing mount and unmount events
458 with a peer group of which it is a member.
461 Make this mount unbindable.
462 This is like a private mount,
463 and in addition this mount can't be bind mounted.
464 When a recursive bind mount
470 flags) is performed on a directory subtree,
471 any bind mounts within the subtree are automatically pruned
472 (i.e., not replicated)
473 when replicating that subtree to produce the target subtree.
475 By default, changing the propagation type affects only the
480 flag is also specified in
482 then the propagation type of all mount points under
491 (available since Linux 2.4.18),
494 specifies an existing mount point and
496 specifies the new location to which that mount point is to be relocated.
497 The move is atomic: at no point is the subtree unmounted.
499 The remaining bits in the
501 argument are ignored, as are the
507 .SS Creating a new mount point
521 performs its default action: creating a new mount point.
523 specifies the source for the new mount point, and
525 specifies the directory at which to create the mount point.
531 arguments are employed, and further bits may be specified in
533 to modify the behavior of the call.
536 On success, zero is returned.
537 On error, \-1 is returned, and
539 is set appropriately.
541 The error values given below result from filesystem type independent
543 Each filesystem type may have its own special errors and its
544 own special behavior.
545 See the Linux kernel source code for details.
548 A component of a path was not searchable.
550 .BR path_resolution (7).)
553 Mounting a read-only filesystem was attempted without giving the
560 is located on a filesystem mounted with the
563 .\" mtk: Probably: write permission is required for MS_BIND, with
564 .\" the error EPERM if not present; CAP_DAC_OVERRIDE is required.
572 cannot be remounted read-only,
573 because it still holds files open for writing.
581 is still busy (it is the working directory of some thread,
582 the mount point of another device, has open files, etc.).
585 One of the pointer arguments points outside the user address space.
589 had an invalid superblock.
596 was not already mounted on
604 was not a mount point, or was \(aq/\(aq.
608 includes more than one of
623 and also includes a flag other than
629 An attempt was made to bind mount an unbindable mount.
632 Too many links encountered during pathname resolution.
635 A move operation was attempted, and
641 (In case no block device is required:)
642 Table of dummy devices is full.
645 A pathname was longer than
650 not configured in the kernel.
653 A pathname was empty or had a nonexistent component.
656 The kernel could not allocate a free page to copy filenames or data into.
660 is not a block device (and a device was required).
669 The major number of the block device
674 The caller does not have the required privileges.
687 were added to glibc headers in version 2.12.
690 This function is Linux-specific and should not be used in
691 programs intended to be portable.
693 Since Linux 2.4 a single filesystem can be mounted at
694 multiple mount points, and multiple mounts can be stacked
695 on the same mount point.
696 .\" Multiple mounts on same mount point: since 2.3.99pre7.
700 argument may have the magic number 0xC0ED (\fBMS_MGC_VAL\fP)
702 (All of the other flags discussed in DESCRIPTION
703 occupy the low order 16 bits of
707 was required in kernel versions prior to 2.4,
708 but since Linux 2.4 is no longer required and is ignored if specified.
717 was added to \fI<mman.h>\fP.
719 Before Linux 2.4 an attempt to execute a set-user-ID or set-group-ID program
720 on a filesystem mounted with
724 Since Linux 2.4 the set-user-ID and set-group-ID bits are
725 just silently ignored in this case.
726 .\" The change is in patch-2.4.0-prerelease.
729 .SS Per-process namespaces
730 Starting with kernel 2.4.19, Linux provides
731 per-process mount namespaces.
732 A mount namespace is the set of filesystem mounts that
733 are visible to a process.
734 Mount-point namespaces can be (and usually are)
735 shared between multiple processes,
736 and changes to the namespace (i.e., mounts and unmounts) by one process
737 are visible to all other processes sharing the same namespace.
738 (The pre-2.4.19 Linux situation can be considered as one in which
739 a single namespace was shared by every process on the system.)
741 A child process created by
743 shares its parent's mount namespace;
744 the mount namespace is preserved across an
747 A process can obtain a private mount namespace if:
748 it was created using the
752 in which case its new namespace is initialized to be a
754 of the namespace of the process that called
761 which causes the caller's mount namespace to obtain a private copy
762 of the namespace that it was previously sharing with other processes,
763 so that future mounts and unmounts by the caller are invisible
764 to other processes (except child processes that the caller
765 subsequently creates) and vice versa.
769 file exposes the list of mount points in the mount
770 namespace of the process with the specified ID; see
776 .BR path_resolution (7),