Unmounting a Windows Share Fails in Linux

The Problem

Unable to unmount a Windows share mount point using umount command. This Windows share is not being used by any processes recently.

When executing umount command, following error is seen;

# umount: /mycloud: device is busy.
  (In some cases useful info about processes that use
  the device is found by lsof(8) or fuser(1))

The Solution

The error “umount: device is busy” means that the mount point is being held up by the server due to some reason. An lsof command is executed to find some open file descriptors.

# lsof /mycloud/
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
rsync 39176 oracle cwd DIR 0,25 0 54427649 /mycloud/primdb/rman
rsync 39176 oracle 1r REG 0,25 6678585344 54428135 /mycloud/primdb/rman/.RMDBPRD_LVL0_20170910_s145161_p1.WxJoHy (deleted)
rsync 39176 oracle 3u REG 0,25 5449449472 54428147 /mycloud/primdb/rman/.RMDBPRD_LVL0_20170910_s145161_p1.uqhidN

This PID could not be killed even with the kill command.

# kill -9 39176
# lsof /mycloud/
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
rsync 39176 oracle cwd DIR 0,25 0 54427649 /mycloud/primdb/rman
rsync 39176 oracle 1r REG 0,25 6678585344 54428135 /mycloud/primdb/rman/.RMDBPRD_LVL0_20170910_s145161_p1.WxJoHy (deleted)
rsync 39176 oracle 3u REG 0,25 5449449472 54428147 /mycloud/primdb/rman/.RMDBPRD_LVL0_20170910_s145161_p1.uqhidN

When checked, an rsync process which writes to this mount point is still in D state due to IO block which occurred some time ago.

# ps aux |grep rsync
root 30103 0.0 0.0 103304 804 pts/0 S+ 10:24 0:00 grep rsync
oracle 39176 0.0 0.0 110956 96 ? D Sep10 17:48 rsync -av --delete /eva/primdb/rman/ /mycloud/primdb/rman/

As this process is in uninterruptable sleep state, this process could not be killed. This is the reason why it is not able to unmount the Windows share from the server.

The D state processes could not be killed using kill command as these are like orphaned entries in the process list without a parent. So it is recommended to do a server reboot for killing any such D state processes.

If a reboot is not possible at the moment as in case of production servers, then wait until the IO becomes available again so that the process will wake up and get completed. However, it is not recommended to wait more than a month as gradually the server load might climb up if there are more such D state processes in the server.

Related Post