]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" Copyright (C) 1993 Rickard E. Faith <faith@cs.unc.edu> |
6883b3e7 | 2 | .\" and Copyright (C) 1994 Andries E. Brouwer <aeb@cwi.nl> |
eac1e050 | 3 | .\" and Copyright (C) 2002, 2005, 2016 Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da | 4 | .\" |
93015253 | 5 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
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. | |
9 | .\" | |
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. | |
c13182ef | 14 | .\" |
fea681da MK |
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 | |
21 | .\" professionally. | |
c13182ef | 22 | .\" |
fea681da MK |
23 | .\" Formatted or processed versions of this manual, if unaccompanied by |
24 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 25 | .\" %%%LICENSE_END |
fea681da MK |
26 | .\" |
27 | .\" Modified 1996-11-04 by Eric S. Raymond <esr@thyrsus.com> | |
c11b1abf | 28 | .\" Modified 2001-10-13 by Michael Kerrisk <mtk.manpages@gmail.com> |
d9bfdb9c | 29 | .\" Added note on historical behavior of MS_NOSUID |
c11b1abf | 30 | .\" Modified 2002-05-16 by Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da MK |
31 | .\" Extensive changes and additions |
32 | .\" Modified 2002-05-27 by aeb | |
c11b1abf | 33 | .\" Modified 2002-06-11 by Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da | 34 | .\" Enhanced descriptions of MS_MOVE, MS_BIND, and MS_REMOUNT |
c11b1abf | 35 | .\" Modified 2004-06-17 by Michael Kerrisk <mtk.manpages@gmail.com> |
8df37e4d | 36 | .\" 2005-05-18, mtk, Added MNT_EXPIRE, plus a few other tidy-ups. |
0a4d78bb MK |
37 | .\" 2008-10-06, mtk: move umount*() material into separate umount.2 page. |
38 | .\" 2008-10-06, mtk: Add discussion of namespaces. | |
fea681da | 39 | .\" |
8538a62b | 40 | .TH MOUNT 2 2018-02-02 "Linux" "Linux Programmer's Manual" |
fea681da | 41 | .SH NAME |
9ee4a2b6 | 42 | mount \- mount filesystem |
fea681da | 43 | .SH SYNOPSIS |
7998dde2 | 44 | .nf |
fea681da | 45 | .B "#include <sys/mount.h>" |
68e4db0a | 46 | .PP |
fea681da | 47 | .BI "int mount(const char *" source ", const char *" target , |
7998dde2 MK |
48 | .BI " const char *" filesystemtype ", unsigned long " mountflags , |
49 | .BI " const void *" data ); | |
7998dde2 | 50 | .fi |
fea681da | 51 | .SH DESCRIPTION |
e511ffb6 | 52 | .BR mount () |
9ee4a2b6 | 53 | attaches the filesystem specified by |
fea681da | 54 | .I source |
751de899 MK |
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 | |
fea681da | 59 | .IR target . |
547ee319 | 60 | .PP |
fea681da MK |
61 | Appropriate privilege (Linux: the |
62 | .B CAP_SYS_ADMIN | |
9ee4a2b6 | 63 | capability) is required to mount filesystems. |
547ee319 | 64 | .PP |
fea681da | 65 | Values for the |
0daa9e92 | 66 | .I filesystemtype |
fea681da MK |
67 | argument supported by the kernel are listed in |
68 | .I /proc/filesystems | |
9792cd16 MK |
69 | (e.g., "btrfs", "ext4", "jfs", "xfs", "vfat", "fuse", |
70 | "tmpfs", "cgroup", "proc", "mqueue", "nfs", "cifs", "iso9660"). | |
fea681da MK |
71 | Further types may become available when the appropriate modules |
72 | are loaded. | |
547ee319 | 73 | .PP |
b3ae9c7d MK |
74 | The |
75 | .I data | |
76 | argument is interpreted by the different filesystems. | |
77 | Typically it is a string of comma-separated options | |
78 | understood by this filesystem. | |
79 | See | |
80 | .BR mount (8) | |
81 | for details of the options available for each filesystem type. | |
547ee319 | 82 | .PP |
f429fadc MK |
83 | A call to |
84 | .BR mount () | |
c3a7b4e9 | 85 | performs one of a number of general types of operation, |
f429fadc MK |
86 | depending on the bits specified in |
87 | .IR mountflags . | |
c3a7b4e9 MK |
88 | The choice of which operation to perform is determined by |
89 | testing the bits set in | |
f429fadc MK |
90 | .IR mountflags , |
91 | with the tests being conducted in the order listed here: | |
92 | .IP * 3 | |
93 | Remount an existing mount: | |
94 | .IR mountflags | |
95 | includes | |
96 | .BR MS_REMOUNT . | |
97 | .IP * | |
98 | Create a bind mount: | |
99 | .IR mountflags | |
100 | includes | |
101 | .BR MS_BIND . | |
102 | .IP * | |
103 | Change the propagation type of an existing mount: | |
104 | .IR mountflags | |
105 | includes one of | |
106 | .BR MS_SHARED , | |
107 | .BR MS_PRIVATE , | |
108 | .BR MS_SLAVE , | |
109 | or | |
110 | .BR MS_UNBINDABLE . | |
111 | .IP * | |
112 | Move an existing mount to a new location: | |
113 | .IR mountflags | |
114 | includes | |
115 | .BR MS_MOVE . | |
116 | .IP * | |
117 | Create a new mount: | |
118 | .IR mountflags | |
119 | includes none of the above flags. | |
120 | .PP | |
121 | Each of these operations is detailed later in this page. | |
122 | Further flags may be specified in | |
123 | .IR mountflags | |
124 | to modify the behavior of | |
125 | .BR mount (), | |
126 | as described below. | |
2835e6c5 | 127 | .\" |
f429fadc MK |
128 | .SS Additional mount flags |
129 | The list below describes the additional flags that can be specified in | |
130 | .IR mountflags . | |
131 | Note that some operation types ignore some or all of these flags, | |
132 | as described later in this page. | |
2835e6c5 | 133 | .\" |
bea08fec | 134 | .\" FIXME 2.6.25 Added MS_I_VERSION, which needs to be documented. |
fa4c100d MK |
135 | .\" commit 7a224228ed79d587ece2304869000aad1b8e97dd |
136 | .\" (This is a per-superblock flag) | |
21d995a8 | 137 | .\" |
fea681da | 138 | .TP |
8df37e4d | 139 | .BR MS_DIRSYNC " (since Linux 2.5.19)" |
9ee4a2b6 | 140 | Make directory changes on this filesystem synchronous. |
fea681da MK |
141 | (This property can be obtained for individual directories |
142 | or subtrees using | |
49ec013c | 143 | .BR chattr (1).) |
fea681da | 144 | .TP |
9b249562 | 145 | .BR MS_LAZYTIME " (since Linux 4.0)" |
42a8e396 MK |
146 | .\" commit 0ae45f63d4ef8d8eeec49c7d8b44a1775fff13e8 |
147 | .\" commit fe032c422c5ba562ba9c2d316f55e258e03259c6 | |
148 | .\" commit a26f49926da938f47561f386be56a83dd37a496d | |
149 | Reduce on-disk updates of inode timestamps (atime, mtime, ctime) | |
150 | by maintaining these changes only in memory. | |
151 | The on-disk timestamps are updated only when: | |
152 | .RS | |
153 | .IP (a) 5 | |
154 | the inode needs to be updated for some change unrelated to file timestamps; | |
155 | .IP (b) | |
156 | the application employs | |
157 | .BR fsync (2), | |
158 | .BR syncfs (2), | |
159 | or | |
160 | .BR sync (2); | |
161 | .IP (c) | |
162 | an undeleted inode is evicted from memory; or | |
163 | .IP (d) | |
164 | more than 24 hours have passed since the inode was written to disk. | |
165 | .RE | |
166 | .IP | |
5eab76af | 167 | This mount option significantly reduces writes |
9cdabfa6 MK |
168 | needed to update the inode's timestamps, especially mtime and atime. |
169 | However, in the event of a system crash, the atime and mtime fields | |
170 | on disk might be out of date by up to 24 hours. | |
054ea65e | 171 | .IP |
9cdabfa6 MK |
172 | Examples of workloads where this option could be of significant benefit |
173 | include frequent random writes to preallocated files, | |
174 | as well as cases where the | |
175 | .B MS_STRICTATIME | |
176 | mount option is also enabled. | |
cdd14e51 MK |
177 | (The advantage of combining |
178 | .BR MS_STRICTATIME | |
179 | and | |
180 | .BR MS_LAZYTIME | |
9cdabfa6 MK |
181 | is that |
182 | .BR stat (2) | |
183 | will return the correctly updated atime, but the atime updates | |
5eab76af | 184 | will be flushed to disk only in the cases listed above.) |
42a8e396 | 185 | .TP |
fea681da | 186 | .B MS_MANDLOCK |
9ee4a2b6 | 187 | Permit mandatory locking on files in this filesystem. |
fea681da MK |
188 | (Mandatory locking must still be enabled on a per-file basis, |
189 | as described in | |
190 | .BR fcntl (2).) | |
afa0b44d MK |
191 | Since Linux 4.5, |
192 | .\" commit 95ace75414f312f9a7b93d873f386987b92a5301 | |
193 | this mount option requires the | |
194 | .B CAP_SYS_ADMIN | |
41976bc5 MK |
195 | capability and a kernel configured with the |
196 | .B CONFIG_MANDATORY_FILE_LOCKING | |
197 | option. | |
fea681da | 198 | .TP |
fea681da | 199 | .B MS_NOATIME |
9ee4a2b6 | 200 | Do not update access times for (all types of) files on this filesystem. |
fea681da MK |
201 | .TP |
202 | .B MS_NODEV | |
9ee4a2b6 | 203 | Do not allow access to devices (special files) on this filesystem. |
fea681da MK |
204 | .TP |
205 | .B MS_NODIRATIME | |
9ee4a2b6 | 206 | Do not update access times for directories on this filesystem. |
882a9435 MK |
207 | This flag provides a subset of the functionality provided by |
208 | .BR MS_NOATIME ; | |
209 | that is, | |
210 | .BR MS_NOATIME | |
211 | implies | |
212 | .BR MS_NODIRATIME . | |
fea681da MK |
213 | .TP |
214 | .B MS_NOEXEC | |
9ee4a2b6 MK |
215 | Do not allow programs to be executed from this filesystem. |
216 | .\" (Possibly useful for a filesystem that contains non-Linux executables. | |
75b94dc3 | 217 | .\" Often used as a security feature, e.g., to make sure that restricted |
fea681da MK |
218 | .\" users cannot execute files uploaded using ftp or so.) |
219 | .TP | |
220 | .B MS_NOSUID | |
4be9e801 MK |
221 | Do not honor set-user-ID and set-group-ID bits or file capabilities |
222 | when executing programs from this filesystem. | |
880f5b4b MK |
223 | .\" (This is a security feature to prevent users executing set-user-ID and |
224 | .\" set-group-ID programs from removable disk devices.) | |
fea681da MK |
225 | .TP |
226 | .B MS_RDONLY | |
9ee4a2b6 | 227 | Mount filesystem read-only. |
eac1e050 MK |
228 | .TP |
229 | .BR MS_REC " (since Linux 2.4.11)" | |
230 | Used in conjunction with | |
231 | .BR MS_BIND | |
232 | to create a recursive bind mount, | |
233 | and in conjunction with the propagation type flags to recursively change | |
234 | the propagation type of all of the mounts in a subtree. | |
235 | See below for further details. | |
c13182ef | 236 | .TP |
31c1f2b0 | 237 | .BR MS_RELATIME " (since Linux 2.6.20)" |
9ee4a2b6 | 238 | When a file on this filesystem is accessed, |
33a0ccb2 | 239 | update the file's last access time (atime) only if the current value |
7c40de08 | 240 | of atime is less than or equal to the file's last modification time (mtime) |
926b6e37 MK |
241 | or last status change time (ctime). |
242 | This option is useful for programs, such as | |
243 | .BR mutt (1), | |
244 | that need to know when a file has been read since it was last modified. | |
02a4e226 MK |
245 | Since Linux 2.6.30, the kernel defaults to the behavior provided |
246 | by this flag (unless | |
247 | .BR MS_NOATIME | |
248 | was specified), and the | |
249 | .B MS_STRICTATIME | |
250 | flag is required to obtain traditional semantics. | |
251 | In addition, since Linux 2.6.30, | |
252 | the file's last access time is always updated if it | |
253 | is more than 1 day old. | |
254 | .\" Matthew Garrett notes in the patch that added this behavior | |
255 | .\" that this lets utilities such as tmpreaper (which deletes | |
5116355c | 256 | .\" files based on last access time) work correctly. |
fea681da | 257 | .TP |
f429fadc MK |
258 | .BR MS_SILENT " (since Linux 2.6.17)" |
259 | Suppress the display of certain | |
260 | .RI ( printk ()) | |
261 | warning messages in the kernel log. | |
262 | This flag supersedes the misnamed and obsolete | |
263 | .BR MS_VERBOSE | |
264 | flag (available since Linux 2.4.12), which has the same meaning. | |
265 | .TP | |
266 | .BR MS_STRICTATIME " (since Linux 2.6.30)" | |
267 | Always update the last access time (atime) when files on this | |
268 | filesystem are accessed. | |
269 | (This was the default behavior before Linux 2.6.30.) | |
270 | Specifying this flag overrides the effect of setting the | |
271 | .BR MS_NOATIME | |
272 | and | |
273 | .BR MS_RELATIME | |
274 | flags. | |
275 | .TP | |
276 | .B MS_SYNCHRONOUS | |
277 | Make writes on this filesystem synchronous (as though | |
278 | the | |
279 | .B O_SYNC | |
280 | flag to | |
281 | .BR open (2) | |
282 | was specified for all file opens to this filesystem). | |
283 | .PP | |
284 | From Linux 2.4 onward, the | |
285 | .BR MS_NODEV ", " MS_NOEXEC ", and " MS_NOSUID | |
286 | flags are settable on a per-mount-point basis. | |
287 | From kernel 2.6.16 onward, | |
288 | .B MS_NOATIME | |
289 | and | |
290 | .B MS_NODIRATIME | |
291 | are also settable on a per-mount-point basis. | |
292 | The | |
293 | .B MS_RELATIME | |
294 | flag is also settable on a per-mount-point basis. | |
c84a8779 N |
295 | Since Linux 2.6.16, |
296 | .B MS_RDONLY | |
297 | can be set or cleared on a per-mount-point basis as well as on | |
0e1a971b | 298 | the underlying filesystem. |
9edbd686 MK |
299 | The mounted filesystem will be writable only if neither the filesystem |
300 | nor the mountpoint are flagged as read-only. | |
f429fadc MK |
301 | .\" |
302 | .SS Remounting an existing mount | |
303 | An existing mount may be remounted by specifying | |
fea681da | 304 | .B MS_REMOUNT |
f429fadc MK |
305 | in |
306 | .IR mountflags . | |
599e5da7 | 307 | This allows you to change the |
fea681da MK |
308 | .I mountflags |
309 | and | |
310 | .I data | |
9ee4a2b6 | 311 | of an existing mount without having to unmount and remount the filesystem. |
fea681da | 312 | .I target |
44535dd2 | 313 | should be the same value specified in the initial |
fea681da | 314 | .BR mount () |
74b46b5f | 315 | call. |
547ee319 | 316 | .PP |
74b46b5f | 317 | The |
44535dd2 MK |
318 | .I source |
319 | and | |
fea681da | 320 | .I filesystemtype |
74b46b5f | 321 | arguments are ignored. |
547ee319 | 322 | .PP |
69b6b231 EB |
323 | The |
324 | .I mountflags | |
325 | and | |
326 | .I data | |
327 | arguments should match the values used in the original | |
328 | .BR mount () | |
329 | call, except for those parameters that are being deliberately changed. | |
c84a8779 N |
330 | Another exception is that |
331 | .B MS_BIND | |
a4222367 | 332 | has a different meaning for remount, and it should be included only if |
c84a8779 | 333 | explicitly desired. |
a4222367 | 334 | .PP |
178b977b | 335 | The following |
c13182ef | 336 | .I mountflags |
178b977b | 337 | can be changed: |
9c2678e6 | 338 | .BR MS_LAZYTIME , |
495a1a89 MK |
339 | .\" FIXME |
340 | .\" MS_LAZYTIME seems to be available only on a few filesystems, | |
341 | .\" and on ext4, it seems (from experiment that this flag | |
342 | .\" can only be enabled (but not disabled) on a remount. | |
343 | .\" The following code in ext4_remount() (kernel 4.17) seems to | |
344 | .\" confirm this: | |
345 | .\" | |
346 | .\" if (*flags & SB_LAZYTIME) | |
347 | .\" sb->s_flags |= SB_LAZYTIME; | |
014b17c6 MK |
348 | .BR MS_MANDLOCK , |
349 | .BR MS_NOATIME , | |
178b977b | 350 | .BR MS_NODEV , |
014b17c6 MK |
351 | .BR MS_NODIRATIME , |
352 | .BR MS_NOEXEC , | |
353 | .BR MS_NOSUID , | |
9c2678e6 | 354 | .BR MS_RELATIME , |
014b17c6 | 355 | .BR MS_RDONLY , |
16008a41 | 356 | and |
014b17c6 | 357 | .BR MS_SYNCHRONOUS . |
d8b67bc9 MK |
358 | Attempts to change the setting of the |
359 | .\" See the definition of MS_RMT_MASK in include/uapi/linux/fs.h | |
360 | .BR MS_DIRSYNC | |
361 | flag during a remount are silently ignored. | |
547ee319 | 362 | .PP |
49f68546 MK |
363 | Since Linux 3.17, |
364 | .\" commit ffbc6f0ead47fa5a1dc9642b0331cb75c20a640e | |
365 | if none of | |
366 | .BR MS_NOATIME , | |
367 | .BR MS_NODIRATIME , | |
368 | .BR MS_RELATIME , | |
369 | or | |
370 | .BR MS_STRICTATIME | |
371 | is specified in | |
372 | .IR mountflags , | |
373 | then the remount operation preserves the existing values of these flags | |
374 | (rather than defaulting to | |
375 | .BR MS_RELATIME ). | |
a4222367 | 376 | .PP |
5ea1abf8 MK |
377 | Since Linux 2.6.26, the |
378 | .B MS_RMOUNT | |
379 | flag can be used with | |
c84a8779 | 380 | .B MS_BIND |
a4222367 | 381 | to modify only the per-mount-point flags. |
f5da58a8 | 382 | .\" See https://lwn.net/Articles/281157/ |
c84a8779 N |
383 | This is particularly useful for setting or clearing the "read-only" |
384 | flag on a mount point without changing the underlying filesystem. | |
385 | Specifying | |
f5da58a8 MK |
386 | .IR mountflags |
387 | as: | |
a4222367 | 388 | .PP |
e56ab30d MK |
389 | .in +4n |
390 | .EX | |
391 | MS_REMOUNT | MS_BIND | MS_RDONLY | |
392 | .EE | |
393 | .in | |
a4222367 | 394 | .PP |
c84a8779 N |
395 | will make access through this mountpoint read-only, without affecting |
396 | other mount points. | |
f429fadc MK |
397 | .\" |
398 | .SS Creating a bind mount | |
399 | If | |
400 | .I mountflags | |
401 | includes | |
402 | .BR MS_BIND | |
403 | (available since Linux 2.4), | |
404 | .\" since 2.4.0-test9 | |
405 | then perform a bind mount. | |
406 | A bind mount makes a file or a directory subtree visible at | |
407 | another point within the single directory hierarchy. | |
408 | Bind mounts may cross filesystem boundaries and span | |
409 | .BR chroot (2) | |
410 | jails. | |
547ee319 | 411 | .PP |
f429fadc MK |
412 | The |
413 | .IR filesystemtype | |
02a4e226 | 414 | and |
f429fadc MK |
415 | .IR data |
416 | arguments are ignored. | |
547ee319 | 417 | .PP |
f429fadc MK |
418 | The remaining bits in the |
419 | .I mountflags | |
420 | argument are also ignored, with the exception of | |
421 | .BR MS_REC . | |
422 | (The bind mount has the same mount options as | |
423 | the underlying mount point.) | |
424 | However, see the discussion of remounting above, | |
425 | for a method of making an existing bind mount read-only. | |
547ee319 | 426 | .PP |
eac1e050 MK |
427 | By default, when a directory is bind mounted, |
428 | only that directory is mounted; | |
429 | if there are any submounts under the directory tree, | |
430 | they are not bind mounted. | |
431 | If the | |
432 | .BR MS_REC | |
433 | flag is also specified, then a recursive bind mount operation is performed: | |
434 | all submounts under the | |
435 | .I source | |
436 | subtree (other than unbindable mounts) | |
437 | are also bind mounted at the corresponding location in the | |
438 | .I target | |
439 | subtree. | |
f429fadc MK |
440 | .\" |
441 | .SS Changing the propagation type of an existing mount | |
c8e5f558 MK |
442 | If |
443 | .IR mountflags | |
444 | includes one of | |
445 | .BR MS_SHARED , | |
446 | .BR MS_PRIVATE , | |
447 | .BR MS_SLAVE , | |
448 | or | |
449 | .BR MS_UNBINDABLE | |
450 | (all available since Linux 2.6.15), | |
451 | then the propagation type of an existing mount is changed. | |
452 | If more than one of these flags is specified, an error results. | |
547ee319 | 453 | .PP |
c8e5f558 MK |
454 | The only flags that can be used with changing the propagation type are |
455 | .BR MS_REC | |
456 | and | |
457 | .BR MS_SILENT . | |
547ee319 | 458 | .PP |
c8e5f558 MK |
459 | The |
460 | .IR source , | |
461 | .IR filesystemtype , | |
462 | and | |
463 | .IR data | |
464 | arguments are ignored. | |
547ee319 | 465 | .PP |
c8e5f558 MK |
466 | The meanings of the propagation type flags are as follows: |
467 | .TP | |
468 | .BR MS_SHARED | |
469 | Make this mount point shared. | |
470 | Mount and unmount events immediately under this mount point will propagate | |
471 | to the other mount points that are members of this mount's peer group. | |
472 | Propagation here means that the same mount or unmount will automatically | |
473 | occur under all of the other mount points in the peer group. | |
474 | Conversely, mount and unmount events that take place under | |
475 | peer mount points will propagate to this mount point. | |
476 | .TP | |
477 | .BR MS_PRIVATE | |
478 | Make this mount point private. | |
479 | Mount and unmount events do not propagate into or out of this mount point. | |
c8e5f558 MK |
480 | .TP |
481 | .BR MS_SLAVE | |
482 | If this is a shared mount point that is a member of a peer group | |
483 | that contains other members, convert it to a slave mount. | |
484 | If this is a shared mount point that is a member of a peer group | |
485 | that contains no other members, convert it to a private mount. | |
486 | Otherwise, the propagation type of the mount point is left unchanged. | |
054ea65e | 487 | .IP |
c8e5f558 MK |
488 | When a mount point is a slave, |
489 | mount and unmount events propagate into this mount point from | |
490 | the (master) shared peer group of which it was formerly a member. | |
491 | Mount and unmount events under this mount point do not propagate to any peer. | |
054ea65e | 492 | .IP |
c8e5f558 MK |
493 | A mount point can be the slave of another peer group |
494 | while at the same time sharing mount and unmount events | |
495 | with a peer group of which it is a member. | |
496 | .TP | |
497 | .BR MS_UNBINDABLE | |
498 | Make this mount unbindable. | |
499 | This is like a private mount, | |
500 | and in addition this mount can't be bind mounted. | |
501 | When a recursive bind mount | |
bf7bc8b8 | 502 | .RB ( mount () |
c8e5f558 MK |
503 | with the |
504 | .BR MS_BIND | |
505 | and | |
506 | .BR MS_REC | |
507 | flags) is performed on a directory subtree, | |
508 | any bind mounts within the subtree are automatically pruned | |
509 | (i.e., not replicated) | |
510 | when replicating that subtree to produce the target subtree. | |
eac1e050 MK |
511 | .PP |
512 | By default, changing the propagation type affects only the | |
513 | .I target | |
514 | mount point. | |
515 | If the | |
516 | .B MS_REC | |
517 | flag is also specified in | |
518 | .IR mountflags , | |
519 | then the propagation type of all mount points under | |
520 | .IR target | |
521 | is also changed. | |
547ee319 | 522 | .PP |
472bbe3b MK |
523 | For further details regarding mount propagation types |
524 | (including the default propagation type assigned to new mounts), see | |
b7b79845 | 525 | .BR mount_namespaces (7). |
f429fadc MK |
526 | .\" |
527 | .SS Moving a mount | |
528 | If | |
529 | .I mountflags | |
530 | contains the flag | |
4a19136b MK |
531 | .BR MS_MOVE |
532 | (available since Linux 2.4.18), | |
f429fadc MK |
533 | then move a subtree: |
534 | .I source | |
535 | specifies an existing mount point and | |
536 | .I target | |
537 | specifies the new location to which that mount point is to be relocated. | |
538 | The move is atomic: at no point is the subtree unmounted. | |
547ee319 | 539 | .PP |
f429fadc MK |
540 | The remaining bits in the |
541 | .IR mountflags | |
542 | argument are ignored, as are the | |
543 | .IR filesystemtype | |
564d9941 | 544 | and |
f429fadc MK |
545 | .IR data |
546 | arguments. | |
547 | .\" | |
548 | .SS Creating a new mount point | |
549 | If none of | |
550 | .BR MS_REMOUNT , | |
551 | .BR MS_BIND , | |
552 | .BR MS_MOVE , | |
553 | .BR MS_SHARED , | |
554 | .BR MS_PRIVATE , | |
555 | .BR MS_SLAVE , | |
556 | or | |
557 | .BR MS_UNBINDABLE | |
558 | is specified in | |
559 | .IR mountflags , | |
560 | then | |
561 | .BR mount () | |
562 | performs its default action: creating a new mount point. | |
563 | .IR source | |
564 | specifies the source for the new mount point, and | |
565 | .IR target | |
566 | specifies the directory at which to create the mount point. | |
547ee319 | 567 | .PP |
c13182ef | 568 | The |
f429fadc MK |
569 | .I filesystemtype |
570 | and | |
571 | .I data | |
572 | arguments are employed, and further bits may be specified in | |
573 | .IR mountflags | |
574 | to modify the behavior of the call. | |
575 | .\" | |
d282bb24 | 576 | .SH RETURN VALUE |
c13182ef MK |
577 | On success, zero is returned. |
578 | On error, \-1 is returned, and | |
fea681da MK |
579 | .I errno |
580 | is set appropriately. | |
581 | .SH ERRORS | |
582 | The error values given below result from filesystem type independent | |
c13182ef | 583 | errors. |
9ee4a2b6 | 584 | Each filesystem type may have its own special errors and its |
c13182ef | 585 | own special behavior. |
66a9882e | 586 | See the Linux kernel source code for details. |
fea681da MK |
587 | .TP |
588 | .B EACCES | |
c13182ef MK |
589 | A component of a path was not searchable. |
590 | (See also | |
ad7cc990 | 591 | .BR path_resolution (7).) |
9e1ae4f8 MK |
592 | .TP |
593 | .B EACCES | |
594 | Mounting a read-only filesystem was attempted without giving the | |
c13182ef | 595 | .B MS_RDONLY |
8df37e4d | 596 | flag. |
9e1ae4f8 MK |
597 | .TP |
598 | .B EACCES | |
599 | The block device | |
fea681da | 600 | .I source |
9ee4a2b6 | 601 | is located on a filesystem mounted with the |
8df37e4d MK |
602 | .B MS_NODEV |
603 | option. | |
fea681da MK |
604 | .\" mtk: Probably: write permission is required for MS_BIND, with |
605 | .\" the error EPERM if not present; CAP_DAC_OVERRIDE is required. | |
606 | .TP | |
607 | .B EBUSY | |
050f3494 MK |
608 | An attempt was made to stack a new mount directly on |
609 | top of an existing mount point that was created in this | |
610 | mount namespace with the same | |
611 | .I source | |
612 | and | |
613 | .IR target . | |
614 | .TP | |
615 | .B EBUSY | |
9e1ae4f8 MK |
616 | .I source |
617 | cannot be remounted read-only, | |
fea681da | 618 | because it still holds files open for writing. |
9e1ae4f8 | 619 | .TP |
fea681da MK |
620 | .B EFAULT |
621 | One of the pointer arguments points outside the user address space. | |
622 | .TP | |
623 | .B EINVAL | |
624 | .I source | |
625 | had an invalid superblock. | |
9e1ae4f8 MK |
626 | .TP |
627 | .B EINVAL | |
628 | A remount operation | |
8df37e4d MK |
629 | .RB ( MS_REMOUNT ) |
630 | was attempted, but | |
fea681da MK |
631 | .I source |
632 | was not already mounted on | |
633 | .IR target . | |
9e1ae4f8 MK |
634 | .TP |
635 | .B EINVAL | |
636 | A move operation | |
8df37e4d MK |
637 | .RB ( MS_MOVE ) |
638 | was attempted, but | |
fea681da | 639 | .I source |
f81fb444 | 640 | was not a mount point, or was \(aq/\(aq. |
fea681da | 641 | .TP |
c8e5f558 MK |
642 | .B EINVAL |
643 | .I mountflags | |
644 | includes more than one of | |
645 | .BR MS_SHARED , | |
646 | .BR MS_PRIVATE , | |
647 | .BR MS_SLAVE , | |
648 | or | |
649 | .BR MS_UNBINDABLE . | |
650 | .TP | |
651 | .B EINVAL | |
652 | .I mountflags | |
653 | includes | |
654 | .BR MS_SHARED , | |
655 | .BR MS_PRIVATE , | |
656 | .BR MS_SLAVE , | |
657 | or | |
658 | .BR MS_UNBINDABLE | |
659 | and also includes a flag other than | |
660 | .BR MS_REC | |
661 | or | |
662 | .BR MS_SILENT . | |
663 | .TP | |
664 | .BR EINVAL | |
665 | An attempt was made to bind mount an unbindable mount. | |
666 | .TP | |
360d7455 | 667 | .BR EINVAL |
f54c67bf MK |
668 | In an unprivileged mount namespace |
669 | (i.e., a mount namespace owned by a user namespace | |
670 | that was created by an unprivileged user), | |
671 | a bind mount operation | |
360d7455 KF |
672 | .RB ( MS_BIND ) |
673 | was attempted without specifying | |
674 | .RB ( MS_REC ), | |
3484e69f | 675 | which would have revealed the filesystem tree underneath one of |
360d7455 KF |
676 | the submounts of the directory being bound. |
677 | .TP | |
fea681da | 678 | .B ELOOP |
9b9b4a81 | 679 | Too many links encountered during pathname resolution. |
9e1ae4f8 MK |
680 | .TP |
681 | .B ELOOP | |
682 | A move operation was attempted, and | |
fea681da MK |
683 | .I target |
684 | is a descendant of | |
685 | .IR source . | |
686 | .TP | |
687 | .B EMFILE | |
688 | (In case no block device is required:) | |
689 | Table of dummy devices is full. | |
690 | .TP | |
691 | .B ENAMETOOLONG | |
682edefb MK |
692 | A pathname was longer than |
693 | .BR MAXPATHLEN . | |
fea681da MK |
694 | .TP |
695 | .B ENODEV | |
a90440ba | 696 | .I filesystemtype |
fea681da MK |
697 | not configured in the kernel. |
698 | .TP | |
699 | .B ENOENT | |
700 | A pathname was empty or had a nonexistent component. | |
701 | .TP | |
702 | .B ENOMEM | |
703 | The kernel could not allocate a free page to copy filenames or data into. | |
704 | .TP | |
705 | .B ENOTBLK | |
706 | .I source | |
707 | is not a block device (and a device was required). | |
708 | .TP | |
709 | .B ENOTDIR | |
5614f733 MK |
710 | .IR target , |
711 | or a prefix of | |
712 | .IR source , | |
713 | is not a directory. | |
fea681da MK |
714 | .TP |
715 | .B ENXIO | |
716 | The major number of the block device | |
717 | .I source | |
718 | is out of range. | |
719 | .TP | |
720 | .B EPERM | |
721 | The caller does not have the required privileges. | |
9326e678 MK |
722 | .SH VERSIONS |
723 | The definitions of | |
724 | .BR MS_DIRSYNC , | |
725 | .BR MS_MOVE , | |
f429fadc | 726 | .BR MS_PRIVATE , |
9326e678 MK |
727 | .BR MS_REC , |
728 | .BR MS_RELATIME , | |
f429fadc | 729 | .BR MS_SHARED , |
67215694 | 730 | .BR MS_SLAVE , |
a6bfc757 | 731 | .BR MS_STRICTATIME , |
f429fadc MK |
732 | and |
733 | .BR MS_UNBINDABLE | |
33a0ccb2 | 734 | were added to glibc headers in version 2.12. |
f429fadc | 735 | .\" |
d282bb24 | 736 | .SH CONFORMING TO |
5614f733 | 737 | This function is Linux-specific and should not be used in |
fea681da | 738 | programs intended to be portable. |
889829be | 739 | .SH NOTES |
f54e02b4 MK |
740 | Since Linux 2.4 a single filesystem can be mounted at |
741 | multiple mount points, and multiple mounts can be stacked | |
742 | on the same mount point. | |
743 | .\" Multiple mounts on same mount point: since 2.3.99pre7. | |
547ee319 | 744 | .PP |
52f00c05 MK |
745 | The |
746 | .I mountflags | |
747 | argument may have the magic number 0xC0ED (\fBMS_MGC_VAL\fP) | |
748 | in the top 16 bits. | |
749 | (All of the other flags discussed in DESCRIPTION | |
750 | occupy the low order 16 bits of | |
751 | .IR mountflags .) | |
752 | Specifying | |
753 | .BR MS_MGC_VAL | |
754 | was required in kernel versions prior to 2.4, | |
755 | but since Linux 2.4 is no longer required and is ignored if specified. | |
547ee319 | 756 | .PP |
fea681da | 757 | The original |
0daa9e92 | 758 | .B MS_SYNC |
682edefb | 759 | flag was renamed |
0daa9e92 | 760 | .B MS_SYNCHRONOUS |
682edefb MK |
761 | in 1.1.69 |
762 | when a different | |
0daa9e92 | 763 | .B MS_SYNC |
682edefb | 764 | was added to \fI<mman.h>\fP. |
dd3568a1 | 765 | .PP |
880f5b4b | 766 | Before Linux 2.4 an attempt to execute a set-user-ID or set-group-ID program |
9ee4a2b6 | 767 | on a filesystem mounted with |
fea681da MK |
768 | .B MS_NOSUID |
769 | would fail with | |
770 | .BR EPERM . | |
c13182ef | 771 | Since Linux 2.4 the set-user-ID and set-group-ID bits are |
880f5b4b | 772 | just silently ignored in this case. |
fea681da | 773 | .\" The change is in patch-2.4.0-prerelease. |
f54e02b4 | 774 | .\" |
29a68c5b | 775 | .SS Per-process namespaces |
4df2eb09 | 776 | Starting with kernel 2.4.19, Linux provides |
732e54dd | 777 | per-process mount namespaces. |
9ee4a2b6 | 778 | A mount namespace is the set of filesystem mounts that |
4df2eb09 MK |
779 | are visible to a process. |
780 | Mount-point namespaces can be (and usually are) | |
781 | shared between multiple processes, | |
0a4d78bb MK |
782 | and changes to the namespace (i.e., mounts and unmounts) by one process |
783 | are visible to all other processes sharing the same namespace. | |