Force unmount of a removable drive

Recently I was running Unetbootin to install a live dvd image on a pen drive. It got stuck in the middle of the job, and even after closing it, I couldnt umount it with umount or gparted. It was suggested that I use fuser or lsob to identify and terminate the running process.

Gparted showed me that the drive was the device /dev/sdc1

So I tried to identify the process using the device

$ ps ax | grep '/media/D514-D264'
20291 ? D 0:09 /usr/lib/p7zip/7z -bd -aos -o/media/D514-D264 e /userhome/CD Images/livedvd-x86-amd64-32ul-2012.1.iso image.squashfs
21055 ? D 0:05 /usr/lib/p7zip/7z -bd -aos -o/media/D514-D264 e /userhome/CD Images/livedvd-x86-amd64-32ul-2012.1.iso image.squashfs
22896 pts/4 S+ 0:00 grep --color=auto /media/D514-D264[/code]

The integer displayed on lefthand coloumn is the PID (processid)

The command kill can be used to stop the process, by specifying the kill signal and process id.

Table 12-2. Common kill signals

Signal name Signal value Effect
SIGHUP 1 Hangup
SIGINT 2 Interrupt from keyboard
SIGKILL 9 Kill signal
SIGTERM 15 Termination signal
SIGSTOP 17,19,23 Stop the process

So to kill (signal 9) processes 20291,21055,22896 I would issue the command:

[[email protected] c]$ sudo kill -9 21055
[[email protected] c]$ sudo kill -9 22896
kill: No such process
[[email protected] c]$ ps ax | grep '/media/D514-D264'
[/code]

There, no more running processes using the device. Voila, now gparted has no problem unmounting the device!


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.