]>
Commit | Line | Data |
---|---|---|
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 | 12 | umount, umount2 \- unmount filesystem |
1d60a859 AC |
13 | .SH LIBRARY |
14 | Standard 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 () | |
25 | and | |
26 | .BR umount2 () | |
9ee4a2b6 | 27 | remove 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 |
33 | Appropriate privilege (Linux: the |
34 | .B CAP_SYS_ADMIN | |
9ee4a2b6 | 35 | capability) is required to unmount filesystems. |
c6d039a3 | 36 | .P |
5614f733 MK |
37 | Linux 2.1.116 added the |
38 | .BR umount2 () | |
39 | system call, which, like | |
40 | .BR umount (), | |
41 | unmounts a target, but allows additional | |
42 | .I flags | |
43 | controlling the behavior of the operation: | |
44 | .TP | |
45 | .BR MNT_FORCE " (since Linux 2.1.116)" | |
7045e438 | 46 | Ask the filesystem to abort pending requests before attempting the |
76218efa MK |
47 | unmount. |
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. | |
2f2ab744 | 53 | As at Linux 4.12, |
1ae6b2c7 | 54 | .B MNT_FORCE |
2f2ab744 MK |
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). | |
5614f733 MK |
62 | .TP |
63 | .BR MNT_DETACH " (since Linux 2.4.11)" | |
525a8b54 | 64 | Perform a lazy unmount: make the mount unavailable for new |
f1311221 EB |
65 | accesses, immediately disconnect the filesystem and all filesystems |
66 | mounted below it from each other and from the mount table, and | |
525a8b54 | 67 | actually 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 |
70 | Mark the mount as expired. |
71 | If a mount is not currently in use, then an initial call to | |
5614f733 MK |
72 | .BR umount2 () |
73 | with this flag fails with the error | |
74 | .BR EAGAIN , | |
525a8b54 MK |
75 | but marks the mount as expired. |
76 | The mount remains expired as long as it isn't accessed | |
5614f733 MK |
77 | by any process. |
78 | A second | |
79 | .BR umount2 () | |
80 | call specifying | |
81 | .B MNT_EXPIRE | |
525a8b54 | 82 | unmounts an expired mount. |
5614f733 MK |
83 | This flag cannot be specified with either |
84 | .B MNT_FORCE | |
85 | or | |
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 |
90 | Don't dereference |
91 | .I target | |
92 | if it is a symbolic link. | |
60fe1ea1 | 93 | This flag allows security problems to be avoided in set-user-ID-\fIroot\fP |
9ee4a2b6 | 94 | programs that allow unprivileged users to unmount filesystems. |
47297adb | 95 | .SH RETURN VALUE |
5614f733 MK |
96 | On success, zero is returned. |
97 | On error, \-1 is returned, and | |
98 | .I errno | |
f6a4078b | 99 | is set to indicate the error. |
5614f733 | 100 | .SH ERRORS |
9ee4a2b6 | 101 | The error values given below result from filesystem type independent |
5614f733 | 102 | errors. |
9ee4a2b6 | 103 | Each filesystem type may have its own special errors and its |
5614f733 | 104 | own special behavior. |
66a9882e | 105 | See the Linux kernel source code for details. |
5614f733 MK |
106 | .TP |
107 | .B EAGAIN | |
108 | A call to | |
109 | .BR umount2 () | |
110 | specifying | |
111 | .B MNT_EXPIRE | |
9ee4a2b6 | 112 | successfully marked an unbusy filesystem as expired. |
5614f733 MK |
113 | .TP |
114 | .B EBUSY | |
115 | .I target | |
116 | could not be unmounted because it is busy. | |
117 | .TP | |
118 | .B EFAULT | |
119 | .I target | |
120 | points outside the user address space. | |
121 | .TP | |
122 | .B EINVAL | |
123 | .I target | |
124 | is not a mount point. | |
ec4a728e MK |
125 | .TP |
126 | .B EINVAL | |
b3987057 MK |
127 | .I target |
128 | is locked; see | |
129 | .BR mount_namespaces (7). | |
130 | .TP | |
131 | .B EINVAL | |
5614f733 MK |
132 | .BR umount2 () |
133 | was called with | |
134 | .B MNT_EXPIRE | |
135 | and either | |
136 | .B MNT_DETACH | |
137 | or | |
138 | .BR MNT_FORCE . | |
139 | .TP | |
a7566673 MK |
140 | .BR EINVAL " (since Linux 2.6.34)" |
141 | .BR umount2 () | |
142 | was called with an invalid flag value in | |
143 | .IR flags . | |
144 | .TP | |
5614f733 MK |
145 | .B ENAMETOOLONG |
146 | A pathname was longer than | |
147 | .BR MAXPATHLEN . | |
148 | .TP | |
149 | .B ENOENT | |
150 | A pathname was empty or had a nonexistent component. | |
151 | .TP | |
152 | .B ENOMEM | |
153 | The kernel could not allocate a free page to copy filenames or data into. | |
154 | .TP | |
155 | .B EPERM | |
156 | The caller does not have the required privileges. | |
4131356c AC |
157 | .SH STANDARDS |
158 | Linux. | |
159 | .SH HISTORY | |
1ae6b2c7 | 160 | .B MNT_DETACH |
835c57e9 | 161 | and |
1ae6b2c7 | 162 | .B MNT_EXPIRE |
8749bd1a | 163 | .\" http://sourceware.org/bugzilla/show_bug.cgi?id=10092 |
b324e17d | 164 | are available since glibc 2.11. |
c6d039a3 | 165 | .P |
4131356c AC |
166 | The original |
167 | .BR umount () | |
168 | function was called as \fIumount(device)\fP and would return | |
169 | .B ENOTBLK | |
170 | when called with something other than a block device. | |
171 | In Linux 0.98p4, a call \fIumount(dir)\fP was added, in order to | |
172 | support anonymous devices. | |
173 | In Linux 2.3.99-pre7, the call \fIumount(device)\fP was removed, | |
174 | leaving only \fIumount(dir)\fP (since now devices can be mounted | |
175 | in more than one place, so specifying the device does not suffice). | |
5614f733 | 176 | .SH NOTES |
525a8b54 MK |
177 | .SS umount() and shared mounts |
178 | Shared mounts cause any mount activity on a mount, including | |
bf7bc8b8 | 179 | .BR umount () |
525a8b54 | 180 | operations, to be forwarded to every shared mount in the |
430a1677 MK |
181 | peer group and every slave mount of that peer group. |
182 | This means that | |
bf7bc8b8 | 183 | .BR umount () |
430a1677 MK |
184 | of any peer in a set of shared mounts will cause all of its |
185 | peers to be unmounted and all of their slaves to be unmounted as well. | |
c6d039a3 | 186 | .P |
430a1677 | 187 | This propagation of unmount activity can be particularly surprising |
525a8b54 | 188 | on systems where every mount is shared by default. |
430a1677 MK |
189 | On such systems, |
190 | recursively bind mounting the root directory of the filesystem | |
191 | onto a subdirectory and then later unmounting that subdirectory with | |
1ae6b2c7 | 192 | .B MNT_DETACH |
430a1677 | 193 | will cause every mount in the mount namespace to be lazily unmounted. |
c6d039a3 | 194 | .P |
430a1677 | 195 | To ensure |
bf7bc8b8 | 196 | .BR umount () |
430a1677 | 197 | does not propagate in this fashion, |
525a8b54 | 198 | the mount may be remounted using a |
e3a78ee9 | 199 | .BR mount (2) |
430a1677 MK |
200 | call with a |
201 | .I mount_flags | |
202 | argument that includes both | |
1ae6b2c7 | 203 | .B MS_REC |
430a1677 | 204 | and |
1ae6b2c7 | 205 | .B MS_PRIVATE |
430a1677 | 206 | prior to |
bf7bc8b8 | 207 | .BR umount () |
430a1677 | 208 | being 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) |