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