Forcefully Unmount disk or partition – (umount /partition: device is busy)

Forcefully Unmount disk or partition – (umount /partition: device is busy)

Normally when we try to unmount a partition or a disk (Cd-rom or any other partitions) in Linux, sometimes we get an error umount: /xxx: device is busy. This is because other resources of the machine are still accessing the drive. You can use the fuser command to kill forcefully mounted partition or you can also figure out which process is accessing the drive.

# fuser -m /mnt/cdrom
/mnt/cdrom: 4769

The above command list all the PID which is responsible for keeping the device busy. To check the process related to above PID use the following command:

# ps aux|grep 4769

You can kill this process and try unmount the disk. If still you are getting same error, use the following command to forcefully unmountthe partition or disk:

# fuser -km /mnt/cdrom

Where,
• -k : Kill processes accessing the file.
• -m : Name specifies a file on a mounted file system or a block device that is mounted. In above example you are using /mnt/cdrom.

fuser -km /mnt/cdrom kills all processes accessing the file system /mnt/cdrom in any way. The -k option only works on processes. If the user is the kernel, fuser will print an advice, but take no action beyond that.

Now use the umount command to unmount a disk or partition from your system.

# umount   /mnt

This will safely remove /mnt/cdrom from your machine. To verify this, use the fdisk command:

# fdisk -l

This will list the all the partitions of your system.