Section (2) umount
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)
Ask the filesystem to abort pending requests before attempting the unmount. This may allow the unmount to complete without waiting for an inaccessible server, but could cause data loss. If, after aborting requests, some processes still have active references to the filesystem, the unmount will still fail. As at Linux 4.12,
MNT_FORCEis supported only on the following filesystems: 9p (since Linux 2.6.16), ceph (since Linux 2.6.34), cifs (since Linux 2.6.12), fuse (since Linux 2.6.16), lustre (since Linux 3.11), and NFS (since Linux 2.1.116).
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_zsingle_quotesz_t accessed by any process. A second
umount2() call specifying
MNT_EXPIREunmounts an expired mount point. This flag cannot be specified with either
UMOUNT_NOFOLLOW(since Linux 2.6.34)
targetif it is a symbolic link. This flag allows security problems to be avoided in set-user-ID-
rootprograms 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
MNT_EXPIREsuccessfully marked an unbusy filesystem as expired.
targetcould not be unmounted because it is busy.
targetpoints outside the user address space.
targetis not a mount point.
umount2() was called with
- EINVAL (since Linux 2.6.34)
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.
umount() and shared mount points
Shared mount points cause any mount activity on a mount
operations, to be forwarded to every shared mount point in
the peer group and every slave mount of that peer group.
This means that
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.
not propagate in this fashion, the mount point may be
remounted using a
call with a
mount_flags argument that
MS_PRIVATE prior to
umount() being called.
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.16 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
Section (8) umount
umount — unmount file systems
umount -a [
−t fstype ] [
−O option... ]
−dflnrv] directory | device ...
The umount command detaches the mentioned file system(s) from the file hierarchy. A file system is specified by giving the directory where it has been mounted. Giving the special device on which the file system lives may also work, but is obsolete, mainly because it will fail in case this device was mounted on more than one directory.
Note that a file system cannot be unmounted when it is
_zsingle_quotesz_busy_zsingle_quotesz_ - for example, when there are open files on it, or
when some process has its working directory there, or when a
swap file on it is in use. The offending process could even
itself - it opens libc, and libc in its turn may open for
example locale files. A lazy unmount avoids this problem, but
it may introduce another issues. See
−−lazy description below.
All of the filesystems described in
/proc/self/mountinfo(or in deprecated /etc/mtab) are unmounted, except the proc, devfs, devpts, sysfs, rpc_pipefs and nfsd filesystems. This list of the filesystems may be replaced by
Unmount all mountpoints in the current namespace for the specified filesystem. The filesystem can be specified by one of the mountpoints or the device name (or UUID, etc.). When this option is used together with
−−recursive, then all nested mounts within the filesystem are recursively unmounted. This option is only supported on systems where /etc/mtab is a symlink to /proc/mounts.
Do not canonicalize paths. The paths canonicalization is based on stat(2) and readlink(2) system calls. These system calls may hang in some cases (for example on NFS if server is not available). The option has to be used with canonical path to the mount point.
For more details about this option see the mount(8) man page. Note that umount does not pass this option to the
When the unmounted device was a loop device, also free this loop device. This option is unnecessary for devices initialized by mount(8), in this case autoclear functionality is enabled by default.
Causes everything to be done except for the actual system call or umount helper execution; this _zsingle_quotesz_fakes_zsingle_quotesz_ unmounting the filesystem. It can be used to remove entries from the deprecated
/etc/mtabthat were unmounted earlier with the
Force an unmount (in case of an unreachable NFS system).
Note that this option does not guarantee that umount command does not hang. It_zsingle_quotesz_s strongly recommended to use absolute paths without symlinks to avoid unwanted readlink and stat system calls on unreachable NFS in umount.
Do not call the
/sbin/umount.filesystem helper even if it exists. By default such a helper program is called if it exists.
Lazy unmount. Detach the filesystem from the file hierarchy now, and clean up all references to this filesystem as soon as it is not busy anymore.
A system reboot would be expected in near future if you_zsingle_quotesz_re going to use this option for network filesystem or local filesystem with submounts. The recommended use-case for umount -l is to prevent hangs on shutdown due to an unreachable network share where a normal umount will hang due to a downed server or a network partition. Remounts of the share will not be possible.
Perform umount in namespace specified by ns. ns is either PID of process running in that namespace or special file representing that namespace.
umount(8) switches to the namespace when it reads /etc/fstab, writes /etc/mtab (or writes to /run/mount) and calls umount(2) system call, otherwise it runs in the original namespace. It means that the target namespace does not have to contain any libraries or another requirements necessary to execute umount(2) command.
See namespaces(7) for more information.
Unmount without writing in
Unmount only the filesystems that have the specified option set in
/etc/fstab. More than one option may be specified in a comma-separated list. Each option can be prefixed with
noto indicate that no action should be taken for this option.
Suppress not mounted error messages.
Recursively unmount each specified directory. Recursion for each directory will stop if any unmount operation in the chain fails for any reason. The relationship between mountpoints is determined by /proc/self/mountinfo entries. The filesystem must be specified by mountpoint path; a recursive unmount by device name (or UUID) is unsupported.
When an unmount fails, try to remount the filesystem read-only.
Indicate that the actions should only be taken on filesystems of the specified type. More than one type may be specified in a comma-separated list. The list of filesystem types can be prefixed with
noto indicate that no action should be taken for all of the mentioned types. Note that umount reads information about mounted filesystems from kernel (/proc/mounts) and filesystem names may be different than filesystem names used in the /etc/fstab (e.g. nfs4 vs. nfs).
Display version information and exit.
Display help text and exit.
The umount command will automatically detach loop device previously initialized by mount(8) command independently of /etc/mtab.
In this case the device is initialized with autoclear flag (see losetup(8) output for more details), otherwise it_zsingle_quotesz_s necessary to use the option −−detach−loop or call losetup -d <device>. The autoclear feature is supported since Linux 2.6.25.
The syntax of external unmount helpers is:
is the filesystem type (or the value from a
helper= marker in the mtab
−t option can be
used for filesystems that have subtype support. For
umount.fuse −t fuse.sshfs
(unprivileged helper) can appear in the
/etc/mtab file when ordinary users need to
be able to unmount a mountpoint that is not defined in
/etc/fstab (for example for a
device that was mounted by udisks(1)).
A helper=type marker in the mtab
file will redirect all unmount requests to the
/sbin/umount.type helper independently
currently deprecated and helper= and another userspace mount
options are maintained by libmount.
table of mounted filesystems (deprecated and usually replaced by symlink to /proc/mounts)
table of known filesystems
table of mounted filesystems generated by kernel.
overrides the default location of the fstab file (ignored for suid)
overrides the default location of the mtab file (ignored for suid)
enables libmount debug output
The umount command is part of the util-linux package and is available from Linux Kernel Archive
Copyright (c) 1996 Andries Brouwer
This page is somewhat derived from a page that was
(c) 1980, 1989, 1991 The Regents of the University of California
and had been heavily modified by Rik Faith and myself.
This is free documentation; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
The GNU General Public License_zsingle_quotesz_s references to object code
and executables are to be interpreted as the output of any
document formatting or typesetting system, including
intermediate and printed output.
This manual is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.