Section: Linux Programmer's Manual (2)Updated: 2010-06-19Local indexUp
umount, umount2 - unmount file system
#include <sys/mount.h>int umount(const char *target);int umount2(const char *target, int flags);
remove the attachment of the (topmost) file system mounted on
Appropriate privilege (Linux: the
capability) is required to unmount file systems.
Linux 2.1.116 added the
system call, which, like
unmounts a target, but allows additional
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, 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
with this flag fails with the error
but marks the mount point as expired.
The mount point remains expired as long as it isn't accessed
by any process.
unmounts an expired mount point.
This flag cannot be specified with either
UMOUNT_NOFOLLOW (since Linux 2.6.34)
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 file systems.
On success, zero is returned.
On error, -1 is returned, and
is set appropriately.
The error values given below result from file-system type independent
Each file system type may have its own special errors and its
own special behavior.
See the kernel source code for details.
A call to
successfully marked an unbusy file system as expired.
could not be unmounted because it is busy.
points outside the user address space.
is not a mount point.
was called with
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.
are only available in glibc since version 2.11.
These functions are Linux-specific and should not be used in
programs intended to be portable.
function was called as umount(device) and would return
when called with something other than a block device.
In Linux 0.98p4 a call umount(dir) was added, in order to
support anonymous devices.
In Linux 2.3.99-pre7 the call umount(device) was removed,
leaving only umount(dir) (since now devices can be mounted
in more than one place, so specifying the device does not suffice).