1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (C) 1993 Rickard E. Faith <faith@cs.unc.edu>
4 .\" and Copyright (C) 1994 Andries E. Brouwer <aeb@cwi.nl>
5 .\" and Copyright (C) 2002, 2005 Michael Kerrisk <mtk.manpages@gmail.com>
7 .\" Permission is granted to make and distribute verbatim copies of this
8 .\" manual provided the copyright notice and this permission notice are
9 .\" preserved on all copies.
11 .\" Permission is granted to copy and distribute modified versions of this
12 .\" manual under the conditions for verbatim copying, provided that the
13 .\" entire resulting derived work is distributed under the terms of a
14 .\" permission notice identical to this one.
16 .\" Since the Linux kernel and libraries are constantly changing, this
17 .\" manual page may be incorrect or out-of-date. The author(s) assume no
18 .\" responsibility for errors or omissions, or for damages resulting from
19 .\" the use of the information contained herein. The author(s) may not
20 .\" have taken the same level of care in the production of this manual,
21 .\" which is licensed free of charge, as they might when working
24 .\" Formatted or processed versions of this manual, if unaccompanied by
25 .\" 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 2008-11-19 "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 (like "minix", "ext2", "ext3", "jfs", "xfs", "reiserfs",
73 "msdos", "proc", "nfs", "iso9660" etc.).
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 (as defined in \fI<linux/fs.h>\fP for libc4 and libc5
83 and in \fI<sys/mount.h>\fP for glibc2) in the low order 16 bits:
84 .\" FIXME 2.6.15 added flags for "shared sub-tree" functionality:
85 .\" MS_UNBINDABLE, MS_PRIVATE, MS_SHARED, MS_SLAVE
86 .\" These need to be documented on this page.
88 .\" Documentation/filesystems/sharedsubtree.txt
90 .\" http://lwn.net/Articles/159077/
92 .\" http://myweb.sudhaa.com:2022/~ram/sharedsubtree/paper/sharedsubtree.1.pdf
93 .\" Shared-Subtree Concept, Implementation, and Applications in Linux
94 .\" Al Viro viro@ftp.linux.org.uk
95 .\" Ram Pai linuxram@us.ibm.com
97 .\" http://foss.in/2005/slides/sharedsubtree1.pdf
98 .\" Shared Subtree Concept and Implementation in the Linux Kernel
102 .BR MS_BIND " (Linux 2.4 onwards)"
103 .\" since 2.4.0-test9
104 Perform a bind mount, making a file or a directory subtree visible at
105 another point within a file system.
106 Bind mounts may cross file system boundaries and span
113 arguments are ignored.
114 Up until Linux 2.6.26,
117 .\" with the exception of the "hidden" MS_REC mountflags bit
118 (the bind mount has the same mount options as
119 the underlying mount point).
120 Since Linux 2.6.26, the
122 flag is honored when making a bind mount.
124 .BR MS_DIRSYNC " (since Linux 2.5.19)"
125 Make directory changes on this file system synchronous.
126 (This property can be obtained for individual directories
131 Permit mandatory locking on files in this file system.
132 (Mandatory locking must still be enabled on a per-file basis,
135 .\" FIXME Say more about MS_MOVE
140 specifies an existing mount point and
142 specifies the new location.
143 The move is atomic: at no point is the subtree unmounted.
145 .IR filesystemtype ", " mountflags ", and " data
146 arguments are ignored.
149 Do not update access times for (all types of) files on this file system.
152 Do not allow access to devices (special files) on this file system.
155 Do not update access times for directories on this file system.
156 This flag provides a subset of the functionality provided by
164 Do not allow programs to be executed from this file system.
165 .\" (Possibly useful for a file system that contains non-Linux executables.
166 .\" Often used as a security feature, e.g., to make sure that restricted
167 .\" users cannot execute files uploaded using ftp or so.)
170 Do not honor set-user-ID and set-group-ID bits when executing
171 programs from this file system.
172 .\" (This is a security feature to prevent users executing set-user-ID and
173 .\" set-group-ID programs from removable disk devices.)
176 Mount file system read-only.
178 .\" FIXME Document MS_REC, available since 2.4.11.
179 .\" This flag has meaning in conjunction with MS_BIND and
180 .\" also with the shared sub-tree flags.
182 .BR MS_RELATIME " (Since Linux 2.6.20)"
183 When a file on this file system is accessed,
184 only update the file's last access time (atime) if the current value
185 of atime is less than or equal to the file's last modification time (mtime)
186 or last status change time (ctime).
187 This option is useful for programs, such as
189 that need to know when a file has been read since it was last modified.
192 Remount an existing mount.
193 This allows you to change the
197 of an existing mount without having to unmount and remount the file system.
201 should be the same values specified in the initial
213 before kernel 2.6.16, the following could also be changed:
217 and, additionally, before kernel 2.4.10, the following could also be changed:
222 .BR MS_SILENT " (since Linux 2.6.17)"
223 Suppress the display of certain
225 warning messages in the kernel log.
226 This flag supersedes the misnamed and obsolete
228 flag (available since Linux 2.4.12), which has the same meaning.
231 Make writes on this file system synchronous (as though
236 was specified for all file opens to this file system).
238 From Linux 2.4 onwards, the
239 .BR MS_NODEV ", " MS_NOEXEC ", and " MS_NOSUID
240 flags are settable on a per-mount-point basis.
241 From kernel 2.6.16 onwards,
245 are also settable on a per-mount-point basis.
248 flag is also settable on a per-mount-point basis.
252 argument is interpreted by the different file systems.
253 Typically it is a string of comma-separated options
254 understood by this file system.
257 for details of the options available for each filesystem type.
259 On success, zero is returned.
260 On error, \-1 is returned, and
262 is set appropriately.
264 The error values given below result from filesystem type independent
266 Each filesystem type may have its own special errors and its
267 own special behavior.
268 See the kernel source code for details.
271 A component of a path was not searchable.
273 .BR path_resolution (7).)
274 Or, mounting a read-only filesystem was attempted without giving the
279 is located on a filesystem mounted with the
282 .\" mtk: Probably: write permission is required for MS_BIND, with
283 .\" the error EPERM if not present; CAP_DAC_OVERRIDE is required.
288 Or, it cannot be remounted read-only,
289 because it still holds files open for writing.
290 Or, it cannot be mounted on
294 is still busy (it is the working directory of some task,
295 the mount point of another device, has open files, etc.).
298 One of the pointer arguments points outside the user address space.
302 had an invalid superblock.
307 was not already mounted on
313 was not a mount point, or was \(aq/\(aq.
316 Too many links encountered during pathname resolution.
317 Or, a move was attempted, while
323 (In case no block device is required:)
324 Table of dummy devices is full.
327 A pathname was longer than
332 not configured in the kernel.
335 A pathname was empty or had a nonexistent component.
338 The kernel could not allocate a free page to copy filenames or data into.
342 is not a block device (and a device was required).
351 The major number of the block device
356 The caller does not have the required privileges.
358 This function is Linux-specific and should not be used in
359 programs intended to be portable.
368 was added to \fI<mman.h>\fP.
370 Before Linux 2.4 an attempt to execute a set-user-ID or set-group-ID program
371 on a filesystem mounted with
375 Since Linux 2.4 the set-user-ID and set-group-ID bits are
376 just silently ignored in this case.
377 .\" The change is in patch-2.4.0-prerelease.
378 .SS Per-process Namespaces
379 Starting with kernel 2.4.19, Linux provides
380 per-process mount-point namespaces.
381 A mount-point namespace is the set of file system mounts that
382 are visible to a process.
383 Mount-point namespaces can be (and usually are)
384 shared between multiple processes,
385 and changes to the namespace (i.e., mounts and unmounts) by one process
386 are visible to all other processes sharing the same namespace.
387 (The pre-2.4.19 Linux situation can be considered as one in which there
388 was a single namespace was shared by every process on the system.)
390 A child process created by
392 shares its parent's mount-point namespace;
393 the mount-point namespace is preserved across an
396 A process can obtain a private mount-point namespace if:
397 it was created using the
401 in which case its new namespace is initialized to be a
403 of the namespace of the process that called
410 which causes the caller's mount-point namespace to obtain a private copy
411 of the namespace that it was previously sharing with other processes,
412 so that future mounts and unmounts by the caller are invisible
413 to other processes (except child processes that the caller
414 subsequently creates) and vice versa.
418 file exposes the list of mount points in the mount-point
419 namespace of the process with the specified ID; see
424 .BR path_resolution (7),