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 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .\" 2008-10-06, mtk: Created this as a new page by splitting
8 .\" umount/umount2 material out of mount.2
10 .TH UMOUNT 2 2022-09-09 "Linux man-pages (unreleased)"
12 umount, umount2 \- unmount filesystem
15 .RI ( libc ", " \-lc )
18 .B "#include <sys/mount.h>"
20 .BI "int umount(const char *" target );
21 .BI "int umount2(const char *" target ", int " flags );
27 remove the attachment of the (topmost) filesystem mounted on
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
33 Appropriate privilege (Linux: the
35 capability) is required to unmount filesystems.
37 Linux 2.1.116 added the
39 system call, which, like
41 unmounts a target, but allows additional
43 controlling the behavior of the operation:
45 .BR MNT_FORCE " (since Linux 2.1.116)"
46 Ask the filesystem to abort pending requests before attempting the
48 This may allow the unmount to complete without waiting
49 for an inaccessible server, but could cause data loss.
50 If, after aborting requests,
51 some processes still have active references to the filesystem,
52 the unmount will still fail.
55 is supported only on the following filesystems:
56 9p (since Linux 2.6.16),
57 ceph (since Linux 2.6.34),
58 cifs (since Linux 2.6.12),
59 fuse (since Linux 2.6.16),
60 lustre (since Linux 3.11),
61 and NFS (since Linux 2.1.116).
63 .BR MNT_DETACH " (since Linux 2.4.11)"
64 Perform a lazy unmount: make the mount unavailable for new
65 accesses, immediately disconnect the filesystem and all filesystems
66 mounted below it from each other and from the mount table, and
67 actually perform the unmount when the mount ceases to be busy.
69 .BR MNT_EXPIRE " (since Linux 2.6.8)"
70 Mark the mount as expired.
71 If a mount is not currently in use, then an initial call to
73 with this flag fails with the error
75 but marks the mount as expired.
76 The mount remains expired as long as it isn't accessed
82 unmounts an expired mount.
83 This flag cannot be specified with either
88 .BR UMOUNT_NOFOLLOW " (since Linux 2.6.34)"
89 .\" Later added to 2.6.33-stable
92 if it is a symbolic link.
93 This flag allows security problems to be avoided in set-user-ID-\fIroot\fP
94 programs that allow unprivileged users to unmount filesystems.
96 On success, zero is returned.
97 On error, \-1 is returned, and
99 is set to indicate the error.
101 The error values given below result from filesystem type independent
103 Each filesystem type may have its own special errors and its
104 own special behavior.
105 See the Linux kernel source code for details.
112 successfully marked an unbusy filesystem as expired.
116 could not be unmounted because it is busy.
120 points outside the user address space.
124 is not a mount point.
129 .BR mount_namespaces (7).
140 .BR EINVAL " (since Linux 2.6.34)"
142 was called with an invalid flag value in
146 A pathname was longer than
150 A pathname was empty or had a nonexistent component.
153 The kernel could not allocate a free page to copy filenames or data into.
156 The caller does not have the required privileges.
161 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=10092
162 are available in glibc since version 2.11.
164 These functions are Linux-specific and should not be used in
165 programs intended to be portable.
167 .SS umount() and shared mounts
168 Shared mounts cause any mount activity on a mount, including
170 operations, to be forwarded to every shared mount in the
171 peer group and every slave mount of that peer group.
174 of any peer in a set of shared mounts will cause all of its
175 peers to be unmounted and all of their slaves to be unmounted as well.
177 This propagation of unmount activity can be particularly surprising
178 on systems where every mount is shared by default.
180 recursively bind mounting the root directory of the filesystem
181 onto a subdirectory and then later unmounting that subdirectory with
183 will cause every mount in the mount namespace to be lazily unmounted.
187 does not propagate in this fashion,
188 the mount may be remounted using a
192 argument that includes both
199 .SS Historical details
202 function was called as \fIumount(device)\fP and would return
204 when called with something other than a block device.
205 In Linux 0.98p4, a call \fIumount(dir)\fP was added, in order to
206 support anonymous devices.
207 In Linux 2.3.99-pre7, the call \fIumount(device)\fP was removed,
208 leaving only \fIumount(dir)\fP (since now devices can be mounted
209 in more than one place, so specifying the device does not suffice).
212 .BR mount_namespaces (7),
213 .BR path_resolution (7),