A USB drive never forgets

Greetings all:

I have recently been using 2" spinning hard drives in USB carriers for archiving data.
When the drive is attached, the drive is recognized, and a device is automatically added to /dev.
I can then mount the drive either with the mount command or KDE’s device manager.
This is the expected behavior.

However, after I umount the drive, and disconnect the USB cable, the device STILL continues to show up
in the /dev list (and in the /dev/disk/by-label directory).
This does NOT happen when hot-plugging/unplugging SATA drives.

It is not a big problem, but the “phantom” drive left behind does cause some issues with a few scripts.

Is there some magic that I can do to have the /dev entry automatically removed when the drive is unplugged?

I am running Suse 12.3 64 bit & KDE on an ASUS Sabertooth motherboard. The USB ports used are USB-3.

Thanx in advance.

Richard Rosa

As we are allways very suspicious about stories told by humans, but not backed by computer facts (after all we humans are not infallible, but computers are :wink: ), my question is: did you check it was realy unmounted before you disconnected?

So I normally connect using Dolphin and when done eject using Dolphin. I do not just unplug it. It is a two part process when followed seems to not leave you in a bad condition. Have you considered it is how you are doing it?

Thank You,

I just checked this on 12.2 and it is not USB3. So for what it is worth, de device special file is gone immediatly after removal.

Being human, I am VERY fallible.
Let it be known that I typically issue the “umount” command twice to make sure that I get the “not mounted” message.

Rich

I’ve tried:
Device manager open with filemanager. Then select “Safely remove device” from Dolphin.
Command Line:mount /dev/sdf1 /mnt umount /dev/sdf1
(I tend to make use of the command line a bit more than the GUI).

Doesn’t matter what the procedure is.
The device stays in the /dev/ (and /dev/disk/by-label) directory when the power is removed.

Rich

On Sun, 27 Oct 2013 20:56:02 +0000, richardrosa wrote:

> The device stays in the /dev/ (and /dev/disk/by-label) directory when
> the power is removed.

When you remove power, run dmesg and see what messages are displayed.
That might provide a hint about what’s going on.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

Lotsa messages when the drive is connected. Nothing new when the plug is pulled.
Something important for notification is missing…

8755.205777] usb 9-1: USB disconnect, device number 8
8755.206803] sd 21:0:0:0: [sdf] Synchronizing SCSI cache
8755.206885] sd 21:0:0:0: [sdf]
8755.206889] Result: hostbyte=DID_NO_CONNECT driverbyte=DRIVER_OK
8755.506057] usb 9-1: new SuperSpeed USB device number 9 using xhci_hcd
8755.516969] usb 9-1: Parent hub missing LPM exit latency info. Power management will be impacted.
8755.517645] usb 9-1: New USB device found, idVendor=174c, idProduct=5136
8755.517651] usb 9-1: New USB device strings: Mfr=2, Product=3, SerialNumber=1
8755.517654] usb 9-1: Product: AS2105
8755.517656] usb 9-1: Manufacturer: ASMedia
8755.517658] usb 9-1: SerialNumber: 00000000000000000000
8755.518719] scsi22 : usb-storage 9-1:1.0
8756.521294] scsi 22:0:0:0: Direct-Access ASMT 2105 0 PQ: 0 ANSI: 6
8756.521740] sd 22:0:0:0: Attached scsi generic sg7 type 0
8758.312566] sd 22:0:0:0: [sdf] 1953525168 512-byte logical blocks: (1.00 TB/931 GiB)
8758.315332] sd 22:0:0:0: [sdf] Write Protect is off
8758.315341] sd 22:0:0:0: [sdf] Mode Sense: 43 00 00 00
8758.318066] sd 22:0:0:0: [sdf] Write cache: enabled, read cache: enabled, doesn’t support DPO or FUA
8758.347446] sdf: sdf1
8758.353652] sd 22:0:0:0: [sdf] Attached SCSI disk

Rich

On 2013-10-27 21:56, richardrosa wrote:

> I’ve tried:
> Device manager open with filemanager. Then select “Safely remove
> device” from Dolphin.
> Command Line:mount /dev/sdf1 /mnt umount /dev/sdf1
> (I tend to make use of the command line a bit more than the GUI).

An umount should not remove the device from /dev. using the eject
command on the browser might. I do not know what is the CLI equivalent.
As long as the usb stick is plugged in, the device should be there.

> Doesn’t matter what the procedure is.
> The device stays in the /dev/ (and /dev/disk/by-label) directory when
> the power is removed.

