umount

unmount –   Unmount a device

-a mount all in /etc/tstab

-f forces unmount

-r if filesystem can’t be unmounted, remount in read-only mode

-t mounts specified file type you must specify device or mountpoint

       umount [-hV]

       umount -a [-dflnrv] [-t vfstype] [-O options]
       umount [-dflnrv] dir | device [...]

 

1. 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

2. 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. You can issue command umount -l with that partition and the unmount will be done after the disk operations gets finished.

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 /mydata -l

3. 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

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

Meanwhile, you can also have a look at ps command output that which process is presently using the mountpoint as shown below:

# ps ajx | grep /mydata
 2540  3037  3037  2468 pts/2     3037 D+       0   0:00 cp -r /home/geekstuff/ProjectData/ /mydata

You can also execute fuser command to find out which process is holding the directory for operations.

# fuser -cu /mydata
/mydata:              3087(root)

It gives you the process id with username (nothing but the owner of the process). If you know what that process is, you may want to stop that process and then try the umount again.