Debian Codegraph @

upstream/debian-unstable/man2/mount.2

raw
1 .\" Copyright 1993, Rickard E. Faith <[email protected]>
2 .\" Copyright 1994, Andries E. Brouwer <[email protected]>
3 .\" Copyright 2002-2016, Michael Kerrisk <[email protected]>
4 .\" Copyright, the authors of the Linux man-pages project
5 .\"
6 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .\"
8 .TH mount 2 2026-02-11 "Linux man-pages 6.18"
9 .SH NAME
10 mount \- mount filesystem
11 .SH LIBRARY
12 Standard C library
13 .RI ( libc ,\~ \-lc )
14 .SH SYNOPSIS
15 .nf
16 .B "#include <sys/mount.h>"
17 .P
18 .BI "int mount(const char *" source ", const char *" target ,
19 .BI " const char *" filesystemtype ", unsigned long " mountflags ,
20 .BI " const void *_Nullable " data );
21 .fi
22 .SH DESCRIPTION
23 .BR mount ()
24 attaches the filesystem specified by
25 .I source
26 (which is often a pathname referring to a device,
27 but can also be the pathname of a directory or file,
28 or a dummy string) to the location (a directory or file)
29 specified by the pathname in
30 .IR target .
31 .P
32 Appropriate privilege (Linux: the
33 .B CAP_SYS_ADMIN
34 capability) is required to mount filesystems.
35 .P
36 Values for the
37 .I filesystemtype
38 argument supported by the kernel are listed in
39 .I /proc/filesystems
40 (e.g., "btrfs", "ext4", "jfs", "xfs", "vfat", "fuse",
41 "tmpfs", "cgroup", "proc", "mqueue", "nfs", "cifs", "iso9660").
42 Further types may become available when the appropriate modules
43 are loaded.
44 .P
45 The
46 .I data
47 argument is interpreted by the different filesystems.
48 Typically it is a string of comma-separated options
49 understood by this filesystem.
50 See
51 .BR mount (8)
52 for details of the options available for each filesystem type.
53 This argument may be specified as NULL, if there are no options.
54 .P
55 A call to
56 .BR mount ()
57 performs one of a number of general types of operation,
58 depending on the bits specified in
59 .IR mountflags .
60 The choice of which operation to perform is determined by
61 testing the bits set in
62 .IR mountflags ,
63 with the tests being conducted in the order listed here:
64 .IP \[bu] 3
65 Remount an existing mount:
66 .I mountflags
67 includes
68 .BR MS_REMOUNT .
69 .IP \[bu]
70 Create a bind mount:
71 .I mountflags
72 includes
73 .BR MS_BIND .
74 .IP \[bu]
75 Change the propagation type of an existing mount:
76 .I mountflags
77 includes one of
78 .BR MS_SHARED ,
79 .BR MS_PRIVATE ,
80 .BR MS_SLAVE ,
81 or
82 .BR MS_UNBINDABLE .
83 .IP \[bu]
84 Move an existing mount to a new location:
85 .I mountflags
86 includes
87 .BR MS_MOVE .
88 .IP \[bu]
89 Create a new mount:
90 .I mountflags
91 includes none of the above flags.
92 .P
93 Each of these operations is detailed later in this page.
94 Further flags may be specified in
95 .I mountflags
96 to modify the behavior of
97 .BR mount (),
98 as described below.
99 .\"
100 .SS Additional mount flags
101 The list below describes the additional flags that can be specified in
102 .IR mountflags .
103 Note that some operation types ignore some or all of these flags,
104 as described later in this page.
105 .\"
106 .\" FIXME 2.6.25 Added MS_I_VERSION, which needs to be documented.
107 .\" commit 7a224228ed79d587ece2304869000aad1b8e97dd
108 .\" (This is a per-superblock flag)
109 .\"
110 .TP
111 .BR MS_DIRSYNC " (since Linux 2.5.19)"
112 Make directory changes on this filesystem synchronous.
113 (This property can be obtained for individual directories
114 or subtrees using
115 .BR chattr (1).)
116 .TP
117 .BR MS_LAZYTIME " (since Linux 4.0)"
118 .\" commit 0ae45f63d4ef8d8eeec49c7d8b44a1775fff13e8
119 .\" commit fe032c422c5ba562ba9c2d316f55e258e03259c6
120 .\" commit a26f49926da938f47561f386be56a83dd37a496d
121 Reduce on-disk updates of inode timestamps (atime, mtime, ctime)
122 by maintaining these changes only in memory.
123 The on-disk timestamps are updated only when:
124 .RS
125 .IP \[bu] 3
126 the inode needs to be updated for some change unrelated to file timestamps;
127 .IP \[bu]
128 the application employs
129 .BR fsync (2),
130 .BR syncfs (2),
131 or
132 .BR sync (2);
133 .IP \[bu]
134 an undeleted inode is evicted from memory;
135 or
136 .IP \[bu]
137 more than 24 hours have passed since the inode was written to disk.
138 .RE
139 .IP
140 This mount option significantly reduces writes
141 needed to update the inode's timestamps, especially mtime and atime.
142 However, in the event of a system crash, the atime and mtime fields
143 on disk might be out of date by up to 24 hours.
144 .IP
145 Examples of workloads where this option could be of significant benefit
146 include frequent random writes to preallocated files,
147 as well as cases where the
148 .B MS_STRICTATIME
149 mount option is also enabled.
150 (The advantage of combining
151 .B MS_STRICTATIME
152 and
153 .B MS_LAZYTIME
154 is that
155 .BR stat (2)
156 will return the correctly updated atime, but the atime updates
157 will be flushed to disk only in the cases listed above.)
158 .TP
159 .B MS_MANDLOCK
160 Permit mandatory locking on files in this filesystem.
161 (Mandatory locking must still be enabled on a per-file basis,
162 as described in
163 .BR fcntl (2).)
164 Since Linux 4.5,
165 .\" commit 95ace75414f312f9a7b93d873f386987b92a5301
166 this mount option requires the
167 .B CAP_SYS_ADMIN
168 capability and a kernel configured with the
169 .B CONFIG_MANDATORY_FILE_LOCKING
170 option.
171 Mandatory locking has been fully deprecated in Linux 5.15, so
172 this flag should be considered deprecated.
173 .TP
174 .B MS_NOATIME
175 Do not update access times for (all types of) files on this filesystem.
176 .TP
177 .B MS_NODEV
178 Do not allow access to devices (special files) on this filesystem.
179 .TP
180 .B MS_NODIRATIME
181 Do not update access times for directories on this filesystem.
182 This flag provides a subset of the functionality provided by
183 .BR MS_NOATIME ;
184 that is,
185 .B MS_NOATIME
186 implies
187 .BR MS_NODIRATIME .
188 .TP
189 .B MS_NOEXEC
190 Do not allow programs to be executed from this filesystem.
191 .\" (Possibly useful for a filesystem that contains non-Linux executables.
192 .\" Often used as a security feature, e.g., to make sure that restricted
193 .\" users cannot execute files uploaded using ftp or so.)
194 .TP
195 .B MS_NOSUID
196 Do not honor set-user-ID and set-group-ID bits or file capabilities
197 when executing programs from this filesystem.
198 In addition, SELinux domain
199 transitions require the permission
200 .IR nosuid_transition ,
201 which in turn needs
202 also the policy capability
203 .IR nnp_nosuid_transition .
204 .\" (This is a security feature to prevent users executing set-user-ID and
205 .\" set-group-ID programs from removable disk devices.)
206 .TP
207 .B MS_RDONLY
208 Mount filesystem read-only.
209 .TP
210 .BR MS_REC " (since Linux 2.4.11)"
211 Used in conjunction with
212 .B MS_BIND
213 to create a recursive bind mount,
214 and in conjunction with the propagation type flags to recursively change
215 the propagation type of all of the mounts in a subtree.
216 See below for further details.
217 .TP
218 .BR MS_RELATIME " (since Linux 2.6.20)"
219 When a file on this filesystem is accessed,
220 update the file's last access time (atime) only if the current value
221 of atime is less than or equal to the file's last modification time (mtime)
222 or last status change time (ctime).
223 This option is useful for programs, such as
224 .BR mutt (1),
225 that need to know when a file has been read since it was last modified.
226 Since Linux 2.6.30, the kernel defaults to the behavior provided
227 by this flag (unless
228 .B MS_NOATIME
229 was specified), and the
230 .B MS_STRICTATIME
231 flag is required to obtain traditional semantics.
232 In addition, since Linux 2.6.30,
233 the file's last access time is always updated if it
234 is more than 1 day old.
235 .\" Matthew Garrett notes in the patch that added this behavior
236 .\" that this lets utilities such as tmpreaper (which deletes
237 .\" files based on last access time) work correctly.
238 .TP
239 .BR MS_SILENT " (since Linux 2.6.17)"
240 Suppress the display of certain
241 .RI ( printk ())
242 warning messages in the kernel log.
243 This flag supersedes the misnamed and obsolete
244 .B MS_VERBOSE
245 flag (available since Linux 2.4.12), which has the same meaning.
246 .TP
247 .BR MS_STRICTATIME " (since Linux 2.6.30)"
248 Always update the last access time (atime) when files on this
249 filesystem are accessed.
250 (This was the default behavior before Linux 2.6.30.)
251 Specifying this flag overrides the effect of setting the
252 .B MS_NOATIME
253 and
254 .B MS_RELATIME
255 flags.
256 .TP
257 .B MS_SYNCHRONOUS
258 Make writes on this filesystem synchronous (as though
259 the
260 .B O_SYNC
261 flag to
262 .BR open (2)
263 was specified for all file opens to this filesystem).
264 .TP
265 .BR MS_NOSYMFOLLOW " (since Linux 5.10)"
266 .\" dab741e0e02bd3c4f5e2e97be74b39df2523fc6e
267 Do not follow symbolic links when resolving paths.
268 Symbolic links can still be created,
269 and
270 .BR readlink (1),
271 .BR readlink (2),
272 .BR realpath (1),
273 and
274 .BR realpath (3)
275 all still work properly.
276 .P
277 From Linux 2.4 onward, some of the above flags are
278 settable on a per-mount basis,
279 while others apply to the superblock of the mounted filesystem,
280 meaning that all mounts of the same filesystem share those flags.
281 (Previously, all of the flags were per-superblock.)
282 .P
283 The per-mount-point flags are as follows:
284 .IP \[bu] 3
285 Since Linux 2.4:
286 .BR MS_NODEV ", " MS_NOEXEC ", and " MS_NOSUID
287 flags are settable on a per-mount-point basis.
288 .IP \[bu]
289 Additionally, since Linux 2.6.16:
290 .B MS_NOATIME
291 and
292 .BR MS_NODIRATIME .
293 .IP \[bu]
294 Additionally, since Linux 2.6.20:
295 .BR MS_RELATIME .
296 .P
297 The following flags are per-superblock:
298 .BR MS_DIRSYNC ,
299 .BR MS_LAZYTIME ,
300 .BR MS_MANDLOCK ,
301 .BR MS_SILENT ,
302 and
303 .BR MS_SYNCHRONOUS .
304 .\" And MS_I_VERSION?
305 The initial settings of these flags are determined on the first
306 mount of the filesystem, and will be shared by all subsequent mounts
307 of the same filesystem.
308 Subsequently, the settings of the flags can be changed
309 via a remount operation (see below).
310 Such changes will be visible via all mounts associated
311 with the filesystem.
312 .P
313 Since Linux 2.6.16,
314 .B MS_RDONLY
315 can be set or cleared on a per-mount-point basis as well as on
316 the underlying filesystem superblock.
317 The mounted filesystem will be writable only if neither the filesystem
318 nor the mount point are flagged as read-only.
319 .\"
320 .SS Remounting an existing mount
321 An existing mount may be remounted by specifying
322 .B MS_REMOUNT
323 in
324 .IR mountflags .
325 This allows you to change the
326 .I mountflags
327 and
328 .I data
329 of an existing mount without having to unmount and remount the filesystem.
330 .I target
331 should be the same value specified in the initial
332 .BR mount ()
333 call.
334 .P
335 The
336 .I source
337 and
338 .I filesystemtype
339 arguments are ignored.
340 .P
341 The
342 .I mountflags
343 and
344 .I data
345 arguments should match the values used in the original
346 .BR mount ()
347 call, except for those parameters that are being deliberately changed.
348 .P
349 The following
350 .I mountflags
351 can be changed:
352 .BR MS_LAZYTIME ,
353 .\" FIXME
354 .\" MS_LAZYTIME seems to be available only on a few filesystems,
355 .\" and on ext4, it seems (from experiment that this flag
356 .\" can only be enabled (but not disabled) on a remount.
357 .\" The following code in ext4_remount() (kernel 4.17) seems to
358 .\" confirm this:
359 .\"
360 .\" if (*flags & SB_LAZYTIME)
361 .\" sb->s_flags |= SB_LAZYTIME;
362 .BR MS_MANDLOCK ,
363 .BR MS_NOATIME ,
364 .BR MS_NODEV ,
365 .BR MS_NODIRATIME ,
366 .BR MS_NOEXEC ,
367 .BR MS_NOSUID ,
368 .BR MS_RELATIME ,
369 .BR MS_RDONLY ,
370 .B MS_STRICTATIME
371 (whose effect is to clear the
372 .B MS_NOATIME
373 and
374 .B MS_RELATIME
375 flags),
376 and
377 .BR MS_SYNCHRONOUS .
378 Attempts to change the setting of the
379 .\" See the definition of MS_RMT_MASK in include/uapi/linux/fs.h,
380 .\" which excludes MS_DIRSYNC and MS_SILENT, although SB_DIRSYNC
381 .\" and SB_SILENT are split out as per-superblock flags in do_mount()
382 .\" (Linux 4.17 source code)
383 .B MS_DIRSYNC
384 and
385 .B MS_SILENT
386 flags during a remount are silently ignored.
387 Note that changes to per-superblock flags are visible via
388 all mounts of the associated filesystem
389 (because the per-superblock flags are shared by all mounts).
390 .P
391 Since Linux 3.17,
392 .\" commit ffbc6f0ead47fa5a1dc9642b0331cb75c20a640e
393 if none of
394 .BR MS_NOATIME ,
395 .BR MS_NODIRATIME ,
396 .BR MS_RELATIME ,
397 or
398 .B MS_STRICTATIME
399 is specified in
400 .IR mountflags ,
401 then the remount operation preserves the existing values of these flags
402 (rather than defaulting to
403 .BR MS_RELATIME ).
404 .P
405 Since Linux 2.6.26, the
406 .B MS_REMOUNT
407 flag can be used with
408 .B MS_BIND
409 to modify only the per-mount-point flags.
410 .\" See https://lwn.net/Articles/281157/
411 This is particularly useful
412 for setting or clearing the "read-only" flag on a mount
413 without changing the filesystem parameters of the underlying filesystem.
414 The
415 .I data
416 argument is ignored.
417 The existing per-mount-point flags of the mount point
418 are cleared
419 and replaced with those in
420 .IR mountflags .
421 This means that
422 if you wish to preserve
423 any existing per-mount-point flags,
424 you need to include them in
425 .IR mountflags ,
426 along with the per-mount-point flags you wish to set
427 (or with the flags you wish to clear missing).
428 Specifying
429 .I mountflags
430 as:
431 .P
432 .in +4n
433 .EX
434 MS_REMOUNT | MS_BIND | MS_RDONLY
435 .EE
436 .in
437 .P
438 will make access through this mount point read-only
439 (clearing all other per-mount-point flags),
440 without affecting other mounts of this filesystem.
441 .\"
442 .SS Creating a bind mount
443 If
444 .I mountflags
445 includes
446 .B MS_BIND
447 (available since Linux 2.4),
448 .\" since Linux 2.4.0-test9
449 then perform a bind mount.
450 A bind mount makes a file or a directory subtree visible at
451 another point within the single directory hierarchy.
452 Bind mounts may cross filesystem boundaries and span
453 .BR chroot (2)
454 jails.
455 .P
456 The
457 .I filesystemtype
458 and
459 .I data
460 arguments are ignored.
461 .P
462 The remaining bits (other than
463 .BR MS_REC ,
464 described below) in the
465 .I mountflags
466 argument are also ignored.
467 (The bind mount has the same mount options as
468 the underlying mount.)
469 However, see the discussion of remounting above,
470 for a method of making an existing bind mount read-only.
471 .P
472 By default, when a directory is bind mounted,
473 only that directory is mounted;
474 if there are any submounts under the directory tree,
475 they are not bind mounted.
476 If the
477 .B MS_REC
478 flag is also specified, then a recursive bind mount operation is performed:
479 all submounts under the
480 .I source
481 subtree (other than unbindable mounts)
482 are also bind mounted at the corresponding location in the
483 .I target
484 subtree.
485 .\"
486 .SS Changing the propagation type of an existing mount
487 If
488 .I mountflags
489 includes one of
490 .BR MS_SHARED ,
491 .BR MS_PRIVATE ,
492 .BR MS_SLAVE ,
493 or
494 .B MS_UNBINDABLE
495 (all available since Linux 2.6.15),
496 then the propagation type of an existing mount is changed.
497 If more than one of these flags is specified, an error results.
498 .P
499 The only other flags that can be specified while changing
500 the propagation type are
501 .B MS_REC
502 (described below) and
503 .B MS_SILENT
504 (which is ignored).
505 .P
506 The
507 .IR source ,
508 .IR filesystemtype ,
509 and
510 .I data
511 arguments are ignored.
512 .P
513 The meanings of the propagation type flags are as follows:
514 .TP
515 .B MS_SHARED
516 Make this mount shared.
517 Mount and unmount events immediately under this mount will propagate
518 to the other mounts that are members of this mount's peer group.
519 Propagation here means that the same mount or unmount will automatically
520 occur under all of the other mounts in the peer group.
521 Conversely, mount and unmount events that take place under
522 peer mounts will propagate to this mount.
523 .TP
524 .B MS_PRIVATE
525 Make this mount private.
526 Mount and unmount events do not propagate into or out of this mount.
527 .TP
528 .B MS_SLAVE
529 If this is a shared mount that is a member of a peer group
530 that contains other members, convert it to a slave mount.
531 If this is a shared mount that is a member of a peer group
532 that contains no other members, convert it to a private mount.
533 Otherwise, the propagation type of the mount is left unchanged.
534 .IP
535 When a mount is a slave,
536 mount and unmount events propagate into this mount from
537 the (master) shared peer group of which it was formerly a member.
538 Mount and unmount events under this mount do not propagate to any peer.
539 .IP
540 A mount can be the slave of another peer group
541 while at the same time sharing mount and unmount events
542 with a peer group of which it is a member.
543 .TP
544 .B MS_UNBINDABLE
545 Make this mount unbindable.
546 This is like a private mount,
547 and in addition this mount can't be bind mounted.
548 When a recursive bind mount
549 .RB ( mount ()
550 with the
551 .B MS_BIND
552 and
553 .B MS_REC
554 flags) is performed on a directory subtree,
555 any unbindable mounts within the subtree are automatically pruned
556 (i.e., not replicated)
557 when replicating that subtree to produce the target subtree.
558 .P
559 By default, changing the propagation type affects only the
560 .I target
561 mount.
562 If the
563 .B MS_REC
564 flag is also specified in
565 .IR mountflags ,
566 then the propagation type of all mounts under
567 .I target
568 is also changed.
569 .P
570 For further details regarding mount propagation types
571 (including the default propagation type assigned to new mounts), see
572 .BR mount_namespaces (7).
573 .\"
574 .SS Moving a mount
575 If
576 .I mountflags
577 contains the flag
578 .B MS_MOVE
579 (available since Linux 2.4.18),
580 then move a subtree:
581 .I source
582 specifies an existing mount and
583 .I target
584 specifies the new location to which that mount is to be relocated.
585 The move is atomic: at no point is the subtree unmounted.
586 .P
587 The remaining bits in the
588 .I mountflags
589 argument are ignored, as are the
590 .I filesystemtype
591 and
592 .I data
593 arguments.
594 .\"
595 .SS Creating a new mount
596 If none of
597 .BR MS_REMOUNT ,
598 .BR MS_BIND ,
599 .BR MS_MOVE ,
600 .BR MS_SHARED ,
601 .BR MS_PRIVATE ,
602 .BR MS_SLAVE ,
603 or
604 .B MS_UNBINDABLE
605 is specified in
606 .IR mountflags ,
607 then
608 .BR mount ()
609 performs its default action: creating a new mount.
610 .I source
611 specifies the source for the new mount, and
612 .I target
613 specifies the directory at which to create the mount point.
614 .P
615 The
616 .I filesystemtype
617 and
618 .I data
619 arguments are employed, and further bits may be specified in
620 .I mountflags
621 to modify the behavior of the call.
622 .\"
623 .SH RETURN VALUE
624 On success, zero is returned.
625 On error, \-1 is returned, and
626 .I errno
627 is set to indicate the error.
628 .SH ERRORS
629 The error values given below result from filesystem type independent
630 errors.
631 Each filesystem type may have its own special errors and its
632 own special behavior.
633 See the Linux kernel source code for details.
634 .TP
635 .B EACCES
636 A component of a path was not searchable.
637 (See also
638 .BR path_resolution (7).)
639 .TP
640 .B EACCES
641 Mounting a read-only filesystem was attempted without giving the
642 .B MS_RDONLY
643 flag.
644 .IP
645 The filesystem may be read-only for various reasons, including:
646 it resides on a read-only optical disk;
647 it is resides on a device with a physical switch that has been set to
648 mark the device read-only;
649 the filesystem implementation was compiled with read-only support;
650 or errors were detected when initially mounting the filesystem,
651 so that it was marked read-only
652 and can't be remounted as read-write (until the errors are fixed).
653 .IP
654 Some filesystems instead return the error
655 .B EROFS
656 on an attempt to mount a read-only filesystem.
657 .TP
658 .B EACCES
659 The block device
660 .I source
661 is located on a filesystem mounted with the
662 .B MS_NODEV
663 option.
664 .\" mtk: Probably: write permission is required for MS_BIND, with
665 .\" the error EPERM if not present; CAP_DAC_OVERRIDE is required.
666 .TP
667 .B EBUSY
668 An attempt was made to stack a new mount directly on
669 top of an existing mount point that was created in this
670 mount namespace with the same
671 .I source
672 and
673 .IR target .
674 .TP
675 .B EBUSY
676 .I source
677 cannot be remounted read-only,
678 because it still holds files open for writing.
679 .TP
680 .B EFAULT
681 One of the pointer arguments points outside the user address space.
682 .TP
683 .B EINVAL
684 .I source
685 had an invalid superblock.
686 .TP
687 .B EINVAL
688 A remount operation
689 .RB ( MS_REMOUNT )
690 was attempted, but
691 .I source
692 was not already mounted on
693 .IR target .
694 .TP
695 .B EINVAL
696 A move operation
697 .RB ( MS_MOVE )
698 was attempted, but the mount tree under
699 .I source
700 includes unbindable mounts and
701 .I target
702 is a mount that has propagation type
703 .BR MS_SHARED .
704 .TP
705 .B EINVAL
706 A move operation
707 .RB ( MS_MOVE )
708 was attempted, but the parent mount of
709 .I source
710 mount has propagation type
711 .BR MS_SHARED .
712 .TP
713 .B EINVAL
714 A move operation
715 .RB ( MS_MOVE )
716 was attempted, but
717 .I source
718 was not a mount, or was \[aq]/\[aq].
719 .TP
720 .B EINVAL
721 A bind operation
722 .RB ( MS_BIND )
723 was requested where
724 .I source
725 referred a mount namespace magic link (i.e., a
726 .IR /proc/ pid /ns/mnt
727 magic link or a bind mount to such a link)
728 and the propagation type of the parent mount of
729 .I target
730 was
731 .BR MS_SHARED ,
732 .\" See commit 8823c079ba7136dc1948d6f6dcb5f8022bde438e
733 but propagation of the requested bind mount could lead to a circular
734 dependency that might prevent the mount namespace from ever being freed.
735 .TP
736 .B EINVAL
737 .I mountflags
738 includes more than one of
739 .BR MS_SHARED ,
740 .BR MS_PRIVATE ,
741 .BR MS_SLAVE ,
742 or
743 .BR MS_UNBINDABLE .
744 .TP
745 .B EINVAL
746 .I mountflags
747 includes
748 .BR MS_SHARED ,
749 .BR MS_PRIVATE ,
750 .BR MS_SLAVE ,
751 or
752 .B MS_UNBINDABLE
753 and also includes a flag other than
754 .B MS_REC
755 or
756 .BR MS_SILENT .
757 .TP
758 .B EINVAL
759 An attempt was made to bind mount an unbindable mount.
760 .TP
761 .B EINVAL
762 In an unprivileged mount namespace
763 (i.e., a mount namespace owned by a user namespace
764 that was created by an unprivileged user),
765 a bind mount operation
766 .RB ( MS_BIND )
767 was attempted without specifying
768 .RB ( MS_REC ),
769 which would have revealed the filesystem tree underneath one of
770 the submounts of the directory being bound.
771 .TP
772 .B ELOOP
773 Too many links encountered during pathname resolution.
774 .TP
775 .B ELOOP
776 A move operation was attempted, and
777 .I target
778 is a descendant of
779 .IR source .
780 .TP
781 .B EMFILE
782 (In case no block device is required:)
783 Table of dummy devices is full.
784 .TP
785 .B ENAMETOOLONG
786 A pathname was longer than
787 .BR MAXPATHLEN .
788 .TP
789 .B ENODEV
790 .I filesystemtype
791 not configured in the kernel.
792 .TP
793 .B ENOENT
794 A pathname was empty or had a nonexistent component.
795 .TP
796 .B ENOMEM
797 The kernel could not allocate a free page to copy filenames or data into.
798 .TP
799 .B ENOSPC
800 Number of mounts will exceed the limit after this syscall
801 in some mount namespaces.
802 This limit is controlled by
803 .IR /proc/sys/fs/mount-max ,
804 see
805 .BR proc_sys_fs (5)
806 for details of this limit.
807 that this limit applies both
808 to the mount namespace where the mount operation occurs
809 and to any mount namespaces to which the mount will propagate.
810 See
811 .BR mount_namespaces (7)
812 for details of mount namespaces and mount propagation.
813 .TP
814 .B ENOTBLK
815 .I source
816 is not a block device (and a device was required).
817 .TP
818 .B ENOTDIR
819 .IR target ,
820 or a prefix of
821 .IR source ,
822 is not a directory.
823 .TP
824 .B ENXIO
825 The major number of the block device
826 .I source
827 is out of range.
828 .TP
829 .B EPERM
830 The caller does not have the required privileges.
831 .TP
832 .B EPERM
833 An attempt was made to modify
834 .RB ( MS_REMOUNT )
835 the
836 .BR MS_RDONLY ,
837 .BR MS_NOSUID ,
838 or
839 .B MS_NOEXEC
840 flag, or one of the "atime" flags
841 .RB ( MS_NOATIME ,
842 .BR MS_NODIRATIME ,
843 .BR MS_RELATIME )
844 of an existing mount, but the mount is locked;
845 see
846 .BR mount_namespaces (7).
847 .TP
848 .B EROFS
849 Mounting a read-only filesystem was attempted without giving the
850 .B MS_RDONLY
851 flag.
852 See
853 .BR EACCES ,
854 above.
855 .\"
856 .SH STANDARDS
857 Linux.
858 .SH HISTORY
859 The definitions of
860 .BR MS_DIRSYNC ,
861 .BR MS_MOVE ,
862 .BR MS_PRIVATE ,
863 .BR MS_REC ,
864 .BR MS_RELATIME ,
865 .BR MS_SHARED ,
866 .BR MS_SLAVE ,
867 .BR MS_STRICTATIME ,
868 and
869 .B MS_UNBINDABLE
870 were added to glibc headers in glibc 2.12.
871 .P
872 Since Linux 2.4 a single filesystem can be mounted at
873 multiple mount points, and multiple mounts can be stacked
874 on the same mount point.
875 .\" Multiple mounts on same mount point: since Linux 2.3.99pre7.
876 .P
877 The
878 .I mountflags
879 argument may have the magic number 0xC0ED
880 .RB ( MS_MGC_VAL )
881 in the top 16 bits.
882 (All of the other flags discussed in DESCRIPTION
883 occupy the low order 16 bits of
884 .IR mountflags .)
885 Specifying
886 .B MS_MGC_VAL
887 was required before Linux 2.4,
888 but since Linux 2.4 is no longer required and is ignored if specified.
889 .P
890 The original
891 .B MS_SYNC
892 flag was renamed
893 .B MS_SYNCHRONOUS
894 in 1.1.69
895 when a different
896 .B MS_SYNC
897 was added to
898 .IR <mman.h> .
899 .P
900 Before Linux 2.4 an attempt to execute a set-user-ID or set-group-ID program
901 on a filesystem mounted with
902 .B MS_NOSUID
903 would fail with
904 .BR EPERM .
905 Since Linux 2.4 the set-user-ID and set-group-ID bits are
906 just silently ignored in this case.
907 .\" The change is in patch-2.4.0-prerelease.
908 .\"
909 .SH NOTES
910 .SS Mount namespaces
911 Starting with Linux 2.4.19, Linux provides mount namespaces.
912 A mount namespace is the set of filesystem mounts that
913 are visible to a process.
914 Mount namespaces can be (and usually are)
915 shared between multiple processes,
916 and changes to the namespace (i.e., mounts and unmounts) by one process
917 are visible to all other processes sharing the same namespace.
918 (The pre-2.4.19 Linux situation can be considered as one in which
919 a single namespace was shared by every process on the system.)
920 .P
921 A child process created by
922 .BR fork (2)
923 shares its parent's mount namespace;
924 the mount namespace is preserved across an
925 .BR execve (2).
926 .P
927 A process can obtain a private mount namespace if:
928 it was created using the
929 .BR clone (2)
930 .B CLONE_NEWNS
931 flag,
932 in which case its new namespace is initialized to be a
933 .I copy
934 of the namespace of the process that called
935 .BR clone (2);
936 or it calls
937 .BR unshare (2)
938 with the
939 .B CLONE_NEWNS
940 flag,
941 which causes the caller's mount namespace to obtain a private copy
942 of the namespace that it was previously sharing with other processes,
943 so that future mounts and unmounts by the caller are invisible
944 to other processes (except child processes that the caller
945 subsequently creates) and vice versa.
946 .P
947 For further details on mount namespaces, see
948 .BR mount_namespaces (7).
949 .\"
950 .SS Parental relationship between mounts
951 Each mount has a parent mount.
952 The overall parental relationship of all mounts defines
953 the single directory hierarchy seen by the processes within a mount namespace.
954 .P
955 The parent of a new mount is defined when the mount is created.
956 In the usual case,
957 the parent of a new mount is the mount of the filesystem
958 containing the directory or file at which the new mount is attached.
959 In the case where a new mount is stacked on top of an existing mount,
960 the parent of the new mount is the previous mount that was stacked
961 at that location.
962 .P
963 The parental relationship between mounts can be discovered via the
964 .IR /proc/ pid /mountinfo
965 file (see below).
966 .\"
967 .SS \f[I]/proc/\f[]pid\f[I]/mounts\f[] and \f[I]/proc/\f[]pid\f[I]/mountinfo\f[]
968 The Linux-specific
969 .IR /proc/ pid /mounts
970 file exposes the list of mounts in the mount
971 namespace of the process with the specified ID.
972 The
973 .IR /proc/ pid /mountinfo
974 file exposes even more information about mounts,
975 including the propagation type and mount ID information that makes it
976 possible to discover the parental relationship between mounts.
977 See
978 .BR proc (5)
979 and
980 .BR mount_namespaces (7)
981 for details of this file.
982 .SH SEE ALSO
983 .BR mountpoint (1),
984 .BR chroot (2),
985 .BR FS_IOC_SETFLAGS (2const),
986 .BR mount_setattr (2),
987 .BR pivot_root (2),
988 .BR umount (2),
989 .BR mount_namespaces (7),
990 .BR path_resolution (7),
991 .BR findmnt (8),
992 .BR lsblk (8),
993 .BR mount (8),
994 .BR umount (8)