umount Command in Linux with Examples

This tutorial explains Linux “umount” command, options and its usage with examples.

umount – unmount a file system.


All files accessible in Unix, or a Unix-style system such as Linux, are arranged in one big tree: the file hierarchy, rooted at /. These files can be spread out over several devices. The mount command attaches a filesystem, located on some device or other, to the file tree. Conversely, the umount command will detach it again.

The umount command detaches the file system(s) mentioned 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 `busy’ – 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 be umount itself – it opens libc, and libc in its turn may open for example locale files. A lazy unmount avoids this problem.



umount [-hV]

umount -a [-dflnrv] [-t vfstype] [-O options]

umount [-dflnrv] {dir|device}…


Print version information and exit.
Print a help message and exit.
Run in verbose mode.
Unmount without writing in /etc/mtab.
In case unmounting fails, try to remount read-only.
In case the unmounted device was a loop device, also free this loop device.
Don’t call the /sbin/umount.filesystem helper even if it exists. By default /sbin/umount.filesystem helper is called if one exists.
All of the file systems described in /etc/mtab are to be unmounted. (With umount version 2.7 and later, the proc filesystem is not unmounted.)
-t vfstype
Indicate that the actions should only be taken on file systems of the specified type. More than one type may be specified in a comma separated list. The list of file system types can be prefixed with no to specify the file system types on which no action should be taken.
-O options
Indicate that the actions should only be taken on file systems with the specified options in /etc/fstab. More than one option type may be specified in a comma separated list. Each option can be prefixed with no to specify options for which no action should be taken.
Force unmount (in case of an unreachable NFS system). (Requires kernel 2.1.116 or later.)
“Lazy” unmount. Detach the filesystem from the filesystem hierarchy now, and cleanup all references to the filesystem as soon as it is not busy anymore. (Requires kernel 2.4.11 or later.)
Don’t canonicalize (standardize the textual representation of) paths.
Causes everything to be done except for the actual system call; this “fakes” unmounting the filesystem. It can be used to remove entries from /etc/mtab that were unmounted earlier with the -n option.


1. Unmount a single mount point

# umount /mydata

2. Unmount more than one mount points


Umount allows you to unmount more than mount point in a single execution of umount of command as follows:

# umount /mydata  /backup
# mount | grep /mydata
# mount | grep /backup

3. Lazy unmount of a filesystem

This is a special option in umount, in case you want to unmount a partition after disk operations are done.

For instance, consider a scenario that a task (i.e: script or any other command) is doing a copy operation on a disk and at the same time you are allowed to issue a unmount with -l, so that unmount would be done once the copy is over (i.e: the disk operation).

# umount /myfol -l

4. Forcefully unmount a filesystem

umount provides the option to forcefully unmount a filesystem with option -f when the device is busy as shown below:

# umount -f /mnt

Note : If this doesn’t work for you, then you can go for lazy unmount.

5. To unmount files and directories of a specific type, enter:

# umount  -t test

This unmounts all files or directories that have a stanza in the /etc/filesystems file that contains the type=test attribute.

Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.

If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.

If you find any mistake above, kindly email to [email protected]

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.