]>
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. | |
547ee319 | 169 | .PP |
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 |
c84a8779 N |
364 | Since Linux 2.6.26, this flag can be used with |
365 | .B MS_BIND | |
a4222367 | 366 | to modify only the per-mount-point flags. |
f5da58a8 | 367 | .\" See https://lwn.net/Articles/281157/ |
c84a8779 N |
368 | This is particularly useful for setting or clearing the "read-only" |
369 | flag on a mount point without changing the underlying filesystem. | |
370 | Specifying | |
f5da58a8 MK |
371 | .IR mountflags |
372 | as: | |
a4222367 | 373 | .PP |
f5da58a8 | 374 | MS_REMOUNT | MS_BIND | MS_RDONLY |
a4222367 | 375 | .PP |
c84a8779 N |
376 | will make access through this mountpoint read-only, without affecting |
377 | other mount points. | |
f429fadc MK |
378 | .\" |
379 | .SS Creating a bind mount | |
380 | If | |
381 | .I mountflags | |
382 | includes | |
383 | .BR MS_BIND | |
384 | (available since Linux 2.4), | |
385 | .\" since 2.4.0-test9 | |
386 | then perform a bind mount. | |
387 | A bind mount makes a file or a directory subtree visible at | |
388 | another point within the single directory hierarchy. | |
389 | Bind mounts may cross filesystem boundaries and span | |
390 | .BR chroot (2) | |
391 | jails. | |
547ee319 | 392 | .PP |
f429fadc MK |
393 | The |
394 | .IR filesystemtype | |
02a4e226 | 395 | and |
f429fadc MK |
396 | .IR data |
397 | arguments are ignored. | |
547ee319 | 398 | .PP |
f429fadc MK |
399 | The remaining bits in the |
400 | .I mountflags | |
401 | argument are also ignored, with the exception of | |
402 | .BR MS_REC . | |
403 | (The bind mount has the same mount options as | |
404 | the underlying mount point.) | |
405 | However, see the discussion of remounting above, | |
406 | for a method of making an existing bind mount read-only. | |
547ee319 | 407 | .PP |
eac1e050 MK |
408 | By default, when a directory is bind mounted, |
409 | only that directory is mounted; | |
410 | if there are any submounts under the directory tree, | |
411 | they are not bind mounted. | |
412 | If the | |
413 | .BR MS_REC | |
414 | flag is also specified, then a recursive bind mount operation is performed: | |
415 | all submounts under the | |
416 | .I source | |
417 | subtree (other than unbindable mounts) | |
418 | are also bind mounted at the corresponding location in the | |
419 | .I target | |
420 | subtree. | |
f429fadc MK |
421 | .\" |
422 | .SS Changing the propagation type of an existing mount | |
c8e5f558 MK |
423 | If |
424 | .IR mountflags | |
425 | includes one of | |
426 | .BR MS_SHARED , | |
427 | .BR MS_PRIVATE , | |
428 | .BR MS_SLAVE , | |
429 | or | |
430 | .BR MS_UNBINDABLE | |
431 | (all available since Linux 2.6.15), | |
432 | then the propagation type of an existing mount is changed. | |
433 | If more than one of these flags is specified, an error results. | |
547ee319 | 434 | .PP |
c8e5f558 MK |
435 | The only flags that can be used with changing the propagation type are |
436 | .BR MS_REC | |
437 | and | |
438 | .BR MS_SILENT . | |
547ee319 | 439 | .PP |
c8e5f558 MK |
440 | The |
441 | .IR source , | |
442 | .IR filesystemtype , | |
443 | and | |
444 | .IR data | |
445 | arguments are ignored. | |
547ee319 | 446 | .PP |
c8e5f558 MK |
447 | The meanings of the propagation type flags are as follows: |
448 | .TP | |
449 | .BR MS_SHARED | |
450 | Make this mount point shared. | |
451 | Mount and unmount events immediately under this mount point will propagate | |
452 | to the other mount points that are members of this mount's peer group. | |
453 | Propagation here means that the same mount or unmount will automatically | |
454 | occur under all of the other mount points in the peer group. | |
455 | Conversely, mount and unmount events that take place under | |
456 | peer mount points will propagate to this mount point. | |
457 | .TP | |
458 | .BR MS_PRIVATE | |
459 | Make this mount point private. | |
460 | Mount and unmount events do not propagate into or out of this mount point. | |
c8e5f558 MK |
461 | .TP |
462 | .BR MS_SLAVE | |
463 | If this is a shared mount point that is a member of a peer group | |
464 | that contains other members, convert it to a slave mount. | |
465 | If this is a shared mount point that is a member of a peer group | |
466 | that contains no other members, convert it to a private mount. | |
467 | Otherwise, the propagation type of the mount point is left unchanged. | |
547ee319 | 468 | .PP |
c8e5f558 MK |
469 | When a mount point is a slave, |
470 | mount and unmount events propagate into this mount point from | |
471 | the (master) shared peer group of which it was formerly a member. | |
472 | Mount and unmount events under this mount point do not propagate to any peer. | |
547ee319 | 473 | .PP |
c8e5f558 MK |
474 | A mount point can be the slave of another peer group |
475 | while at the same time sharing mount and unmount events | |
476 | with a peer group of which it is a member. | |
477 | .TP | |
478 | .BR MS_UNBINDABLE | |
479 | Make this mount unbindable. | |
480 | This is like a private mount, | |
481 | and in addition this mount can't be bind mounted. | |
482 | When a recursive bind mount | |
bf7bc8b8 | 483 | .RB ( mount () |
c8e5f558 MK |
484 | with the |
485 | .BR MS_BIND | |
486 | and | |
487 | .BR MS_REC | |
488 | flags) is performed on a directory subtree, | |
489 | any bind mounts within the subtree are automatically pruned | |
490 | (i.e., not replicated) | |
491 | when replicating that subtree to produce the target subtree. | |
eac1e050 MK |
492 | .PP |
493 | By default, changing the propagation type affects only the | |
494 | .I target | |
495 | mount point. | |
496 | If the | |
497 | .B MS_REC | |
498 | flag is also specified in | |
499 | .IR mountflags , | |
500 | then the propagation type of all mount points under | |
501 | .IR target | |
502 | is also changed. | |
547ee319 | 503 | .PP |
472bbe3b MK |
504 | For further details regarding mount propagation types |
505 | (including the default propagation type assigned to new mounts), see | |
b7b79845 | 506 | .BR mount_namespaces (7). |
f429fadc MK |
507 | .\" |
508 | .SS Moving a mount | |
509 | If | |
510 | .I mountflags | |
511 | contains the flag | |
4a19136b MK |
512 | .BR MS_MOVE |
513 | (available since Linux 2.4.18), | |
f429fadc MK |
514 | then move a subtree: |
515 | .I source | |
516 | specifies an existing mount point and | |
517 | .I target | |
518 | specifies the new location to which that mount point is to be relocated. | |
519 | The move is atomic: at no point is the subtree unmounted. | |
547ee319 | 520 | .PP |
f429fadc MK |
521 | The remaining bits in the |
522 | .IR mountflags | |
523 | argument are ignored, as are the | |
524 | .IR filesystemtype | |
564d9941 | 525 | and |
f429fadc MK |
526 | .IR data |
527 | arguments. | |
528 | .\" | |
529 | .SS Creating a new mount point | |
530 | If none of | |
531 | .BR MS_REMOUNT , | |
532 | .BR MS_BIND , | |
533 | .BR MS_MOVE , | |
534 | .BR MS_SHARED , | |
535 | .BR MS_PRIVATE , | |
536 | .BR MS_SLAVE , | |
537 | or | |
538 | .BR MS_UNBINDABLE | |
539 | is specified in | |
540 | .IR mountflags , | |
541 | then | |
542 | .BR mount () | |
543 | performs its default action: creating a new mount point. | |
544 | .IR source | |
545 | specifies the source for the new mount point, and | |
546 | .IR target | |
547 | specifies the directory at which to create the mount point. | |
547ee319 | 548 | .PP |
c13182ef | 549 | The |
f429fadc MK |
550 | .I filesystemtype |
551 | and | |
552 | .I data | |
553 | arguments are employed, and further bits may be specified in | |
554 | .IR mountflags | |
555 | to modify the behavior of the call. | |
556 | .\" | |
d282bb24 | 557 | .SH RETURN VALUE |
c13182ef MK |
558 | On success, zero is returned. |
559 | On error, \-1 is returned, and | |
fea681da MK |
560 | .I errno |
561 | is set appropriately. | |
562 | .SH ERRORS | |
563 | The error values given below result from filesystem type independent | |
c13182ef | 564 | errors. |
9ee4a2b6 | 565 | Each filesystem type may have its own special errors and its |
c13182ef | 566 | own special behavior. |
66a9882e | 567 | See the Linux kernel source code for details. |
fea681da MK |
568 | .TP |
569 | .B EACCES | |
c13182ef MK |
570 | A component of a path was not searchable. |
571 | (See also | |
ad7cc990 | 572 | .BR path_resolution (7).) |
9e1ae4f8 MK |
573 | .TP |
574 | .B EACCES | |
575 | Mounting a read-only filesystem was attempted without giving the | |
c13182ef | 576 | .B MS_RDONLY |
8df37e4d | 577 | flag. |
9e1ae4f8 MK |
578 | .TP |
579 | .B EACCES | |
580 | The block device | |
fea681da | 581 | .I source |
9ee4a2b6 | 582 | is located on a filesystem mounted with the |
8df37e4d MK |
583 | .B MS_NODEV |
584 | option. | |
fea681da MK |
585 | .\" mtk: Probably: write permission is required for MS_BIND, with |
586 | .\" the error EPERM if not present; CAP_DAC_OVERRIDE is required. | |
587 | .TP | |
588 | .B EBUSY | |
050f3494 MK |
589 | An attempt was made to stack a new mount directly on |
590 | top of an existing mount point that was created in this | |
591 | mount namespace with the same | |
592 | .I source | |
593 | and | |
594 | .IR target . | |
595 | .TP | |
596 | .B EBUSY | |
9e1ae4f8 MK |
597 | .I source |
598 | cannot be remounted read-only, | |
fea681da | 599 | because it still holds files open for writing. |
9e1ae4f8 | 600 | .TP |
fea681da MK |
601 | .B EFAULT |
602 | One of the pointer arguments points outside the user address space. | |
603 | .TP | |
604 | .B EINVAL | |
605 | .I source | |
606 | had an invalid superblock. | |
9e1ae4f8 MK |
607 | .TP |
608 | .B EINVAL | |
609 | A remount operation | |
8df37e4d MK |
610 | .RB ( MS_REMOUNT ) |
611 | was attempted, but | |
fea681da MK |
612 | .I source |
613 | was not already mounted on | |
614 | .IR target . | |
9e1ae4f8 MK |
615 | .TP |
616 | .B EINVAL | |
617 | A move operation | |
8df37e4d MK |
618 | .RB ( MS_MOVE ) |
619 | was attempted, but | |
fea681da | 620 | .I source |
f81fb444 | 621 | was not a mount point, or was \(aq/\(aq. |
fea681da | 622 | .TP |
c8e5f558 MK |
623 | .B EINVAL |
624 | .I mountflags | |
625 | includes more than one of | |
626 | .BR MS_SHARED , | |
627 | .BR MS_PRIVATE , | |
628 | .BR MS_SLAVE , | |
629 | or | |
630 | .BR MS_UNBINDABLE . | |
631 | .TP | |
632 | .B EINVAL | |
633 | .I mountflags | |
634 | includes | |
635 | .BR MS_SHARED , | |
636 | .BR MS_PRIVATE , | |
637 | .BR MS_SLAVE , | |
638 | or | |
639 | .BR MS_UNBINDABLE | |
640 | and also includes a flag other than | |
641 | .BR MS_REC | |
642 | or | |
643 | .BR MS_SILENT . | |
644 | .TP | |
645 | .BR EINVAL | |
646 | An attempt was made to bind mount an unbindable mount. | |
647 | .TP | |
360d7455 | 648 | .BR EINVAL |
f54c67bf MK |
649 | In an unprivileged mount namespace |
650 | (i.e., a mount namespace owned by a user namespace | |
651 | that was created by an unprivileged user), | |
652 | a bind mount operation | |
360d7455 KF |
653 | .RB ( MS_BIND ) |
654 | was attempted without specifying | |
655 | .RB ( MS_REC ), | |
3484e69f | 656 | which would have revealed the filesystem tree underneath one of |
360d7455 KF |
657 | the submounts of the directory being bound. |
658 | .TP | |
fea681da | 659 | .B ELOOP |
9b9b4a81 | 660 | Too many links encountered during pathname resolution. |
9e1ae4f8 MK |
661 | .TP |
662 | .B ELOOP | |
663 | A move operation was attempted, and | |
fea681da MK |
664 | .I target |
665 | is a descendant of | |
666 | .IR source . | |
667 | .TP | |
668 | .B EMFILE | |
669 | (In case no block device is required:) | |
670 | Table of dummy devices is full. | |
671 | .TP | |
672 | .B ENAMETOOLONG | |
682edefb MK |
673 | A pathname was longer than |
674 | .BR MAXPATHLEN . | |
fea681da MK |
675 | .TP |
676 | .B ENODEV | |
a90440ba | 677 | .I filesystemtype |
fea681da MK |
678 | not configured in the kernel. |
679 | .TP | |
680 | .B ENOENT | |
681 | A pathname was empty or had a nonexistent component. | |
682 | .TP | |
683 | .B ENOMEM | |
684 | The kernel could not allocate a free page to copy filenames or data into. | |
685 | .TP | |
686 | .B ENOTBLK | |
687 | .I source | |
688 | is not a block device (and a device was required). | |
689 | .TP | |
690 | .B ENOTDIR | |
5614f733 MK |
691 | .IR target , |
692 | or a prefix of | |
693 | .IR source , | |
694 | is not a directory. | |
fea681da MK |
695 | .TP |
696 | .B ENXIO | |
697 | The major number of the block device | |
698 | .I source | |
699 | is out of range. | |
700 | .TP | |
701 | .B EPERM | |
702 | The caller does not have the required privileges. | |
9326e678 MK |
703 | .SH VERSIONS |
704 | The definitions of | |
705 | .BR MS_DIRSYNC , | |
706 | .BR MS_MOVE , | |
f429fadc | 707 | .BR MS_PRIVATE , |
9326e678 MK |
708 | .BR MS_REC , |
709 | .BR MS_RELATIME , | |
f429fadc | 710 | .BR MS_SHARED , |
67215694 | 711 | .BR MS_SLAVE , |
9326e678 | 712 | .BR MS_STRICTATIME |
f429fadc MK |
713 | and |
714 | .BR MS_UNBINDABLE | |
33a0ccb2 | 715 | were added to glibc headers in version 2.12. |
f429fadc | 716 | .\" |
d282bb24 | 717 | .SH CONFORMING TO |
5614f733 | 718 | This function is Linux-specific and should not be used in |
fea681da | 719 | programs intended to be portable. |
889829be | 720 | .SH NOTES |
f54e02b4 MK |
721 | Since Linux 2.4 a single filesystem can be mounted at |
722 | multiple mount points, and multiple mounts can be stacked | |
723 | on the same mount point. | |
724 | .\" Multiple mounts on same mount point: since 2.3.99pre7. | |
547ee319 | 725 | .PP |
52f00c05 MK |
726 | The |
727 | .I mountflags | |
728 | argument may have the magic number 0xC0ED (\fBMS_MGC_VAL\fP) | |
729 | in the top 16 bits. | |
730 | (All of the other flags discussed in DESCRIPTION | |
731 | occupy the low order 16 bits of | |
732 | .IR mountflags .) | |
733 | Specifying | |
734 | .BR MS_MGC_VAL | |
735 | was required in kernel versions prior to 2.4, | |
736 | but since Linux 2.4 is no longer required and is ignored if specified. | |
547ee319 | 737 | .PP |
fea681da | 738 | The original |
0daa9e92 | 739 | .B MS_SYNC |
682edefb | 740 | flag was renamed |
0daa9e92 | 741 | .B MS_SYNCHRONOUS |
682edefb MK |
742 | in 1.1.69 |
743 | when a different | |
0daa9e92 | 744 | .B MS_SYNC |
682edefb | 745 | was added to \fI<mman.h>\fP. |
dd3568a1 | 746 | .PP |
880f5b4b | 747 | Before Linux 2.4 an attempt to execute a set-user-ID or set-group-ID program |
9ee4a2b6 | 748 | on a filesystem mounted with |
fea681da MK |
749 | .B MS_NOSUID |
750 | would fail with | |
751 | .BR EPERM . | |
c13182ef | 752 | Since Linux 2.4 the set-user-ID and set-group-ID bits are |
880f5b4b | 753 | just silently ignored in this case. |
fea681da | 754 | .\" The change is in patch-2.4.0-prerelease. |
f54e02b4 | 755 | .\" |
29a68c5b | 756 | .SS Per-process namespaces |
4df2eb09 | 757 | Starting with kernel 2.4.19, Linux provides |
732e54dd | 758 | per-process mount namespaces. |
9ee4a2b6 | 759 | A mount namespace is the set of filesystem mounts that |
4df2eb09 MK |
760 | are visible to a process. |
761 | Mount-point namespaces can be (and usually are) | |
762 | shared between multiple processes, | |
0a4d78bb MK |
763 | and changes to the namespace (i.e., mounts and unmounts) by one process |
764 | are visible to all other processes sharing the same namespace. | |