1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (C) 1993 Rickard E. Faith <faith@cs.unc.edu>
4 .\" and Copyright (C) 1994 Andries E. Brouwer <aeb@cwi.nl>
5 .\" and Copyright (C) 2002, 2005 Michael Kerrisk <mtk-manpages@gmx.net>
7 .\" Permission is granted to make and distribute verbatim copies of this
8 .\" manual provided the copyright notice and this permission notice are
9 .\" preserved on all copies.
11 .\" Permission is granted to copy and distribute modified versions of this
12 .\" manual under the conditions for verbatim copying, provided that the
13 .\" entire resulting derived work is distributed under the terms of a
14 .\" permission notice identical to this one.
16 .\" Since the Linux kernel and libraries are constantly changing, this
17 .\" manual page may be incorrect or out-of-date. The author(s) assume no
18 .\" responsibility for errors or omissions, or for damages resulting from
19 .\" the use of the information contained herein. The author(s) may not
20 .\" have taken the same level of care in the production of this manual,
21 .\" which is licensed free of charge, as they might when working
24 .\" Formatted or processed versions of this manual, if unaccompanied by
25 .\" the source, must acknowledge the copyright and authors of this work.
27 .\" Modified 1996-11-04 by Eric S. Raymond <esr@thyrsus.com>
28 .\" Modified 2001-10-13 by Michael Kerrisk <mtk-manpages@gmx.net>
29 .\" Added note on historical behaviour of MS_NOSUID
30 .\" Modified 2002-05-16 by Michael Kerrisk <mtk-manpages@gmx.net>
31 .\" Extensive changes and additions
32 .\" Modified 2002-05-27 by aeb
33 .\" Modified 2002-06-11 by Michael Kerrisk <mtk-manpages@gmx.net>
34 .\" Enhanced descriptions of MS_MOVE, MS_BIND, and MS_REMOUNT
35 .\" Modified 2004-06-17 by Michael Kerrisk <mtk-manpages@gmx.net>
36 .\" 2005-05-18, mtk, Added MNT_EXPIRE, plus a few other tidy-ups.
38 .TH MOUNT 2 2004-05-18 "Linux 2.6.12" "Linux Programmer's Manual"
40 mount, umount \- mount and unmount filesystems
43 .B "#include <sys/mount.h>"
45 .BI "int mount(const char *" source ", const char *" target ,
46 .BI " const char *" filesystemtype ", unsigned long " mountflags ,
47 .BI " const void *" data );
49 .BI "int umount(const char *" target );
51 .BI "int umount2(const char *" target ", int " flags );
55 attaches the filesystem specified by
57 (which is often a device name, but can also be a directory name
58 or a dummy) to the directory specified by
64 remove the attachment of the (topmost) filesystem mounted on
67 Appropriate privilege (Linux: the
69 capability) is required to mount and unmount filesystems.
71 Since Linux 2.4 a single filesystem can be visible at
72 multiple mount points, and multiple mounts can be stacked
73 on the same mount point.
74 .\" Multiple mounts on same mount point: since 2.3.99pre7.
78 argument supported by the kernel are listed in
80 (like "minix", "ext2", "msdos", "proc", "nfs", "iso9660" etc.).
81 Further types may become available when the appropriate modules
86 argument may have the magic number 0xC0ED (\fBMS_MGC_VAL\fP)
87 in the top 16 bits (this was required in kernel versions prior to 2.4, but
88 is no longer required and ignored if specified),
89 and various mount flags (as defined in <linux/fs.h> for libc4 and libc5
90 and in <sys/mount.h> for glibc2) in the low order 16 bits:
91 .\" FIXME 2.6.15 added flags for "shared sub-tree" functionality:
92 .\" MS_UNBINDABLE, MS_PRIVATE, MS_SHARED, MS_SLAVE
93 .\" These need to be documented on this page.
94 .\" See Documentation/sharedsubtree.txt
99 Perform a bind mount, making a file or a directory subtree visible at
100 another point within a file system.
101 Bind mounts may cross file system boundaries and span
105 .IR filesystemtype ", " mountflags ", and " data
106 arguments are ignored.
107 .\" with the exception of the "hidden" MS_REC mountflags bit
109 .BR MS_DIRSYNC " (since Linux 2.5.19)"
110 Make directory changes on this file system synchronous.
111 (This property can be obtained for individual directories
116 Permit mandatory locking on files in this file system.
117 (Mandatory locking must still be enabled on a per-file basis,
120 .\" FIXME Say more about MS_MOVE
125 specifies an existing mount point and
127 specifies the new location.
128 The move is atomic: at no point is the subtree unmounted.
130 .IR filesystemtype ", " mountflags ", and " data
131 arguments are ignored.
134 Do not update access times for (all types of) files on this file system.
137 Do not allow access to devices (special files) on this file system.
140 Do not update access times for directories on this file system.
143 Do not allow programs to be executed from this file system.
144 .\" (Possibly useful for a file system that contains non-Linux executables.
145 .\" Often used as a security feature, e.g. to make sure that restricted
146 .\" users cannot execute files uploaded using ftp or so.)
149 Do not honour set-user-ID and set-group-ID bits when executing
150 programs from this file system.
151 .\" (This is a security feature to prevent users executing set-user-ID and
152 .\" set-group-ID programs from removable disk devices.)
155 Mount file system read-only.
157 .\" FIXME Document MS_REC, available since 2.4.11.
158 .\" This flag has meaning in conjunction with MS_BIND and
159 .\" also with the shared sub-tree flags.
161 .BR MS_RELATIME "(Since Linux 2.6.20)"
162 When a file on this file system is accessed,
163 only update the file's last accessed time (atime) if the current value
164 of atime is less than or equal to the file's last modified (mtime)
165 or last status change time (ctime).
166 This option is useful for programs, such as
168 that need to know when a file has been read since it was last modified.
171 Remount an existing mount. This is allows you to change the
175 of an existing mount without having to unmount and remount the file system.
179 should be the same values specified in the initial
191 before kernel 2.6.16, the following could also be changed:
195 and, additionally, before kernel 2.4, the following could also be changed:
201 Make writes on this file system synchronous (as though
206 was specified for all file opens to this file system).
208 From Linux 2.4 onwards, the
209 .BR MS_NODEV ", " MS_NOEXEC ", and " MS_NOSUID
210 flags are settable on a per-mount-point basis.
211 From kernel 2.6.16 onwards,
215 are also settable on a per-mount-point basis.
218 flag is also settable on a per-mount-point basis.
222 argument is interpreted by the different file systems.
223 Typically it is a string of comma-separated options
224 understood by this file system.
227 for details of the options available for each filesystem type.
229 .\" Note: the kernel naming differs from the glibc naming
230 .\" umount2 is the glibc name for what the kernel now calls umount
231 .\" and umount is the glibc name for oldumount
232 Linux 2.1.116 added the
234 system call, which, like
236 unmounts a target, but allows additional
238 controlling the behaviour of the operation:
240 .BR MNT_FORCE " (since Linux 2.1.116)"
241 Force unmount even if busy. This can cause data loss.
242 (Only for NFS mounts.)
243 .\" FIXME Can MNT_FORCE result in data loss? According to
244 .\" the Solaris manual page it can cause data loss on Solaris.
245 .\" If the same holds on Linux, then this should be documented.
247 .BR MNT_DETACH " (since Linux 2.4.11)"
248 Perform a lazy unmount: make the mount point unavailable for
249 new accesses, and actually perform the unmount when the mount point
252 .BR MNT_EXPIRE " (since Linux 2.6.8)"
253 Mark the mount point as expired.
254 If a mount point is not currently in use, then an initial call to
256 with this flag fails with the error
258 but marks the mount point as expired.
259 The mount point remains expired as long as it isn't accessed
265 unmounts an expired mount point.
266 This flag cannot be specified with either
271 On success, zero is returned. On error, \-1 is returned, and
273 is set appropriately.
275 The error values given below result from filesystem type independent
276 errors. Each filesystem type may have its own special errors and its
277 own special behavior. See the kernel source code for details.
281 A component of a path was not searchable. (See also
282 .BR path_resolution (2).)
283 Or, mounting a read-only filesystem was attempted without giving the
288 is located on a filesystem mounted with the
291 .\" mtk: Probably: write permission is required for MS_BIND, with
292 .\" the error EPERM if not present; CAP_DAC_OVERRIDE is required.
299 successfully marked an unbusy file system as expired.
303 is already mounted. Or, it cannot be remounted read-only,
304 because it still holds files open for writing.
305 Or, it cannot be mounted on
309 is still busy (it is the working directory of some task,
310 the mount point of another device, has open files, etc.).
311 Or, it could not be unmounted because it is busy.
314 One of the pointer arguments points outside the user address space.
318 had an invalid superblock.
323 was not already mounted on
329 was not a mount point, or was '/'.
330 Or, an unmount was attempted, but
332 was not a mount point.
343 Too many link encountered during pathname resolution.
344 Or, a move was attempted, while
350 (In case no block device is required:)
351 Table of dummy devices is full.
354 A pathname was longer than MAXPATHLEN.
358 not configured in the kernel.
361 A pathname was empty or had a nonexistent component.
364 The kernel could not allocate a free page to copy filenames or data into.
368 is not a block device (and a device was required).
371 The second argument, or a prefix of the first argument, is not
375 The major number of the block device
380 The caller does not have the required privileges.
382 These functions are Linux specific and should not be used in
383 programs intended to be portable.
387 function was called as \fIumount(device)\fP and would return ENOTBLK
388 when called with something other than a block device.
389 In Linux 0.98p4 a call \fIumount(dir)\fP was added, in order to
390 support anonymous devices.
391 In Linux 2.3.99-pre7 the call \fIumount(device)\fP was removed,
392 leaving only \fIumount(dir)\fP (since now devices can be mounted
393 in more than one place, so specifying the device does not suffice).
395 The original MS_SYNC flag was renamed MS_SYNCHRONOUS in 1.1.69
396 when a different MS_SYNC was added to <mman.h>.
398 Before Linux 2.4 an attempt to execute a set-user-ID or set-group-ID program
399 on a filesystem mounted with
403 Since Linux 2.4 the set-user-ID and set-group-ID bits are
404 just silently ignored in this case.
405 .\" The change is in patch-2.4.0-prerelease.
407 .BR path_resolution (2),