But the USB socket provides power, and the device might be using it, and
thus, the system would still detect a device present.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

On Sun, 27 Oct 2013 21:26:02 +0000, richardrosa wrote:

> Lotsa messages when the drive is connected. Nothing new when the plug is
> pulled.
> Something important for notification is missing…

The first message looks like the disconnection is detected. Have you got
another device that the device nodes are removed when you disconnect it
that you can compare to?

Also, I should have mentioned, please post output inside code tags - it’s
the “#” button on the advanced message editor. That generally helps with
readability for those using the web interface.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

On Sun, 27 Oct 2013 21:33:06 +0000, Carlos E. R. wrote:

> I do not know what is the CLI equivalent.

“eject”

:slight_smile:

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

On 2013-10-27 22:42, Jim Henderson wrote:
> On Sun, 27 Oct 2013 21:33:06 +0000, Carlos E. R. wrote:
>
>> I do not know what is the CLI equivalent.
>
> “eject”
>
> :slight_smile:

Let’s try. I didn’t thought it could be that one.


Telcontar:~ # eject /dev/sdf1
Telcontar:~ # l /dev/sdf*
brw-rw---- 1 root disk 8, 80 Oct 27 22:55 /dev/sdf
Telcontar:~ # mount | grep media
Telcontar:~ # mount | grep sdf
Telcontar:~ #

It disappears from the desktop, but the device remains.

Wait… sdf1 disappeared, but not sdf. Curious.

(“eject /dev/sdf” does the same).


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

On Sun, 27 Oct 2013 22:03:06 +0000, Carlos E. R. wrote:

> Let’s try. I didn’t thought it could be that one.

I’ve used it with flash drives in the past and it’s worked just fine.

I wouldn’t have suggested it if I hadn’t tried it and had success with it.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

On 2013-10-27 23:03, Carlos E. R. wrote:
> On 2013-10-27 22:42, Jim Henderson wrote:

> It disappears from the desktop, but the device remains.

I get this on the “eject” command:


> <0.6> 2013-10-27 23:20:45 Telcontar kernel - - - [61976.811186] sdf: detected capacity change from 15938355200 to 0

And this next line when I physically remove the stick.


> <0.6> 2013-10-27 23:20:54 Telcontar kernel - - - [61985.322914] usb 1-6: USB disconnect, device number 9


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

The “disconnect” message appears when the drive is re-powered. I’m assuming that somewhere some
code figured it had to disconnect the last connection before establishing a new one.

Some additional experimentation shows this to be a USB3 problem only.
Attaching and removing the same drive from a USB2 port performs as expected.
dmesg shows a USB disconnect when the cable is pulled. No such message shows up
for the USB3 port. Some important signal is not being acknowledged…

Since this system has more than one USB3 port, I’ve tried several of them, with the same results.
I’ve also played around with the few BIOS USB settings on the Motherboard, and none of them seem to change anything.

Rich

On Sun, 27 Oct 2013 22:46:02 +0000, richardrosa wrote:

> Some additional experimentation shows this to be a USB3 problem only.

That’s interesting. I’ve got a USB3 drive here (but it’s not connected
at the moment to my laptop, which has a USB3 port on it), but I wonder if
anyone else can reproduce that.

It could be you found a bug - in which case, you’ll want to report it
through bugzilla.novell.com. Login with the same credentials you use for
these forums.

To work around it with scripts you’ve got that depend on checking the
existence, you might instead look at /etc/mtab or parse the output of the
mount command to see if the drive is mounted. Not a perfect solution,
but it should prove to be reliable until the issue is addressed.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

So it is a USB 3.0 problem. You can upgrade your kernel after reading my blog.

openSUSE and Installing New Linux Kernel Versions - Blogs - openSUSE Forums

This might fix the USB 3.0 problem.

Thank You,

Thanx. I’ll give a kernel update a try (maybe tomorrow).

Thank you again for your assistance.

Rich

I followed your excellent instructions, and loaded the latest & greatest kernel (3.12.0-rc6-1.gdb1113e-debug), and
voila! USB3 hard drive goes away when unplugged!
Unfortunately, my video driver (nvidia) doesn’t work so well with this kernel,
so I guess I’ll have to wait for the fix to go mainstream…

As I indicated, this is NOT a major problem, just a minor annoyance.

Thanx again for your assistance…

Rich

So USB 3.0 is fixed. What kernel version did use? You can try 3.10 and 3.11 among others.

Thank You,