umount (unmount file systems)
This command is used to unmount file systems such as disk partitions. Note that there is no “n” in umount. The program is called like this:
You can specify the device to be unmounted (e.g. /dev/sda1) or its mount point (e.g. /media/data). Unmounting a removable file system such as a USB flash drive partition can take a long time. This is because Linux does not always transfer files to external media immediately. The files may enter a write buffer and sit there until Linux decides to copy them to the target device in one fell swoop.
When a file system is unmounted, Linux calls the sync command, which flushes all write buffers, commiting any changes to disk. You can run sync yourself, but you don't have to because umount does this automatically. When you're working with large files on a foreign system, you may want to run sync manually to ensure that your changes are committed to disk immediately.
Linux beginners often find themselves confronted with the following error:
Unmount failed: Cannot unmount because
file system on device is busy
You get this message when you try to unmount a device that is still in use. Sometimes it is far from obvious who is still using the device. For example, a file manager window may be showing the contents of a directory on the device. This can be enough for a call to umount to fail. Use the command lsof (“list open files”) to find out which processes are using files on your target device. For example:
This will list any processes that are using files on the partition /dev/sdb1. After terminating the processes, you will be able to unmount the device without errors.