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>
5 .\" %%%LICENSE_START(VERBATIM)
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.
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.
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
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
27 .\" 2008-10-06, mtk: Created this as a new page by splitting
28 .\" umount/umount2 material out of mount.2
30 .TH UMOUNT 2 2021-03-22 "Linux" "Linux Programmer's Manual"
32 umount, umount2 \- unmount filesystem
35 .B "#include <sys/mount.h>"
37 .BI "int umount(const char *" target );
38 .BI "int umount2(const char *" target ", int " flags );
44 remove the attachment of the (topmost) filesystem mounted on
46 .\" Note: the kernel naming differs from the glibc naming
47 .\" umount2 is the glibc name for what the kernel now calls umount
48 .\" and umount is the glibc name for oldumount
50 Appropriate privilege (Linux: the
52 capability) is required to unmount filesystems.
54 Linux 2.1.116 added the
56 system call, which, like
58 unmounts a target, but allows additional
60 controlling the behavior of the operation:
62 .BR MNT_FORCE " (since Linux 2.1.116)"
63 Ask the filesystem to abort pending requests before attempting the
65 This may allow the unmount to complete without waiting
66 for an inaccessible server, but could cause data loss.
67 If, after aborting requests,
68 some processes still have active references to the filesystem,
69 the unmount will still fail.
72 is supported only on the following filesystems:
73 9p (since Linux 2.6.16),
74 ceph (since Linux 2.6.34),
75 cifs (since Linux 2.6.12),
76 fuse (since Linux 2.6.16),
77 lustre (since Linux 3.11),
78 and NFS (since Linux 2.1.116).
80 .BR MNT_DETACH " (since Linux 2.4.11)"
81 Perform a lazy unmount: make the mount point unavailable for new
82 accesses, immediately disconnect the filesystem and all filesystems
83 mounted below it from each other and from the mount table, and
84 actually perform the unmount when the mount point ceases to be busy.
86 .BR MNT_EXPIRE " (since Linux 2.6.8)"
87 Mark the mount point as expired.
88 If a mount point is not currently in use, then an initial call to
90 with this flag fails with the error
92 but marks the mount point as expired.
93 The mount point remains expired as long as it isn't accessed
99 unmounts an expired mount point.
100 This flag cannot be specified with either
105 .BR UMOUNT_NOFOLLOW " (since Linux 2.6.34)"
106 .\" Later added to 2.6.33-stable
109 if it is a symbolic link.
110 This flag allows security problems to be avoided in set-user-ID-\fIroot\fP
111 programs that allow unprivileged users to unmount filesystems.
113 On success, zero is returned.
114 On error, \-1 is returned, and
116 is set to indicate the error.
118 The error values given below result from filesystem type independent
120 Each filesystem type may have its own special errors and its
121 own special behavior.
122 See the Linux kernel source code for details.
129 successfully marked an unbusy filesystem as expired.
133 could not be unmounted because it is busy.
137 points outside the user address space.
141 is not a mount point.
152 .BR EINVAL " (since Linux 2.6.34)"
154 was called with an invalid flag value in
158 A pathname was longer than
162 A pathname was empty or had a nonexistent component.
165 The kernel could not allocate a free page to copy filenames or data into.
168 The caller does not have the required privileges.
173 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=10092
174 are available in glibc since version 2.11.
176 These functions are Linux-specific and should not be used in
177 programs intended to be portable.
179 .SS umount() and shared mount points
180 Shared mount points cause any mount activity on a mount point, including
182 operations, to be forwarded to every shared mount point in the
183 peer group and every slave mount of that peer group.
186 of any peer in a set of shared mounts will cause all of its
187 peers to be unmounted and all of their slaves to be unmounted as well.
189 This propagation of unmount activity can be particularly surprising
190 on systems where every mount point is shared by default.
192 recursively bind mounting the root directory of the filesystem
193 onto a subdirectory and then later unmounting that subdirectory with
195 will cause every mount in the mount namespace to be lazily unmounted.
199 does not propagate in this fashion,
200 the mount point may be remounted using a
204 argument that includes both
211 .SS Historical details
214 function was called as \fIumount(device)\fP and would return
216 when called with something other than a block device.
217 In Linux 0.98p4, a call \fIumount(dir)\fP was added, in order to
218 support anonymous devices.
219 In Linux 2.3.99-pre7, the call \fIumount(device)\fP was removed,
220 leaving only \fIumount(dir)\fP (since now devices can be mounted
221 in more than one place, so specifying the device does not suffice).
224 .BR mount_namespaces (7),
225 .BR path_resolution (7),