]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/umount.2
man*/: srcfix (Use .P instead of .PP or .LP)
[thirdparty/man-pages.git] / man2 / umount.2
CommitLineData
5614f733
MK
1.\" Copyright (C) 1993 Rickard E. Faith <faith@cs.unc.edu>
2.\" and Copyright (C) 1994 Andries E. Brouwer <aeb@cwi.nl>
3.\" and Copyright (C) 2002, 2005 Michael Kerrisk <mtk.manpages@gmail.com>
4.\"
5fbde956 5.\" SPDX-License-Identifier: Linux-man-pages-copyleft
5614f733
MK
6.\"
7.\" 2008-10-06, mtk: Created this as a new page by splitting
8.\" umount/umount2 material out of mount.2
9.\"
4c1c5274 10.TH umount 2 (date) "Linux man-pages (unreleased)"
5614f733 11.SH NAME
9ee4a2b6 12umount, umount2 \- unmount filesystem
1d60a859
AC
13.SH LIBRARY
14Standard C library
8fc3b2cf 15.RI ( libc ", " \-lc )
5614f733
MK
16.SH SYNOPSIS
17.nf
18.B "#include <sys/mount.h>"
c6d039a3 19.P
5614f733 20.BI "int umount(const char *" target );
5614f733
MK
21.BI "int umount2(const char *" target ", int " flags );
22.fi
23.SH DESCRIPTION
24.BR umount ()
25and
26.BR umount2 ()
9ee4a2b6 27remove the attachment of the (topmost) filesystem mounted on
5614f733
MK
28.IR target .
29.\" Note: the kernel naming differs from the glibc naming
30.\" umount2 is the glibc name for what the kernel now calls umount
31.\" and umount is the glibc name for oldumount
c6d039a3 32.P
5614f733
MK
33Appropriate privilege (Linux: the
34.B CAP_SYS_ADMIN
9ee4a2b6 35capability) is required to unmount filesystems.
c6d039a3 36.P
5614f733
MK
37Linux 2.1.116 added the
38.BR umount2 ()
39system call, which, like
40.BR umount (),
41unmounts a target, but allows additional
42.I flags
43controlling the behavior of the operation:
44.TP
45.BR MNT_FORCE " (since Linux 2.1.116)"
7045e438 46Ask the filesystem to abort pending requests before attempting the
76218efa
MK
47unmount.
48This may allow the unmount to complete without waiting
49for an inaccessible server, but could cause data loss.
50If, after aborting requests,
51some processes still have active references to the filesystem,
52the unmount will still fail.
2f2ab744 53As at Linux 4.12,
1ae6b2c7 54.B MNT_FORCE
2f2ab744
MK
55is supported only on the following filesystems:
569p (since Linux 2.6.16),
57ceph (since Linux 2.6.34),
58cifs (since Linux 2.6.12),
59fuse (since Linux 2.6.16),
60lustre (since Linux 3.11),
61and NFS (since Linux 2.1.116).
5614f733
MK
62.TP
63.BR MNT_DETACH " (since Linux 2.4.11)"
525a8b54 64Perform a lazy unmount: make the mount unavailable for new
f1311221
EB
65accesses, immediately disconnect the filesystem and all filesystems
66mounted below it from each other and from the mount table, and
525a8b54 67actually perform the unmount when the mount ceases to be busy.
5614f733
MK
68.TP
69.BR MNT_EXPIRE " (since Linux 2.6.8)"
525a8b54
MK
70Mark the mount as expired.
71If a mount is not currently in use, then an initial call to
5614f733
MK
72.BR umount2 ()
73with this flag fails with the error
74.BR EAGAIN ,
525a8b54
MK
75but marks the mount as expired.
76The mount remains expired as long as it isn't accessed
5614f733
MK
77by any process.
78A second
79.BR umount2 ()
80call specifying
81.B MNT_EXPIRE
525a8b54 82unmounts an expired mount.
5614f733
MK
83This flag cannot be specified with either
84.B MNT_FORCE
85or
86.BR MNT_DETACH .
c3b9aac8
MK
87.TP
88.BR UMOUNT_NOFOLLOW " (since Linux 2.6.34)"
b324e17d 89.\" Later added to Linux 2.6.33-stable
c3b9aac8
MK
90Don't dereference
91.I target
92if it is a symbolic link.
60fe1ea1 93This flag allows security problems to be avoided in set-user-ID-\fIroot\fP
9ee4a2b6 94programs that allow unprivileged users to unmount filesystems.
47297adb 95.SH RETURN VALUE
5614f733
MK
96On success, zero is returned.
97On error, \-1 is returned, and
98.I errno
f6a4078b 99is set to indicate the error.
5614f733 100.SH ERRORS
9ee4a2b6 101The error values given below result from filesystem type independent
5614f733 102errors.
9ee4a2b6 103Each filesystem type may have its own special errors and its
5614f733 104own special behavior.
66a9882e 105See the Linux kernel source code for details.
5614f733
MK
106.TP
107.B EAGAIN
108A call to
109.BR umount2 ()
110specifying
111.B MNT_EXPIRE
9ee4a2b6 112successfully marked an unbusy filesystem as expired.
5614f733
MK
113.TP
114.B EBUSY
115.I target
116could not be unmounted because it is busy.
117.TP
118.B EFAULT
119.I target
120points outside the user address space.
121.TP
122.B EINVAL
123.I target
124is not a mount point.
ec4a728e
MK
125.TP
126.B EINVAL
b3987057
MK
127.I target
128is locked; see
129.BR mount_namespaces (7).
130.TP
131.B EINVAL
5614f733
MK
132.BR umount2 ()
133was called with
134.B MNT_EXPIRE
135and either
136.B MNT_DETACH
137or
138.BR MNT_FORCE .
139.TP
a7566673
MK
140.BR EINVAL " (since Linux 2.6.34)"
141.BR umount2 ()
142was called with an invalid flag value in
143.IR flags .
144.TP
5614f733
MK
145.B ENAMETOOLONG
146A pathname was longer than
147.BR MAXPATHLEN .
148.TP
149.B ENOENT
150A pathname was empty or had a nonexistent component.
151.TP
152.B ENOMEM
153The kernel could not allocate a free page to copy filenames or data into.
154.TP
155.B EPERM
156The caller does not have the required privileges.
4131356c
AC
157.SH STANDARDS
158Linux.
159.SH HISTORY
1ae6b2c7 160.B MNT_DETACH
835c57e9 161and
1ae6b2c7 162.B MNT_EXPIRE
8749bd1a 163.\" http://sourceware.org/bugzilla/show_bug.cgi?id=10092
b324e17d 164are available since glibc 2.11.
c6d039a3 165.P
4131356c
AC
166The original
167.BR umount ()
168function was called as \fIumount(device)\fP and would return
169.B ENOTBLK
170when called with something other than a block device.
171In Linux 0.98p4, a call \fIumount(dir)\fP was added, in order to
172support anonymous devices.
173In Linux 2.3.99-pre7, the call \fIumount(device)\fP was removed,
174leaving only \fIumount(dir)\fP (since now devices can be mounted
175in more than one place, so specifying the device does not suffice).
5614f733 176.SH NOTES
525a8b54
MK
177.SS umount() and shared mounts
178Shared mounts cause any mount activity on a mount, including
bf7bc8b8 179.BR umount ()
525a8b54 180operations, to be forwarded to every shared mount in the
430a1677
MK
181peer group and every slave mount of that peer group.
182This means that
bf7bc8b8 183.BR umount ()
430a1677
MK
184of any peer in a set of shared mounts will cause all of its
185peers to be unmounted and all of their slaves to be unmounted as well.
c6d039a3 186.P
430a1677 187This propagation of unmount activity can be particularly surprising
525a8b54 188on systems where every mount is shared by default.
430a1677
MK
189On such systems,
190recursively bind mounting the root directory of the filesystem
191onto a subdirectory and then later unmounting that subdirectory with
1ae6b2c7 192.B MNT_DETACH
430a1677 193will cause every mount in the mount namespace to be lazily unmounted.
c6d039a3 194.P
430a1677 195To ensure
bf7bc8b8 196.BR umount ()
430a1677 197does not propagate in this fashion,
525a8b54 198the mount may be remounted using a
e3a78ee9 199.BR mount (2)
430a1677
MK
200call with a
201.I mount_flags
202argument that includes both
1ae6b2c7 203.B MS_REC
430a1677 204and
1ae6b2c7 205.B MS_PRIVATE
430a1677 206prior to
bf7bc8b8 207.BR umount ()
430a1677 208being called.
47297adb 209.SH SEE ALSO
5614f733 210.BR mount (2),
a67271b0 211.BR mount_namespaces (7),
5614f733
MK
212.BR path_resolution (7),
213.BR mount (8),
214.BR umount (8)