LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 09-07-2011, 04:35 AM   #1
solid_state
LQ Newbie
 
Registered: Sep 2011
Posts: 1

Rep: Reputation: Disabled
Unhappy Unmounting Detachable devices(eSATA,USB storage) in linux


A detachable device like eSATA,USB can be abruptly removed (by simply pulling the plug).
Then, if there are open file handles on a partition , then the partitions wont unmount. i.e. the Linux "umount" command will fail, even AFTER the drive is physically detached.
And if the unmount fails, then on reattachment of the device the mount will fail. So we will have to find out which processes are using the drive and kill them or close all the handles. And if you cannot do either , then you will have to reboot the box to see your drive mounted. And I can definitely not kill the process using it.
I see no force unmount option , there is a -f option but it is only for NFS.

This sounds very strange,doesn't Linux
accommodate for this scenario where a user simply yanks a drive? Does anyone know how to handle this scenario gracefully in Linux,programmatically?

Is there any way to find out what file handles are open on a particular partition/device or selectively flush and close all file handles only for a particular device ?
 
Old 09-07-2011, 11:36 PM   #2
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,986

Rep: Reputation: 388Reputation: 388Reputation: 388Reputation: 388
Take a look at the fuser command:

# fuser -vm <path to device file>

lists all processes accessing the device and:

# fuser -km <path to device file>

kills all processes accessing the device.
 
Old 09-07-2011, 11:56 PM   #3
mulyadi.santosa
Member
 
Registered: Sep 2011
Posts: 96

Rep: Reputation: 15
Hi

Quote:
Originally Posted by solid_state View Post
This sounds very strange,doesn't Linux
accommodate for this scenario where a user simply yanks a drive? Does anyone know how to handle this scenario gracefully in Linux,programmatically?

Is there any way to find out what file handles are open on a particular partition/device or selectively flush and close all file handles only for a particular device ?
The thing is, AFAIK, if you execute read() function, the error return value doesn't include something like "the device that contains your read target doesn't exist anymore". The closest I saw in "man read" in EIO, which means I/O error. And I doubt that any recent application really anticipate all of the error return value *very carefully*.

IMHO, all of the existing OSes also don't anticipate this kind of situation, since it's more like accident rather than systematical error. It's like as bad as you got sudden error in your MBR, only more awful
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
USB Mass storage devices don't work in linux 2.6.[9,11.x] _private Debian 9 11-06-2013 06:46 AM
steps to block usb mass storage devices in linux anirbanseal80 Linux - Hardware 2 09-07-2010 03:11 PM
Unmounting USB devices jiml8 Linux - Software 9 07-02-2007 10:27 AM
Is it possible to disable power supply to an USB storage device when unmounting? costavi Linux - Hardware 2 11-14-2006 03:23 AM
little questions about USB storage devices on linux darksmiley Linux - Hardware 5 02-03-2006 05:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 08:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration