1UMOUNT(2)                  Linux Programmer's Manual                 UMOUNT(2)
2
3
4

NAME

6       umount, umount2 - unmount filesystem
7

SYNOPSIS

9       #include <sys/mount.h>
10
11       int umount(const char *target);
12
13       int umount2(const char *target, int flags);
14

DESCRIPTION

16       umount()  and umount2() remove the attachment of the (topmost) filesys‐
17       tem mounted on target.
18
19       Appropriate privilege (Linux: the CAP_SYS_ADMIN capability) is required
20       to unmount filesystems.
21
22       Linux  2.1.116  added  the umount2() system call, which, like umount(),
23       unmounts a target, but allows additional flags controlling the behavior
24       of the operation:
25
26       MNT_FORCE (since Linux 2.1.116)
27              Ask  the  filesystem to abort pending requests before attempting
28              the unmount.  This may allow the  unmount  to  complete  without
29              waiting  for  an inaccessible server, but could cause data loss.
30              If, after aborting requests, some processes  still  have  active
31              references  to  the filesystem, the unmount will still fail.  As
32              at Linux 4.12, MNT_FORCE is  supported  only  on  the  following
33              filesystems: 9p (since Linux 2.6.16), ceph (since Linux 2.6.34),
34              cifs (since Linux 2.6.12), fuse  (since  Linux  2.6.16),  lustre
35              (since Linux 3.11), and NFS (since Linux 2.1.116).
36
37       MNT_DETACH (since Linux 2.4.11)
38              Perform a lazy unmount: make the mount point unavailable for new
39              accesses, immediately disconnect the filesystem and all filesys‐
40              tems  mounted below it from each other and from the mount table,
41              and actually perform the unmount when the mount point ceases  to
42              be busy.
43
44       MNT_EXPIRE (since Linux 2.6.8)
45              Mark  the  mount point as expired.  If a mount point is not cur‐
46              rently in use, then an initial call to umount2() with this  flag
47              fails  with  the  error EAGAIN, but marks the mount point as ex‐
48              pired.  The mount point remains expired as long as it isn't  ac‐
49              cessed  by  any  process.   A  second  umount2() call specifying
50              MNT_EXPIRE unmounts an expired mount point.  This flag cannot be
51              specified with either MNT_FORCE or MNT_DETACH.
52
53       UMOUNT_NOFOLLOW (since Linux 2.6.34)
54              Don't  dereference  target  if it is a symbolic link.  This flag
55              allows security problems to be avoided in set-user-ID-root  pro‐
56              grams that allow unprivileged users to unmount filesystems.
57

RETURN VALUE

59       On  success,  zero is returned.  On error, -1 is returned, and errno is
60       set appropriately.
61

ERRORS

63       The error values given below result from  filesystem  type  independent
64       errors.   Each  filesystem type may have its own special errors and its
65       own special behavior.  See the Linux kernel source code for details.
66
67       EAGAIN A call to umount2() specifying MNT_EXPIRE successfully marked an
68              unbusy filesystem as expired.
69
70       EBUSY  target could not be unmounted because it is busy.
71
72       EFAULT target point