umount, umount2 — unmount filesystem
||const char *target
||const char *target,|
umount2() remove the attachment of the
(topmost) filesystem mounted on
Appropriate privilege (Linux: the
CAP_SYS_ADMIN capability) is required to
Linux 2.1.116 added the
umount2() system call, which, like
umount(), unmounts a target,
but allows additional
flags controlling the behavior
of the operation:
MNT_FORCE(since Linux 2.1.116)
Force unmount even if busy. This can cause data loss. (Only for NFS mounts.)
MNT_DETACH(since Linux 2.4.11)
Perform a lazy unmount: make the mount point unavailable for new accesses, immediately disconnect the filesystem and all filesystems mounted below it from each other and from the mount table, and actually perform the unmount when the mount point ceases to be busy.
MNT_EXPIRE(since Linux 2.6.8)
Mark the mount point as expired. If a mount point is
not currently in use, then an initial call to
umount2() with this flag
fails with the error EAGAIN, but marks the mount point as
expired. The mount point remains expired as long as it
isn't accessed by any process. A second
umount2() call specifying
MNT_EXPIRE unmounts an
expired mount point. This flag cannot be specified with
UMOUNT_NOFOLLOW(since Linux 2.6.34)
target if it is a
symbolic link. This flag allows security problems to be
avoided in set-user-ID-
root programs that
allow unprivileged users to unmount filesystems.
On success, zero is returned. On error, −1 is
errno is set
The error values given below result from filesystem type independent errors. Each filesystem type may have its own special errors and its own special behavior. See the Linux kernel source code for details.
A call to
successfully marked an unbusy filesystem as
not be unmounted because it is busy.
points outside the user address space.
not a mount point.
umount2() was called
umount2() was called
with an invalid flag value in
A pathname was longer than
A pathname was empty or had a nonexistent component.
The kernel could not allocate a free page to copy filenames or data into.
The caller does not have the required privileges.
These functions are Linux-specific and should not be used in programs intended to be portable.
Shared mount points cause any mount activity on a mount point, including umount(2) operations, to be forwarded to every shared mount point in the peer group and every slave mount of that peer group. This means that umount(2) of any peer in a set of shared mounts will cause all of its peers to be unmounted and all of their slaves to be unmounted as well.
This propagation of unmount activity can be particularly
surprising on systems where every mount point is shared by
default. On such systems, recursively bind mounting the
root directory of the filesystem onto a subdirectory and
then later unmounting that subdirectory with
MNT_DETACH will cause every mount in the
mount namespace to be lazily unmounted.
To ensure umount(2) does not
propagate in this fashion, the mount point may be remounted
using a mount(2) call with a
argument that includes both
MS_PRIVATE prior to umount(2) being
function was called as
umount(device) and would
return ENOTBLK when called
with something other than a block device. In Linux 0.98p4,
umount(dir) was added, in
order to support anonymous devices. In Linux 2.3.99-pre7,
umount(device) was removed,
umount(dir) (since now
devices can be mounted in more than one place, so
specifying the device does not suffice).
This page is part of release 4.07 of the Linux
man-pages project. A
description of the project, information about reporting bugs,
and the latest version of this page, can be found at
Copyright (C) 1993 Rickard E. Faith <faithcs.unc.edu>
and Copyright (C) 1994 Andries E. Brouwer <aebcwi.nl>
and Copyright (C) 2002, 2005 Michael Kerrisk <mtk.manpagesgmail.com>
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Since the Linux kernel and libraries are constantly changing, this
manual page may be incorrect or out-of-date. The author(s) assume no
responsibility for errors or omissions, or for damages resulting from
the use of the information contained herein. The author(s) may not
have taken the same level of care in the production of this manual,
which is licensed free of charge, as they might when working
Formatted or processed versions of this manual, if unaccompanied by
the source, must acknowledge the copyright and authors of this work.
2008-10-06, mtk: Created this as a new page by splitting
umount/umount2 material out of mount.2