]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/mount.2
mount.2: SEE ALSO: add chroot(2) and pivot_root(2)
[thirdparty/man-pages.git] / man2 / mount.2
CommitLineData
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 42mount \- 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 53attaches the filesystem specified by
fea681da 54.I source
751de899
MK
55(which is often a pathname referring to a device,
56but can also be the pathname of a directory or file,
57or a dummy string) to the location (a directory or file)
58specified by the pathname in
fea681da 59.IR target .
547ee319 60.PP
fea681da
MK
61Appropriate privilege (Linux: the
62.B CAP_SYS_ADMIN
9ee4a2b6 63capability) is required to mount filesystems.
547ee319 64.PP
fea681da 65Values for the
0daa9e92 66.I filesystemtype
fea681da
MK
67argument 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
71Further types may become available when the appropriate modules
72are loaded.
547ee319 73.PP
b3ae9c7d
MK
74The
75.I data
76argument is interpreted by the different filesystems.
77Typically it is a string of comma-separated options
78understood by this filesystem.
79See
80.BR mount (8)
81for details of the options available for each filesystem type.
547ee319 82.PP
f429fadc
MK
83A call to
84.BR mount ()
c3a7b4e9 85performs one of a number of general types of operation,
f429fadc
MK
86depending on the bits specified in
87.IR mountflags .
c3a7b4e9
MK
88The choice of which operation to perform is determined by
89testing the bits set in
f429fadc
MK
90.IR mountflags ,
91with the tests being conducted in the order listed here:
92.IP * 3
93Remount an existing mount:
94.IR mountflags
95includes
96.BR MS_REMOUNT .
97.IP *
98Create a bind mount:
99.IR mountflags
100includes
101.BR MS_BIND .
102.IP *
103Change the propagation type of an existing mount:
104.IR mountflags
105includes one of
106.BR MS_SHARED ,
107.BR MS_PRIVATE ,
108.BR MS_SLAVE ,
109or
110.BR MS_UNBINDABLE .
111.IP *
112Move an existing mount to a new location:
113.IR mountflags
114includes
115.BR MS_MOVE .
116.IP *
117Create a new mount:
118.IR mountflags
119includes none of the above flags.
120.PP
121Each of these operations is detailed later in this page.
122Further flags may be specified in
123.IR mountflags
124to modify the behavior of
125.BR mount (),
126as described below.
2835e6c5 127.\"
f429fadc
MK
128.SS Additional mount flags
129The list below describes the additional flags that can be specified in
130.IR mountflags .
131Note that some operation types ignore some or all of these flags,
132as 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 140Make directory changes on this filesystem synchronous.
fea681da
MK
141(This property can be obtained for individual directories
142or 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
149Reduce on-disk updates of inode timestamps (atime, mtime, ctime)
150by maintaining these changes only in memory.
151The on-disk timestamps are updated only when:
152.RS
153.IP (a) 5
154the inode needs to be updated for some change unrelated to file timestamps;
155.IP (b)
156the application employs
157.BR fsync (2),
158.BR syncfs (2),
159or
160.BR sync (2);
161.IP (c)
162an undeleted inode is evicted from memory; or
163.IP (d)
164more than 24 hours have passed since the inode was written to disk.
165.RE
166.IP
5eab76af 167This mount option significantly reduces writes
9cdabfa6
MK
168needed to update the inode's timestamps, especially mtime and atime.
169However, in the event of a system crash, the atime and mtime fields
170on disk might be out of date by up to 24 hours.
054ea65e 171.IP
9cdabfa6
MK
172Examples of workloads where this option could be of significant benefit
173include frequent random writes to preallocated files,
174as well as cases where the
175.B MS_STRICTATIME
176mount option is also enabled.
cdd14e51
MK
177(The advantage of combining
178.BR MS_STRICTATIME
179and
180.BR MS_LAZYTIME
9cdabfa6
MK
181is that
182.BR stat (2)
183will return the correctly updated atime, but the atime updates
5eab76af 184will be flushed to disk only in the cases listed above.)
42a8e396 185.TP
fea681da 186.B MS_MANDLOCK
9ee4a2b6 187Permit mandatory locking on files in this filesystem.
fea681da
MK
188(Mandatory locking must still be enabled on a per-file basis,
189as described in
190.BR fcntl (2).)
afa0b44d
MK
191Since Linux 4.5,
192.\" commit 95ace75414f312f9a7b93d873f386987b92a5301
193this mount option requires the
194.B CAP_SYS_ADMIN
41976bc5
MK
195capability and a kernel configured with the
196.B CONFIG_MANDATORY_FILE_LOCKING
197option.
fea681da 198.TP
fea681da 199.B MS_NOATIME
9ee4a2b6 200Do not update access times for (all types of) files on this filesystem.
fea681da
MK
201.TP
202.B MS_NODEV
9ee4a2b6 203Do not allow access to devices (special files) on this filesystem.
fea681da
MK
204.TP
205.B MS_NODIRATIME
9ee4a2b6 206Do not update access times for directories on this filesystem.
882a9435
MK
207This flag provides a subset of the functionality provided by
208.BR MS_NOATIME ;
209that is,
210.BR MS_NOATIME
211implies
212.BR MS_NODIRATIME .
fea681da
MK
213.TP
214.B MS_NOEXEC
9ee4a2b6
MK
215Do 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
221Do not honor set-user-ID and set-group-ID bits or file capabilities
222when 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 227Mount filesystem read-only.
eac1e050
MK
228.TP
229.BR MS_REC " (since Linux 2.4.11)"
230Used in conjunction with
231.BR MS_BIND
232to create a recursive bind mount,
233and in conjunction with the propagation type flags to recursively change
234the propagation type of all of the mounts in a subtree.
235See below for further details.
c13182ef 236.TP
31c1f2b0 237.BR MS_RELATIME " (since Linux 2.6.20)"
9ee4a2b6 238When a file on this filesystem is accessed,
33a0ccb2 239update the file's last access time (atime) only if the current value
7c40de08 240of atime is less than or equal to the file's last modification time (mtime)
926b6e37
MK
241or last status change time (ctime).
242This option is useful for programs, such as
243.BR mutt (1),
244that need to know when a file has been read since it was last modified.
02a4e226
MK
245Since Linux 2.6.30, the kernel defaults to the behavior provided
246by this flag (unless
247.BR MS_NOATIME
248was specified), and the
249.B MS_STRICTATIME
250flag is required to obtain traditional semantics.
251In addition, since Linux 2.6.30,
252the file's last access time is always updated if it
253is 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)"
259Suppress the display of certain
260.RI ( printk ())
261warning messages in the kernel log.
262This flag supersedes the misnamed and obsolete
263.BR MS_VERBOSE
264flag (available since Linux 2.4.12), which has the same meaning.
265.TP
266.BR MS_STRICTATIME " (since Linux 2.6.30)"
267Always update the last access time (atime) when files on this
268filesystem are accessed.
269(This was the default behavior before Linux 2.6.30.)
270Specifying this flag overrides the effect of setting the
271.BR MS_NOATIME
272and
273.BR MS_RELATIME
274flags.
275.TP
276.B MS_SYNCHRONOUS
277Make writes on this filesystem synchronous (as though
278the
279.B O_SYNC
280flag to
281.BR open (2)
282was specified for all file opens to this filesystem).
283.PP
63b0b1a3
MK
284From Linux 2.4 onward, some of the above flags are
285settable on a per-mount basis,
286while others apply to the superblock of the mounted filesystem,
287meaning that all mounts of the same filesystem share those flags.
288(Previously, all of the flags were per-superblock.)
289.PP
290The per-mount-point flags are as follows:
291.IP * 3
292Since Linux 2.4:
f429fadc
MK
293.BR MS_NODEV ", " MS_NOEXEC ", and " MS_NOSUID
294flags are settable on a per-mount-point basis.
63b0b1a3
MK
295.IP *
296Since Linux 2.6.16:
f429fadc
MK
297.B MS_NOATIME
298and
63b0b1a3
MK
299.BR MS_NODIRATIME .
300.IP *
301Since Linux 2.6.20:
302.BR MS_RELATIME .
303.PP
304The following flags are per-superblock:
305.BR MS_DIRSYNC ,
306.BR MS_LAZYTIME ,
307.BR MS_MANDLOCK ,
308.BR MS_MS_SILENT ,
309and
310.BR MS_SYNCHRONOUS .
311.\" And MS_I_VERSION?
46183bb0 312The initial settings of these flags are determined on the first
63b0b1a3
MK
313mount of the filesystem, and will be shared by all subsequent mounts
314of the same filesystem.
315Subsequently, the settings of the flags can be changed
316via a remount operation (see below).
317Such changes will be visible via all mount points associated
318with the filesystem.
319.PP
c84a8779
N
320Since Linux 2.6.16,
321.B MS_RDONLY
322can be set or cleared on a per-mount-point basis as well as on
63b0b1a3 323the underlying filesystem superblock.
9edbd686
MK
324The mounted filesystem will be writable only if neither the filesystem
325nor the mountpoint are flagged as read-only.
f429fadc
MK
326.\"
327.SS Remounting an existing mount
328An existing mount may be remounted by specifying
fea681da 329.B MS_REMOUNT
f429fadc
MK
330in
331.IR mountflags .
599e5da7 332This allows you to change the
fea681da
MK
333.I mountflags
334and
335.I data
9ee4a2b6 336of an existing mount without having to unmount and remount the filesystem.
fea681da 337.I target
44535dd2 338should be the same value specified in the initial
fea681da 339.BR mount ()
74b46b5f 340call.
547ee319 341.PP
74b46b5f 342The
44535dd2
MK
343.I source
344and
fea681da 345.I filesystemtype
74b46b5f 346arguments are ignored.
547ee319 347.PP
69b6b231
EB
348The
349.I mountflags
350and
351.I data
352arguments should match the values used in the original
353.BR mount ()
354call, except for those parameters that are being deliberately changed.
a4222367 355.PP
178b977b 356The following
c13182ef 357.I mountflags
178b977b 358can 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
380and
381.BR MS_RELATIME
382flags),
16008a41 383and
014b17c6 384.BR MS_SYNCHRONOUS .
d8b67bc9 385Attempts 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
391and
392.BR MS_SILENT
393flags during a remount are silently ignored.
38ea2e76
MK
394Note that changes to per-superblock flags are visible via
395all mount points of the associated filesystem
396(because the per-superblock flags are shared by all mount points).
547ee319 397.PP
49f68546
MK
398Since Linux 3.17,
399.\" commit ffbc6f0ead47fa5a1dc9642b0331cb75c20a640e
400if none of
401.BR MS_NOATIME ,
402.BR MS_NODIRATIME ,
403.BR MS_RELATIME ,
404or
405.BR MS_STRICTATIME
406is specified in
407.IR mountflags ,
408then the remount operation preserves the existing values of these flags
409(rather than defaulting to
410.BR MS_RELATIME ).
a4222367 411.PP
5ea1abf8
MK
412Since Linux 2.6.26, the
413.B MS_RMOUNT
414flag can be used with
c84a8779 415.B MS_BIND
a4222367 416to modify only the per-mount-point flags.
f5da58a8 417.\" See https://lwn.net/Articles/281157/
c84a8779
N
418This is particularly useful for setting or clearing the "read-only"
419flag on a mount point without changing the underlying filesystem.
420Specifying
f5da58a8
MK
421.IR mountflags
422as:
a4222367 423.PP
e56ab30d
MK
424.in +4n
425.EX
426MS_REMOUNT | MS_BIND | MS_RDONLY
427.EE
428.in
a4222367 429.PP
c84a8779
N
430will make access through this mountpoint read-only, without affecting
431other mount points.
f429fadc
MK
432.\"
433.SS Creating a bind mount
434If
435.I mountflags
436includes
437.BR MS_BIND
438(available since Linux 2.4),
439.\" since 2.4.0-test9
440then perform a bind mount.
441A bind mount makes a file or a directory subtree visible at
442another point within the single directory hierarchy.
443Bind mounts may cross filesystem boundaries and span
444.BR chroot (2)
445jails.
547ee319 446.PP
f429fadc
MK
447The
448.IR filesystemtype
02a4e226 449and
f429fadc
MK
450.IR data
451arguments are ignored.
547ee319 452.PP
fca61050
MK
453The remaining bits (other than
454.BR MS_REC ,
455described below) in the
f429fadc 456.I mountflags
fca61050 457argument are also ignored.
f429fadc
MK
458(The bind mount has the same mount options as
459the underlying mount point.)
460However, see the discussion of remounting above,
461for a method of making an existing bind mount read-only.
547ee319 462.PP
eac1e050
MK
463By default, when a directory is bind mounted,
464only that directory is mounted;
465if there are any submounts under the directory tree,
466they are not bind mounted.
467If the
468.BR MS_REC
469flag is also specified, then a recursive bind mount operation is performed:
470all submounts under the
471.I source
472subtree (other than unbindable mounts)
473are also bind mounted at the corresponding location in the
474.I target
475subtree.
f429fadc
MK
476.\"
477.SS Changing the propagation type of an existing mount
c8e5f558
MK
478If
479.IR mountflags
480includes one of
481.BR MS_SHARED ,
482.BR MS_PRIVATE ,
483.BR MS_SLAVE ,
484or
485.BR MS_UNBINDABLE
486(all available since Linux 2.6.15),
487then the propagation type of an existing mount is changed.
488If more than one of these flags is specified, an error results.
547ee319 489.PP
158c5bc0
MK
490The only other flags that can be specified while changing
491the 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
497The
498.IR source ,
499.IR filesystemtype ,
500and
501.IR data
502arguments are ignored.
547ee319 503.PP
c8e5f558
MK
504The meanings of the propagation type flags are as follows:
505.TP
506.BR MS_SHARED
507Make this mount point shared.
508Mount and unmount events immediately under this mount point will propagate
509to the other mount points that are members of this mount's peer group.
510Propagation here means that the same mount or unmount will automatically
511occur under all of the other mount points in the peer group.
512Conversely, mount and unmount events that take place under
513peer mount points will propagate to this mount point.
514.TP
515.BR MS_PRIVATE
516Make this mount point private.
517Mount and unmount events do not propagate into or out of this mount point.
c8e5f558
MK
518.TP
519.BR MS_SLAVE
520If this is a shared mount point that is a member of a peer group
521that contains other members, convert it to a slave mount.
522If this is a shared mount point that is a member of a peer group
523that contains no other members, convert it to a private mount.
524Otherwise, the propagation type of the mount point is left unchanged.
054ea65e 525.IP
c8e5f558
MK
526When a mount point is a slave,
527mount and unmount events propagate into this mount point from
528the (master) shared peer group of which it was formerly a member.
529Mount and unmount events under this mount point do not propagate to any peer.
054ea65e 530.IP
c8e5f558
MK
531A mount point can be the slave of another peer group
532while at the same time sharing mount and unmount events
533with a peer group of which it is a member.
534.TP
535.BR MS_UNBINDABLE
536Make this mount unbindable.
537This is like a private mount,
538and in addition this mount can't be bind mounted.
539When a recursive bind mount
bf7bc8b8 540.RB ( mount ()
c8e5f558
MK
541with the
542.BR MS_BIND
543and
544.BR MS_REC
545flags) is performed on a directory subtree,
d70a2e57 546any unbindable mounts within the subtree are automatically pruned
c8e5f558
MK
547(i.e., not replicated)
548when replicating that subtree to produce the target subtree.
eac1e050
MK
549.PP
550By default, changing the propagation type affects only the
551.I target
552mount point.
553If the
554.B MS_REC
555flag is also specified in
556.IR mountflags ,
557then the propagation type of all mount points under
558.IR target
559is also changed.
547ee319 560.PP
472bbe3b
MK
561For 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
566If
567.I mountflags
568contains the flag
4a19136b
MK
569.BR MS_MOVE
570(available since Linux 2.4.18),
f429fadc
MK
571then move a subtree:
572.I source
573specifies an existing mount point and
574.I target
575specifies the new location to which that mount point is to be relocated.
576The move is atomic: at no point is the subtree unmounted.
547ee319 577.PP
f429fadc
MK
578The remaining bits in the
579.IR mountflags
580argument are ignored, as are the
581.IR filesystemtype
564d9941 582and
f429fadc
MK
583.IR data
584arguments.
585.\"
586.SS Creating a new mount point
587If 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 ,
594or
595.BR MS_UNBINDABLE
596is specified in
597.IR mountflags ,
598then
599.BR mount ()
600performs its default action: creating a new mount point.
601.IR source
602specifies the source for the new mount point, and
603.IR target
604specifies the directory at which to create the mount point.
547ee319 605.PP
c13182ef 606The
f429fadc
MK
607.I filesystemtype
608and
609.I data
610arguments are employed, and further bits may be specified in
611.IR mountflags
612to modify the behavior of the call.
613.\"
d282bb24 614.SH RETURN VALUE
c13182ef
MK
615On success, zero is returned.
616On error, \-1 is returned, and
fea681da
MK
617.I errno
618is set appropriately.
619.SH ERRORS
620The error values given below result from filesystem type independent
c13182ef 621errors.
9ee4a2b6 622Each filesystem type may have its own special errors and its
c13182ef 623own special behavior.
66a9882e 624See the Linux kernel source code for details.
fea681da
MK
625.TP
626.B EACCES
c13182ef
MK
627A component of a path was not searchable.
628(See also
ad7cc990 629.BR path_resolution (7).)
9e1ae4f8
MK
630.TP
631.B EACCES
632Mounting a read-only filesystem was attempted without giving the
c13182ef 633.B MS_RDONLY
8df37e4d 634flag.
ed6d1908
MK
635.IP
636The file system may be read-only for various reasons, including:
637it resides on a read-only optical disk;
638it is resides on a device with a physical switch that has been set to
639mark the device read-only;
640the filesystem implementation was compiled with read-only support;
641or errors were detected when initially mounting the filesystem,
642so that it was marked read-only
643and can't be remounted as read-write (until the errors are fixed).
1c1ccb2c
MK
644.IP
645Some filesystems instead return the error
646.BR EROFS
647on an attempt to mount a read-only filesystem.
9e1ae4f8
MK
648.TP
649.B EACCES
650The block device
fea681da 651.I source
9ee4a2b6 652is located on a filesystem mounted with the
8df37e4d
MK
653.B MS_NODEV
654option.
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
659An attempt was made to stack a new mount directly on
660top of an existing mount point that was created in this
661mount namespace with the same
662.I source
663and
664.IR target .
665.TP
666.B EBUSY
9e1ae4f8
MK
667.I source
668cannot be remounted read-only,
fea681da 669because it still holds files open for writing.
9e1ae4f8 670.TP
fea681da
MK
671.B EFAULT
672One of the pointer arguments points outside the user address space.
673.TP
674.B EINVAL
675.I source
676had an invalid superblock.
9e1ae4f8
MK
677.TP
678.B EINVAL
679A remount operation
8df37e4d
MK
680.RB ( MS_REMOUNT )
681was attempted, but
fea681da
MK
682.I source
683was not already mounted on
684.IR target .
9e1ae4f8
MK
685.TP
686.B EINVAL
687A move operation
8df37e4d
MK
688.RB ( MS_MOVE )
689was attempted, but
fea681da 690.I source
f81fb444 691was not a mount point, or was \(aq/\(aq.
fea681da 692.TP
c8e5f558
MK
693.B EINVAL
694.I mountflags
695includes more than one of
696.BR MS_SHARED ,
697.BR MS_PRIVATE ,
698.BR MS_SLAVE ,
699or
700.BR MS_UNBINDABLE .
701.TP
702.B EINVAL
703.I mountflags
704includes
705.BR MS_SHARED ,
706.BR MS_PRIVATE ,
707.BR MS_SLAVE ,
708or
709.BR MS_UNBINDABLE
710and also includes a flag other than
711.BR MS_REC
712or
713.BR MS_SILENT .
714.TP
715.BR EINVAL
716An attempt was made to bind mount an unbindable mount.
717.TP
360d7455 718.BR EINVAL
f54c67bf
MK
719In an unprivileged mount namespace
720(i.e., a mount namespace owned by a user namespace
721that was created by an unprivileged user),
722a bind mount operation
360d7455
KF
723.RB ( MS_BIND )
724was attempted without specifying
725.RB ( MS_REC ),
3484e69f 726which would have revealed the filesystem tree underneath one of
360d7455
KF
727the submounts of the directory being bound.
728.TP
fea681da 729.B ELOOP
9b9b4a81 730Too many links encountered during pathname resolution.
9e1ae4f8
MK
731.TP
732.B ELOOP
733A move operation was attempted, and
fea681da
MK
734.I target
735is a descendant of
736.IR source .
737.TP
738.B EMFILE
739(In case no block device is required:)
740Table of dummy devices is full.
741.TP
742.B ENAMETOOLONG
682edefb
MK
743A pathname was longer than
744.BR MAXPATHLEN .
fea681da
MK
745.TP
746.B ENODEV
a90440ba 747.I filesystemtype
fea681da
MK
748not configured in the kernel.
749.TP
750.B ENOENT
751A pathname was empty or had a nonexistent component.
752.TP
753.B ENOMEM
754The kernel could not allocate a free page to copy filenames or data into.
755.TP
756.B ENOTBLK
757.I source
758is not a block device (and a device was required).
759.TP
760.B ENOTDIR
5614f733
MK
761.IR target ,
762or a prefix of
763.IR source ,
764is not a directory.
fea681da
MK
765.TP
766.B ENXIO
767The major number of the block device
768.I source
769is out of range.
770.TP
771.B EPERM
772The caller does not have the required privileges.
1c1ccb2c
MK
773.TP
774.B EROFS
775Mounting a read-only filesystem was attempted without giving the
776.B MS_RDONLY
777flag.
778See
779.BR EACCES ,
780above.
9326e678
MK
781.SH VERSIONS
782The 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
791and
792.BR MS_UNBINDABLE
33a0ccb2 793were added to glibc headers in version 2.12.
f429fadc 794.\"
d282bb24 795.SH CONFORMING TO
5614f733 796This function is Linux-specific and should not be used in
fea681da 797programs intended to be portable.
889829be 798.SH NOTES
f54e02b4
MK
799Since Linux 2.4 a single filesystem can be mounted at
800multiple mount points, and multiple mounts can be stacked
801on the same mount point.
802.\" Multiple mounts on same mount point: since 2.3.99pre7.
547ee319 803.PP
52f00c05
MK
804The
805.I mountflags
806argument may have the magic number 0xC0ED (\fBMS_MGC_VAL\fP)
807in the top 16 bits.
808(All of the other flags discussed in DESCRIPTION
809occupy the low order 16 bits of
810.IR mountflags .)
811Specifying
812.BR MS_MGC_VAL
813was required in kernel versions prior to 2.4,
814but since Linux 2.4 is no longer required and is ignored if specified.
547ee319 815.PP
fea681da 816The original
0daa9e92 817.B MS_SYNC
682edefb 818flag was renamed
0daa9e92 819.B MS_SYNCHRONOUS
682edefb
MK
820in 1.1.69
821when a different
0daa9e92 822.B MS_SYNC
682edefb 823was added to \fI<mman.h>\fP.
dd3568a1 824.PP
880f5b4b 825Before Linux 2.4 an attempt to execute a set-user-ID or set-group-ID program
9ee4a2b6 826on a filesystem mounted with
fea681da
MK
827.B MS_NOSUID
828would fail with
829.BR EPERM .
c13182ef 830Since Linux 2.4 the set-user-ID and set-group-ID bits are
880f5b4b 831just 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 835Starting with kernel 2.4.19, Linux provides
732e54dd 836per-process mount namespaces.
9ee4a2b6 837A mount namespace is the set of filesystem mounts that
4df2eb09
MK
838are visible to a process.
839Mount-point namespaces can be (and usually are)
840shared between multiple processes,
0a4d78bb
MK
841and changes to the namespace (i.e., mounts and unmounts) by one process
842are visible to all other processes sharing the same namespace.