]>
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 | .\" |
9ba01802 | 40 | .TH MOUNT 2 2019-03-06 "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 | |
63b0b1a3 MK |
284 | From Linux 2.4 onward, some of the above flags are |
285 | settable on a per-mount basis, | |
286 | while others apply to the superblock of the mounted filesystem, | |
287 | meaning that all mounts of the same filesystem share those flags. | |
288 | (Previously, all of the flags were per-superblock.) | |
289 | .PP | |
290 | The per-mount-point flags are as follows: | |
291 | .IP * 3 | |
292 | Since Linux 2.4: | |
f429fadc MK |
293 | .BR MS_NODEV ", " MS_NOEXEC ", and " MS_NOSUID |
294 | flags are settable on a per-mount-point basis. | |
63b0b1a3 MK |
295 | .IP * |
296 | Since Linux 2.6.16: | |
f429fadc MK |
297 | .B MS_NOATIME |
298 | and | |
63b0b1a3 MK |
299 | .BR MS_NODIRATIME . |
300 | .IP * | |
301 | Since Linux 2.6.20: | |
302 | .BR MS_RELATIME . | |
303 | .PP | |
304 | The following flags are per-superblock: | |
305 | .BR MS_DIRSYNC , | |
306 | .BR MS_LAZYTIME , | |
307 | .BR MS_MANDLOCK , | |
308 | .BR MS_MS_SILENT , | |
309 | and | |
310 | .BR MS_SYNCHRONOUS . | |
311 | .\" And MS_I_VERSION? | |
46183bb0 | 312 | The initial settings of these flags are determined on the first |
63b0b1a3 MK |
313 | mount of the filesystem, and will be shared by all subsequent mounts |
314 | of the same filesystem. | |
315 | Subsequently, the settings of the flags can be changed | |
316 | via a remount operation (see below). | |
317 | Such changes will be visible via all mount points associated | |
318 | with the filesystem. | |
319 | .PP | |
c84a8779 N |
320 | Since Linux 2.6.16, |
321 | .B MS_RDONLY | |
322 | can be set or cleared on a per-mount-point basis as well as on | |
63b0b1a3 | 323 | the underlying filesystem superblock. |
9edbd686 MK |
324 | The mounted filesystem will be writable only if neither the filesystem |
325 | nor the mountpoint are flagged as read-only. | |
f429fadc MK |
326 | .\" |
327 | .SS Remounting an existing mount | |
328 | An existing mount may be remounted by specifying | |
fea681da | 329 | .B MS_REMOUNT |
f429fadc MK |
330 | in |
331 | .IR mountflags . | |
599e5da7 | 332 | This allows you to change the |
fea681da MK |
333 | .I mountflags |
334 | and | |
335 | .I data | |
9ee4a2b6 | 336 | of an existing mount without having to unmount and remount the filesystem. |
fea681da | 337 | .I target |
44535dd2 | 338 | should be the same value specified in the initial |
fea681da | 339 | .BR mount () |
74b46b5f | 340 | call. |
547ee319 | 341 | .PP |
74b46b5f | 342 | The |
44535dd2 MK |
343 | .I source |
344 | and | |
fea681da | 345 | .I filesystemtype |
74b46b5f | 346 | arguments are ignored. |
547ee319 | 347 | .PP |
69b6b231 EB |
348 | The |
349 | .I mountflags | |
350 | and | |
351 | .I data | |
352 | arguments should match the values used in the original | |
353 | .BR mount () | |
354 | call, except for those parameters that are being deliberately changed. | |
a4222367 | 355 | .PP |
178b977b | 356 | The following |
c13182ef | 357 | .I mountflags |
178b977b | 358 | can be changed: |
9c2678e6 | 359 | .BR MS_LAZYTIME , |
495a1a89 MK |
360 | .\" FIXME |
361 | .\" MS_LAZYTIME seems to be available only on a few filesystems, | |
362 | .\" and on ext4, it seems (from experiment that this flag | |
363 | .\" can only be enabled (but not disabled) on a remount. | |
364 | .\" The following code in ext4_remount() (kernel 4.17) seems to | |
365 | .\" confirm this: | |
366 | .\" | |
367 | .\" if (*flags & SB_LAZYTIME) | |
368 | .\" sb->s_flags |= SB_LAZYTIME; | |
014b17c6 MK |
369 | .BR MS_MANDLOCK , |
370 | .BR MS_NOATIME , | |
178b977b | 371 | .BR MS_NODEV , |
014b17c6 MK |
372 | .BR MS_NODIRATIME , |
373 | .BR MS_NOEXEC , | |
374 | .BR MS_NOSUID , | |
9c2678e6 | 375 | .BR MS_RELATIME , |
014b17c6 | 376 | .BR MS_RDONLY , |
849971a1 MK |
377 | .BR MS_STRICTATIME |
378 | (whose effect is to clear the | |
379 | .BR MS_NOATIME | |
380 | and | |
381 | .BR MS_RELATIME | |
382 | flags), | |
16008a41 | 383 | and |
014b17c6 | 384 | .BR MS_SYNCHRONOUS . |
d8b67bc9 | 385 | Attempts to change the setting of the |
e0a21e13 | 386 | .\" See the definition of MS_RMT_MASK in include/uapi/linux/fs.h, |
f66b1d8b MK |
387 | .\" which excludes MS_DIRSYNC and MS_SILENT, although SB_DIRSYNC |
388 | .\" and SB_SILENT are split out as per-superblock flags in do_mount() | |
389 | .\" (Linux 4.17 source code) | |
d8b67bc9 | 390 | .BR MS_DIRSYNC |
f66b1d8b MK |
391 | and |
392 | .BR MS_SILENT | |
393 | flags during a remount are silently ignored. | |
38ea2e76 MK |
394 | Note that changes to per-superblock flags are visible via |
395 | all mount points of the associated filesystem | |
396 | (because the per-superblock flags are shared by all mount points). | |
547ee319 | 397 | .PP |
49f68546 MK |
398 | Since Linux 3.17, |
399 | .\" commit ffbc6f0ead47fa5a1dc9642b0331cb75c20a640e | |
400 | if none of | |
401 | .BR MS_NOATIME , | |
402 | .BR MS_NODIRATIME , | |
403 | .BR MS_RELATIME , | |
404 | or | |
405 | .BR MS_STRICTATIME | |
406 | is specified in | |
407 | .IR mountflags , | |
408 | then the remount operation preserves the existing values of these flags | |
409 | (rather than defaulting to | |
410 | .BR MS_RELATIME ). | |
a4222367 | 411 | .PP |
5ea1abf8 MK |
412 | Since Linux 2.6.26, the |
413 | .B MS_RMOUNT | |
414 | flag can be used with | |
c84a8779 | 415 | .B MS_BIND |
a4222367 | 416 | to modify only the per-mount-point flags. |
f5da58a8 | 417 | .\" See https://lwn.net/Articles/281157/ |
c84a8779 N |
418 | This is particularly useful for setting or clearing the "read-only" |
419 | flag on a mount point without changing the underlying filesystem. | |
420 | Specifying | |
f5da58a8 MK |
421 | .IR mountflags |
422 | as: | |
a4222367 | 423 | .PP |
e56ab30d MK |
424 | .in +4n |
425 | .EX | |
426 | MS_REMOUNT | MS_BIND | MS_RDONLY | |
427 | .EE | |
428 | .in | |
a4222367 | 429 | .PP |
c84a8779 N |
430 | will make access through this mountpoint read-only, without affecting |
431 | other mount points. | |
f429fadc MK |
432 | .\" |
433 | .SS Creating a bind mount | |
434 | If | |
435 | .I mountflags | |
436 | includes | |
437 | .BR MS_BIND | |
438 | (available since Linux 2.4), | |
439 | .\" since 2.4.0-test9 | |
440 | then perform a bind mount. | |
441 | A bind mount makes a file or a directory subtree visible at | |
442 | another point within the single directory hierarchy. | |
443 | Bind mounts may cross filesystem boundaries and span | |
444 | .BR chroot (2) | |
445 | jails. | |
547ee319 | 446 | .PP |
f429fadc MK |
447 | The |
448 | .IR filesystemtype | |
02a4e226 | 449 | and |
f429fadc MK |
450 | .IR data |
451 | arguments are ignored. | |
547ee319 | 452 | .PP |
fca61050 MK |
453 | The remaining bits (other than |
454 | .BR MS_REC , | |
455 | described below) in the | |
f429fadc | 456 | .I mountflags |
fca61050 | 457 | argument are also ignored. |
f429fadc MK |
458 | (The bind mount has the same mount options as |
459 | the underlying mount point.) | |
460 | However, see the discussion of remounting above, | |
461 | for a method of making an existing bind mount read-only. | |
547ee319 | 462 | .PP |
eac1e050 MK |
463 | By default, when a directory is bind mounted, |
464 | only that directory is mounted; | |
465 | if there are any submounts under the directory tree, | |
466 | they are not bind mounted. | |
467 | If the | |
468 | .BR MS_REC | |
469 | flag is also specified, then a recursive bind mount operation is performed: | |
470 | all submounts under the | |
471 | .I source | |
472 | subtree (other than unbindable mounts) | |
473 | are also bind mounted at the corresponding location in the | |
474 | .I target | |
475 | subtree. | |
f429fadc MK |
476 | .\" |
477 | .SS Changing the propagation type of an existing mount | |
c8e5f558 MK |
478 | If |
479 | .IR mountflags | |
480 | includes one of | |
481 | .BR MS_SHARED , | |
482 | .BR MS_PRIVATE , | |
483 | .BR MS_SLAVE , | |
484 | or | |
485 | .BR MS_UNBINDABLE | |
486 | (all available since Linux 2.6.15), | |
487 | then the propagation type of an existing mount is changed. | |
488 | If more than one of these flags is specified, an error results. | |
547ee319 | 489 | .PP |
158c5bc0 MK |
490 | The only other flags that can be specified while changing |
491 | the propagation type are | |
c8e5f558 | 492 | .BR MS_REC |
2008f97d | 493 | (described below) and |
182c1e83 MK |
494 | .BR MS_SILENT |
495 | (which is ignored). | |
547ee319 | 496 | .PP |
c8e5f558 MK |
497 | The |
498 | .IR source , | |
499 | .IR filesystemtype , | |
500 | and | |
501 | .IR data | |
502 | arguments are ignored. | |
547ee319 | 503 | .PP |
c8e5f558 MK |
504 | The meanings of the propagation type flags are as follows: |
505 | .TP | |
506 | .BR MS_SHARED | |
507 | Make this mount point shared. | |
508 | Mount and unmount events immediately under this mount point will propagate | |
509 | to the other mount points that are members of this mount's peer group. | |
510 | Propagation here means that the same mount or unmount will automatically | |
511 | occur under all of the other mount points in the peer group. | |
512 | Conversely, mount and unmount events that take place under | |
513 | peer mount points will propagate to this mount point. | |
514 | .TP | |
515 | .BR MS_PRIVATE | |
516 | Make this mount point private. | |
517 | Mount and unmount events do not propagate into or out of this mount point. | |
c8e5f558 MK |
518 | .TP |
519 | .BR MS_SLAVE | |
520 | If this is a shared mount point that is a member of a peer group | |
521 | that contains other members, convert it to a slave mount. | |
522 | If this is a shared mount point that is a member of a peer group | |
523 | that contains no other members, convert it to a private mount. | |
524 | Otherwise, the propagation type of the mount point is left unchanged. | |
054ea65e | 525 | .IP |
c8e5f558 MK |
526 | When a mount point is a slave, |
527 | mount and unmount events propagate into this mount point from | |
528 | the (master) shared peer group of which it was formerly a member. | |
529 | Mount and unmount events under this mount point do not propagate to any peer. | |
054ea65e | 530 | .IP |
c8e5f558 MK |
531 | A mount point can be the slave of another peer group |
532 | while at the same time sharing mount and unmount events | |
533 | with a peer group of which it is a member. | |
534 | .TP | |
535 | .BR MS_UNBINDABLE | |
536 | Make this mount unbindable. | |
537 | This is like a private mount, | |
538 | and in addition this mount can't be bind mounted. | |
539 | When a recursive bind mount | |
bf7bc8b8 | 540 | .RB ( mount () |
c8e5f558 MK |
541 | with the |
542 | .BR MS_BIND | |
543 | and | |
544 | .BR MS_REC | |
545 | flags) is performed on a directory subtree, | |
d70a2e57 | 546 | any unbindable mounts within the subtree are automatically pruned |
c8e5f558 MK |
547 | (i.e., not replicated) |
548 | when replicating that subtree to produce the target subtree. | |
eac1e050 MK |
549 | .PP |
550 | By default, changing the propagation type affects only the | |
551 | .I target | |
552 | mount point. | |
553 | If the | |
554 | .B MS_REC | |
555 | flag is also specified in | |
556 | .IR mountflags , | |
557 | then the propagation type of all mount points under | |
558 | .IR target | |
559 | is also changed. | |
547ee319 | 560 | .PP |
472bbe3b MK |
561 | For further details regarding mount propagation types |
562 | (including the default propagation type assigned to new mounts), see | |
b7b79845 | 563 | .BR mount_namespaces (7). |
f429fadc MK |
564 | .\" |
565 | .SS Moving a mount | |
566 | If | |
567 | .I mountflags | |
568 | contains the flag | |
4a19136b MK |
569 | .BR MS_MOVE |
570 | (available since Linux 2.4.18), | |
f429fadc MK |
571 | then move a subtree: |
572 | .I source | |
573 | specifies an existing mount point and | |
574 | .I target | |
575 | specifies the new location to which that mount point is to be relocated. | |
576 | The move is atomic: at no point is the subtree unmounted. | |
547ee319 | 577 | .PP |
f429fadc MK |
578 | The remaining bits in the |
579 | .IR mountflags | |
580 | argument are ignored, as are the | |
581 | .IR filesystemtype | |
564d9941 | 582 | and |
f429fadc MK |
583 | .IR data |
584 | arguments. | |
585 | .\" | |
586 | .SS Creating a new mount point | |
587 | If none of | |
588 | .BR MS_REMOUNT , | |
589 | .BR MS_BIND , | |
590 | .BR MS_MOVE , | |
591 | .BR MS_SHARED , | |
592 | .BR MS_PRIVATE , | |
593 | .BR MS_SLAVE , | |
594 | or | |
595 | .BR MS_UNBINDABLE | |
596 | is specified in | |
597 | .IR mountflags , | |
598 | then | |
599 | .BR mount () | |
600 | performs its default action: creating a new mount point. | |
601 | .IR source | |
602 | specifies the source for the new mount point, and | |
603 | .IR target | |
604 | specifies the directory at which to create the mount point. | |
547ee319 | 605 | .PP |
c13182ef | 606 | The |
f429fadc MK |
607 | .I filesystemtype |
608 | and | |
609 | .I data | |
610 | arguments are employed, and further bits may be specified in | |
611 | .IR mountflags | |
612 | to modify the behavior of the call. | |
613 | .\" | |
d282bb24 | 614 | .SH RETURN VALUE |
c13182ef MK |
615 | On success, zero is returned. |
616 | On error, \-1 is returned, and | |
fea681da MK |
617 | .I errno |
618 | is set appropriately. | |
619 | .SH ERRORS | |
620 | The error values given below result from filesystem type independent | |
c13182ef | 621 | errors. |
9ee4a2b6 | 622 | Each filesystem type may have its own special errors and its |
c13182ef | 623 | own special behavior. |
66a9882e | 624 | See the Linux kernel source code for details. |
fea681da MK |
625 | .TP |
626 | .B EACCES | |
c13182ef MK |
627 | A component of a path was not searchable. |
628 | (See also | |
ad7cc990 | 629 | .BR path_resolution (7).) |
9e1ae4f8 MK |
630 | .TP |
631 | .B EACCES | |
632 | Mounting a read-only filesystem was attempted without giving the | |
c13182ef | 633 | .B MS_RDONLY |
8df37e4d | 634 | flag. |
ed6d1908 MK |
635 | .IP |
636 | The file system may be read-only for various reasons, including: | |
637 | it resides on a read-only optical disk; | |
638 | it is resides on a device with a physical switch that has been set to | |
639 | mark the device read-only; | |
640 | the filesystem implementation was compiled with read-only support; | |
641 | or errors were detected when initially mounting the filesystem, | |
642 | so that it was marked read-only | |
643 | and can't be remounted as read-write (until the errors are fixed). | |
1c1ccb2c MK |
644 | .IP |
645 | Some filesystems instead return the error | |
646 | .BR EROFS | |
647 | on an attempt to mount a read-only filesystem. | |
9e1ae4f8 MK |
648 | .TP |
649 | .B EACCES | |
650 | The block device | |
fea681da | 651 | .I source |
9ee4a2b6 | 652 | is located on a filesystem mounted with the |
8df37e4d MK |
653 | .B MS_NODEV |
654 | option. | |
fea681da MK |
655 | .\" mtk: Probably: write permission is required for MS_BIND, with |
656 | .\" the error EPERM if not present; CAP_DAC_OVERRIDE is required. | |
657 | .TP | |
658 | .B EBUSY | |
050f3494 MK |
659 | An attempt was made to stack a new mount directly on |
660 | top of an existing mount point that was created in this | |
661 | mount namespace with the same | |
662 | .I source | |
663 | and | |
664 | .IR target . | |
665 | .TP | |
666 | .B EBUSY | |
9e1ae4f8 MK |
667 | .I source |
668 | cannot be remounted read-only, | |
fea681da | 669 | because it still holds files open for writing. |
9e1ae4f8 | 670 | .TP |
fea681da MK |
671 | .B EFAULT |
672 | One of the pointer arguments points outside the user address space. | |
673 | .TP | |
674 | .B EINVAL | |
675 | .I source | |
676 | had an invalid superblock. | |
9e1ae4f8 MK |
677 | .TP |
678 | .B EINVAL | |
679 | A remount operation | |
8df37e4d MK |
680 | .RB ( MS_REMOUNT ) |
681 | was attempted, but | |
fea681da MK |
682 | .I source |
683 | was not already mounted on | |
684 | .IR target . | |
9e1ae4f8 MK |
685 | .TP |
686 | .B EINVAL | |
687 | A move operation | |
8df37e4d MK |
688 | .RB ( MS_MOVE ) |
689 | was attempted, but | |
fea681da | 690 | .I source |
f81fb444 | 691 | was not a mount point, or was \(aq/\(aq. |
fea681da | 692 | .TP |
c8e5f558 MK |
693 | .B EINVAL |
694 | .I mountflags | |
695 | includes more than one of | |
696 | .BR MS_SHARED , | |
697 | .BR MS_PRIVATE , | |
698 | .BR MS_SLAVE , | |
699 | or | |
700 | .BR MS_UNBINDABLE . | |
701 | .TP | |
702 | .B EINVAL | |
703 | .I mountflags | |
704 | includes | |
705 | .BR MS_SHARED , | |
706 | .BR MS_PRIVATE , | |
707 | .BR MS_SLAVE , | |
708 | or | |
709 | .BR MS_UNBINDABLE | |
710 | and also includes a flag other than | |
711 | .BR MS_REC | |
712 | or | |
713 | .BR MS_SILENT . | |
714 | .TP | |
715 | .BR EINVAL | |
716 | An attempt was made to bind mount an unbindable mount. | |
717 | .TP | |
360d7455 | 718 | .BR EINVAL |
f54c67bf MK |
719 | In an unprivileged mount namespace |
720 | (i.e., a mount namespace owned by a user namespace | |
721 | that was created by an unprivileged user), | |
722 | a bind mount operation | |
360d7455 KF |
723 | .RB ( MS_BIND ) |
724 | was attempted without specifying | |
725 | .RB ( MS_REC ), | |
3484e69f | 726 | which would have revealed the filesystem tree underneath one of |
360d7455 KF |
727 | the submounts of the directory being bound. |
728 | .TP | |
fea681da | 729 | .B ELOOP |
9b9b4a81 | 730 | Too many links encountered during pathname resolution. |
9e1ae4f8 MK |
731 | .TP |
732 | .B ELOOP | |
733 | A move operation was attempted, and | |
fea681da MK |
734 | .I target |
735 | is a descendant of | |
736 | .IR source . | |
737 | .TP | |
738 | .B EMFILE | |
739 | (In case no block device is required:) | |
740 | Table of dummy devices is full. | |
741 | .TP | |
742 | .B ENAMETOOLONG | |
682edefb MK |
743 | A pathname was longer than |
744 | .BR MAXPATHLEN . | |
fea681da MK |
745 | .TP |
746 | .B ENODEV | |
a90440ba | 747 | .I filesystemtype |
fea681da MK |
748 | not configured in the kernel. |
749 | .TP | |
750 | .B ENOENT | |
751 | A pathname was empty or had a nonexistent component. | |
752 | .TP | |
753 | .B ENOMEM | |
754 | The kernel could not allocate a free page to copy filenames or data into. | |
755 | .TP | |
756 | .B ENOTBLK | |
757 | .I source | |
758 | is not a block device (and a device was required). | |
759 | .TP | |
760 | .B ENOTDIR | |
5614f733 MK |
761 | .IR target , |
762 | or a prefix of | |
763 | .IR source , | |
764 | is not a directory. | |
fea681da MK |
765 | .TP |
766 | .B ENXIO | |
767 | The major number of the block device | |
768 | .I source | |
769 | is out of range. | |
770 | .TP | |
771 | .B EPERM | |
772 | The caller does not have the required privileges. | |
1c1ccb2c MK |
773 | .TP |
774 | .B EROFS | |
775 | Mounting a read-only filesystem was attempted without giving the | |
776 | .B MS_RDONLY | |
777 | flag. | |
778 | See | |
779 | .BR EACCES , | |
780 | above. | |
9326e678 MK |
781 | .SH VERSIONS |
782 | The definitions of | |
783 | .BR MS_DIRSYNC , | |
784 | .BR MS_MOVE , | |
f429fadc | 785 | .BR MS_PRIVATE , |
9326e678 MK |
786 | .BR MS_REC , |
787 | .BR MS_RELATIME , | |
f429fadc | 788 | .BR MS_SHARED , |
67215694 | 789 | .BR MS_SLAVE , |
a6bfc757 | 790 | .BR MS_STRICTATIME , |
f429fadc MK |
791 | and |
792 | .BR MS_UNBINDABLE | |
33a0ccb2 | 793 | were added to glibc headers in version 2.12. |
f429fadc | 794 | .\" |
d282bb24 | 795 | .SH CONFORMING TO |
5614f733 | 796 | This function is Linux-specific and should not be used in |
fea681da | 797 | programs intended to be portable. |
889829be | 798 | .SH NOTES |
f54e02b4 MK |
799 | Since Linux 2.4 a single filesystem can be mounted at |
800 | multiple mount points, and multiple mounts can be stacked | |
801 | on the same mount point. | |
802 | .\" Multiple mounts on same mount point: since 2.3.99pre7. | |
547ee319 | 803 | .PP |
52f00c05 MK |
804 | The |
805 | .I mountflags | |
806 | argument may have the magic number 0xC0ED (\fBMS_MGC_VAL\fP) | |
807 | in the top 16 bits. | |
808 | (All of the other flags discussed in DESCRIPTION | |
809 | occupy the low order 16 bits of | |
810 | .IR mountflags .) | |
811 | Specifying | |
812 | .BR MS_MGC_VAL | |
813 | was required in kernel versions prior to 2.4, | |
814 | but since Linux 2.4 is no longer required and is ignored if specified. | |
547ee319 | 815 | .PP |
fea681da | 816 | The original |
0daa9e92 | 817 | .B MS_SYNC |
682edefb | 818 | flag was renamed |
0daa9e92 | 819 | .B MS_SYNCHRONOUS |
682edefb MK |
820 | in 1.1.69 |
821 | when a different | |
0daa9e92 | 822 | .B MS_SYNC |
682edefb | 823 | was added to \fI<mman.h>\fP. |
dd3568a1 | 824 | .PP |
880f5b4b | 825 | Before Linux 2.4 an attempt to execute a set-user-ID or set-group-ID program |
9ee4a2b6 | 826 | on a filesystem mounted with |
fea681da MK |
827 | .B MS_NOSUID |
828 | would fail with | |
829 | .BR EPERM . | |
c13182ef | 830 | Since Linux 2.4 the set-user-ID and set-group-ID bits are |
880f5b4b | 831 | just silently ignored in this case. |
fea681da | 832 | .\" The change is in patch-2.4.0-prerelease. |
f54e02b4 | 833 | .\" |
29a68c5b | 834 | .SS Per-process namespaces |
4df2eb09 | 835 | Starting with kernel 2.4.19, Linux provides |
732e54dd | 836 | per-process mount namespaces. |
9ee4a2b6 | 837 | A mount namespace is the set of filesystem mounts that |
4df2eb09 MK |
838 | are visible to a process. |
839 | Mount-point namespaces can be (and usually are) | |
840 | shared between multiple processes, | |
0a4d78bb MK |
841 | and changes to the namespace (i.e., mounts and unmounts) by one process |
842 | are visible to all other processes sharing the same namespace. | |