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