1MOUNT(2) Linux Programmer's Manual MOUNT(2)
2
3
4
6 mount - mount filesystem
7
9 #include <sys/mount.h>
10
11 int mount(const char *source, const char *target,
12 const char *filesystemtype, unsigned long mountflags,
13 const void *data);
14
16 mount() attaches the filesystem specified by source (which is often a
17 pathname referring to a device, but can also be the pathname of a di‐
18 rectory or file, or a dummy string) to the location (a directory or
19 file) specified by the pathname in target.
20
21 Appropriate privilege (Linux: the CAP_SYS_ADMIN capability) is required
22 to mount filesystems.
23
24 Values for the filesystemtype argument supported by the kernel are
25 listed in /proc/filesystems (e.g., "btrfs", "ext4", "jfs", "xfs",
26 "vfat", "fuse", "tmpfs", "cgroup", "proc", "mqueue", "nfs", "cifs",
27 "iso9660"). Further types may become available when the appropriate
28 modules are loaded.
29
30 The data argument is interpreted by the different filesystems. Typi‐
31 cally it is a string of comma-separated options understood by this
32 filesystem. See mount(8) for details of the options available for each
33 filesystem type. This argument may be specified as NULL, if there are
34 no options.
35
36 A call to mount() performs one of a number of general types of opera‐
37 tion, depending on the bits specified in mountflags. The choice of
38 which operation to perform is determined by testing the bits set in
39 mountflags, with the tests being conducted in the order listed here:
40
41 * Remount an existing mount: mountflags includes MS_REMOUNT.
42
43 * Create a bind mount: mountflags includes MS_BIND.
44
45 * Change the propagation type of an existing mount: mountflags in‐
46 cludes one of MS_SHARED, MS_PRIVATE, MS_SLAVE, or MS_UNBINDABLE.
47
48 * Move an existing mount to a new location: mountflags includes
49 MS_MOVE.
50
51 * Create a new mount: mountflags includes none of the above flags.
52
53 Each of these operations is detailed later in this page. Further flags
54 may be specified in mountflags to modify the behavior of mount(), as
55 described below.
56
57 Additional mount flags
58 The list below describes the additional flags that can be specified in
59 mountflags. Note that some operation types ignore some or all of these
60 flags, as described later in this page.
61
62 MS_DIRSYNC (since Linux 2.5.19)
63 Make directory changes on this filesystem synchronous. (This
64 property can be obtained for individual directories or subtrees
65 using chattr(1).)
66
67 MS_LAZYTIME (since Linux 4.0