Blame man2/umount.2

Packit 7cfc04
.\" Copyright (C) 1993 Rickard E. Faith <faith@cs.unc.edu>
Packit 7cfc04
.\" and Copyright (C) 1994 Andries E. Brouwer <aeb@cwi.nl>
Packit 7cfc04
.\" and Copyright (C) 2002, 2005 Michael Kerrisk <mtk.manpages@gmail.com>
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(VERBATIM)
Packit 7cfc04
.\" Permission is granted to make and distribute verbatim copies of this
Packit 7cfc04
.\" manual provided the copyright notice and this permission notice are
Packit 7cfc04
.\" preserved on all copies.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Permission is granted to copy and distribute modified versions of this
Packit 7cfc04
.\" manual under the conditions for verbatim copying, provided that the
Packit 7cfc04
.\" entire resulting derived work is distributed under the terms of a
Packit 7cfc04
.\" permission notice identical to this one.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Since the Linux kernel and libraries are constantly changing, this
Packit 7cfc04
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
Packit 7cfc04
.\" responsibility for errors or omissions, or for damages resulting from
Packit 7cfc04
.\" the use of the information contained herein.  The author(s) may not
Packit 7cfc04
.\" have taken the same level of care in the production of this manual,
Packit 7cfc04
.\" which is licensed free of charge, as they might when working
Packit 7cfc04
.\" professionally.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Formatted or processed versions of this manual, if unaccompanied by
Packit 7cfc04
.\" the source, must acknowledge the copyright and authors of this work.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.\" 2008-10-06, mtk: Created this as a new page by splitting
Packit 7cfc04
.\"     umount/umount2 material out of mount.2
Packit 7cfc04
.\"
Packit 7cfc04
.TH UMOUNT 2 2017-09-15 "Linux" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
umount, umount2 \- unmount filesystem
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.nf
Packit 7cfc04
.B "#include <sys/mount.h>"
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int umount(const char *" target );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int umount2(const char *" target ", int " flags );
Packit 7cfc04
.fi
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
.BR umount ()
Packit 7cfc04
and
Packit 7cfc04
.BR umount2 ()
Packit 7cfc04
remove the attachment of the (topmost) filesystem mounted on
Packit 7cfc04
.IR target .
Packit 7cfc04
.\" Note: the kernel naming differs from the glibc naming
Packit 7cfc04
.\" umount2 is the glibc name for what the kernel now calls umount
Packit 7cfc04
.\" and umount is the glibc name for oldumount
Packit 7cfc04
.PP
Packit 7cfc04
Appropriate privilege (Linux: the
Packit 7cfc04
.B CAP_SYS_ADMIN
Packit 7cfc04
capability) is required to unmount filesystems.
Packit 7cfc04
.PP
Packit 7cfc04
Linux 2.1.116 added the
Packit 7cfc04
.BR umount2 ()
Packit 7cfc04
system call, which, like
Packit 7cfc04
.BR umount (),
Packit 7cfc04
unmounts a target, but allows additional
Packit 7cfc04
.I flags
Packit 7cfc04
controlling the behavior of the operation:
Packit 7cfc04
.TP
Packit 7cfc04
.BR MNT_FORCE " (since Linux 2.1.116)"
Packit 7cfc04
Ask the filesystem to abort pending requests before attempting the
Packit 7cfc04
unmount.
Packit 7cfc04
This may allow the unmount to complete without waiting
Packit 7cfc04
for an inaccessible server, but could cause data loss.
Packit 7cfc04
If, after aborting requests,
Packit 7cfc04
some processes still have active references to the filesystem,
Packit 7cfc04
the unmount will still fail.
Packit 7cfc04
As at Linux 4.12,
Packit 7cfc04
.BR MNT_FORCE
Packit 7cfc04
is supported only on the following filesystems:
Packit 7cfc04
9p (since Linux 2.6.16),
Packit 7cfc04
ceph (since Linux 2.6.34),
Packit 7cfc04
cifs (since Linux 2.6.12),
Packit 7cfc04
fuse (since Linux 2.6.16),
Packit 7cfc04
lustre (since Linux 3.11),
Packit 7cfc04
and NFS (since Linux 2.1.116).
Packit 7cfc04
.TP
Packit 7cfc04
.BR MNT_DETACH " (since Linux 2.4.11)"
Packit 7cfc04
Perform a lazy unmount: make the mount point unavailable for new
Packit 7cfc04
accesses, immediately disconnect the filesystem and all filesystems
Packit 7cfc04
mounted below it from each other and from the mount table, and
Packit 7cfc04
actually perform the unmount when the mount point ceases to be busy.
Packit 7cfc04
.TP
Packit 7cfc04
.BR MNT_EXPIRE " (since Linux 2.6.8)"
Packit 7cfc04
Mark the mount point as expired.
Packit 7cfc04
If a mount point is not currently in use, then an initial call to
Packit 7cfc04
.BR umount2 ()
Packit 7cfc04
with this flag fails with the error
Packit 7cfc04
.BR EAGAIN ,
Packit 7cfc04
but marks the mount point as expired.
Packit 7cfc04
The mount point remains expired as long as it isn't accessed
Packit 7cfc04
by any process.
Packit 7cfc04
A second
Packit 7cfc04
.BR umount2 ()
Packit 7cfc04
call specifying
Packit 7cfc04
.B MNT_EXPIRE
Packit 7cfc04
unmounts an expired mount point.
Packit 7cfc04
This flag cannot be specified with either
Packit 7cfc04
.B MNT_FORCE
Packit 7cfc04
or
Packit 7cfc04
.BR MNT_DETACH .
Packit 7cfc04
.TP
Packit 7cfc04
.BR UMOUNT_NOFOLLOW " (since Linux 2.6.34)"
Packit 7cfc04
.\" Later added to 2.6.33-stable
Packit 7cfc04
Don't dereference
Packit 7cfc04
.I target
Packit 7cfc04
if it is a symbolic link.
Packit 7cfc04
This flag allows security problems to be avoided in set-user-ID-\fIroot\fP
Packit 7cfc04
programs that allow unprivileged users to unmount filesystems.
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
On success, zero is returned.
Packit 7cfc04
On error, \-1 is returned, and
Packit 7cfc04
.I errno
Packit 7cfc04
is set appropriately.
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
The error values given below result from filesystem type independent
Packit 7cfc04
errors.
Packit 7cfc04
Each filesystem type may have its own special errors and its
Packit 7cfc04
own special behavior.
Packit 7cfc04
See the Linux kernel source code for details.
Packit 7cfc04
.TP
Packit 7cfc04
.B EAGAIN
Packit 7cfc04
A call to
Packit 7cfc04
.BR umount2 ()
Packit 7cfc04
specifying
Packit 7cfc04
.B MNT_EXPIRE
Packit 7cfc04
successfully marked an unbusy filesystem as expired.
Packit 7cfc04
.TP
Packit 7cfc04
.B EBUSY
Packit 7cfc04
.I target
Packit 7cfc04
could not be unmounted because it is busy.
Packit 7cfc04
.TP
Packit 7cfc04
.B EFAULT
Packit 7cfc04
.I target
Packit 7cfc04
points outside the user address space.
Packit 7cfc04
.TP
Packit 7cfc04
.B EINVAL
Packit 7cfc04
.I target
Packit 7cfc04
is not a mount point.
Packit 7cfc04
.TP
Packit 7cfc04
.B EINVAL
Packit 7cfc04
.BR umount2 ()
Packit 7cfc04
was called with
Packit 7cfc04
.B MNT_EXPIRE
Packit 7cfc04
and either
Packit 7cfc04
.B MNT_DETACH
Packit 7cfc04
or
Packit 7cfc04
.BR MNT_FORCE .
Packit 7cfc04
.TP
Packit 7cfc04
.BR EINVAL " (since Linux 2.6.34)"
Packit 7cfc04
.BR umount2 ()
Packit 7cfc04
was called with an invalid flag value in
Packit 7cfc04
.IR flags .
Packit 7cfc04
.TP
Packit 7cfc04
.B ENAMETOOLONG
Packit 7cfc04
A pathname was longer than
Packit 7cfc04
.BR MAXPATHLEN .
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOENT
Packit 7cfc04
A pathname was empty or had a nonexistent component.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOMEM
Packit 7cfc04
The kernel could not allocate a free page to copy filenames or data into.
Packit 7cfc04
.TP
Packit 7cfc04
.B EPERM
Packit 7cfc04
The caller does not have the required privileges.
Packit 7cfc04
.SH VERSIONS
Packit 7cfc04
.BR MNT_DETACH
Packit 7cfc04
and
Packit 7cfc04
.BR MNT_EXPIRE
Packit 7cfc04
.\" http://sourceware.org/bugzilla/show_bug.cgi?id=10092
Packit 7cfc04
are available in glibc since version 2.11.
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
These functions are Linux-specific and should not be used in
Packit 7cfc04
programs intended to be portable.
Packit 7cfc04
.SH NOTES
Packit 7cfc04
.SS umount() and shared mount points
Packit 7cfc04
Shared mount points cause any mount activity on a mount point, including
Packit 7cfc04
.BR umount ()
Packit 7cfc04
operations, to be forwarded to every shared mount point in the
Packit 7cfc04
peer group and every slave mount of that peer group.
Packit 7cfc04
This means that
Packit 7cfc04
.BR umount ()
Packit 7cfc04
of any peer in a set of shared mounts will cause all of its
Packit 7cfc04
peers to be unmounted and all of their slaves to be unmounted as well.
Packit 7cfc04
.PP
Packit 7cfc04
This propagation of unmount activity can be particularly surprising
Packit 7cfc04
on systems where every mount point is shared by default.
Packit 7cfc04
On such systems,
Packit 7cfc04
recursively bind mounting the root directory of the filesystem
Packit 7cfc04
onto a subdirectory and then later unmounting that subdirectory with
Packit 7cfc04
.BR MNT_DETACH
Packit 7cfc04
will cause every mount in the mount namespace to be lazily unmounted.
Packit 7cfc04
.PP
Packit 7cfc04
To ensure
Packit 7cfc04
.BR umount ()
Packit 7cfc04
does not propagate in this fashion,
Packit 7cfc04
the mount point may be remounted using a
Packit 7cfc04
.BR mount ()
Packit 7cfc04
call with a
Packit 7cfc04
.I mount_flags
Packit 7cfc04
argument that includes both
Packit 7cfc04
.BR MS_REC
Packit 7cfc04
and
Packit 7cfc04
.BR MS_PRIVATE
Packit 7cfc04
prior to
Packit 7cfc04
.BR umount ()
Packit 7cfc04
being called.
Packit 7cfc04
.SS Historical details
Packit 7cfc04
The original
Packit 7cfc04
.BR umount ()
Packit 7cfc04
function was called as \fIumount(device)\fP and would return
Packit 7cfc04
.B ENOTBLK
Packit 7cfc04
when called with something other than a block device.
Packit 7cfc04
In Linux 0.98p4, a call \fIumount(dir)\fP was added, in order to
Packit 7cfc04
support anonymous devices.
Packit 7cfc04
In Linux 2.3.99-pre7, the call \fIumount(device)\fP was removed,
Packit 7cfc04
leaving only \fIumount(dir)\fP (since now devices can be mounted
Packit 7cfc04
in more than one place, so specifying the device does not suffice).
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR mount (2),
Packit 7cfc04
.BR mount_namespaces (7),
Packit 7cfc04
.BR path_resolution (7),
Packit 7cfc04
.BR mount (8),
Packit 7cfc04
.BR umount (8)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.