Manpage of UMOUNT
UMOUNTSection: Linux Programmer's Manual (2)
NAMEumount, umount2 - unmount filesystem
#include <sys/mount.h>int umount(const char *target);int umount2(const char *target, int flags);
DESCRIPTIONumount() and umount2() remove the attachment of the (topmost) filesystem mounted on target.
Appropriate privilege (Linux: the CAP_SYS_ADMINcapability) is required to unmount filesystems.
Linux 2.1.116 added the umount2() system call, which, like umount(), unmounts a target, but allows additional flagscontrolling 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_EXPIREunmounts an expired mount point. This flag cannot be specified with either MNT_FORCEor MNT_DETACH.
- UMOUNT_NOFOLLOW (since Linux 2.6.34)
- Don't dereference 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.
RETURN VALUEOn success, zero is returned. On error, -1 is returned, and errnois set appropriately.
ERRORSThe 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 umount2() specifying 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 MNT_EXPIREand either MNT_DETACHor MNT_FORCE.
- EINVAL (since Linux 2.6.34)
- umount2() was called with an invalid flag value in flags.
- A pathname was longer than MAXPATHLEN.
- 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.
VERSIONSMNT_DETACHand MNT_EXPIREare available in glibc since version 2.11.
CONFORMING TOThese functions are Linux-specific and should not be used in programs intended to be portable.
umount() and shared mount pointsShared mount points cause any mount activity on a mount point, including umount() 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() 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_DETACHwill cause every mount in the mount namespace to be lazily unmounted.
To ensure umount() does not propagate in this fashion, the mount point may be remounted using a mount() call with a mount_flagsargument that includes both MS_RECand MS_PRIVATEprior to umount() being called.
Historical detailsThe original umount() function was called as umount(device) and would return ENOTBLKwhen 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).
SEE ALSOmount(2), mount_namespaces(7), path_resolution(7), mount(8), umount(8)
- RETURN VALUE
- CONFORMING TO
- SEE ALSO
This document was created by man2html, using the manual pages.
Time: 16:30:08 GMT, March 14, 2017 Click Here!