Umount

From LQWiki
Jump to navigation Jump to search

umount (not "unmount") detaches a volume from the file hierarchy - unmounting it. This may be necessary in order to stop a removable disk in order to ensure the filesystem is left in a consistent state so you can remove it.

For example, if /dev/hdc1 is mounted as /mnt/onedisk then you will be able to browse the contents of hdc1 as though it were just another directory. However, once you "umount" it, it will appear devoid of content. It doesn't mean that there isn't anything on hdc1 - it just means that the kernel is no longer associating /mnt/onedisk with hdc1. This can be remedied by using mount to restore this association.

"device is busy" errors

A common issue when attempting to unmount devices currently mounted is that umount will refuse, stating that the device is currently busy. One must close the file in all the processes that are using the device (that is, accessing files or using the device directly). If you don't know what is using the device, use fuser, or use lsof, as root:

 su
 lsof /media/cdrom

Alternatively, if the device is mounted in the filesystem, and you are currently in that filesystem, simply changing directory first will often allow umount to do its work.

If the mount in question is smbfs and the target machine had been rebooted or the network connection otherwise interrupted, you may get an "Input/output error" when you try to umount or lsof. To solve this, use a "lazy umount":

 umount -l /mnt/windows

Provided by

Most (all?) Linux distributions incorporate this from the [util-linux] project.

See also