An hard-disk hostage situation

This article has been originally published in Italian (here). Feedbacks on content and translation are appreciated. Contributions are welcome. The original article must be considered the reference in case of updates.
Old chainWhat if your trusted penguin (once in a while) became a criminal and held an external disk hostage, preventing the unmount?

It might happen, after viewing the content of a disk (even an internal one) through the file manager, that the process is not properly shut down. That is, we close the file manager window but it remains active.

When we try to remove – unmount and disconnect – the drive, we are presented with an error message of “device busy” and unmount not successful. The system still detects files kept “open” by an application.

Before getting tougher and unplugging cords and connectors we might try to investigate a little, using the lsof command, meant exactly to list (“ls-” = “list”) currently open files (“-of” = “open files”):

~$ lsof | grep Tera
dolphin   2001   mfm  cwd  DIR  8,50 4096  5181 /media/Tera_2/Documents

In the example above I combined lsof with grep to filter out a relevant string (in lsof output as well as that of any other command or file contents). The filter is obviously the volume label (part of it, actually, as I am too lazy to write it in full) of disk to be unmounted, /media/Tera_2.

I find out that the culprit is the butler file manager (dolphin), whose PID (Process ID, a unique number that identifies each process) is 2001 (“A space odissey”? “HAL, remove the disk. HAL!“). Next in the line are name of process owner (mfm), a little techno “blah-blah” and, at the end of the line, the path of  “hostage” folder, that is therefore seen as used.

Through the PID I can kill without mercy the offending process and free the hostage, like Jeanclòvvandamm at his best:

~$ kill 2001

Running lsof once more confirms that nothing else is preventing volume unmount:

~$ lsof | grep Tera
~$

Proud of my bravery, I can unmount and go to sleep.


While we are at it, if such a problem should occur in Windows, you might want to simply kill the process “explorer.exe” in Task Manager (or whatever it is called now, I am a little behind with versions).

Select the process in list, right click on it and select “End process” (“Termina processo” in italian). Alternatively just select process and press DEL or the “End process” button in the lower area of window. This “trick” is actually a little overkill, since explorer is not only the file manager process but “all the rest”. So, no panic if you see icons and the taskbar disappear from desktop. Did anyone notice the literary references?

To bring everything back we should restart the process from Task manager (summon it quickly with CTRL + Shift + ESC shortcut): head to menu bar and click File → New task (Run…). In the dialog window type “explorer.exe” and click OK.


Et voilà, your desktop is back at its usual mess :-). Mmh, it took me 3 screenshots to explain such a simple thing?!?! 😀

Informazioni su Man from Mars

https://extendedreality.wordpress.com/

Dimmi che ne pensi o fai "Ciao ciao!" con la manina // Share your thoughts or just say "Hello!"

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...

%d blogger hanno fatto clic su Mi Piace per questo: