LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (http://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   "Turning off" USB memory stick before unplugging/disconnecting (http://www.linuxquestions.org/questions/linux-hardware-18/turning-off-usb-memory-stick-before-unplugging-disconnecting-191901/)

detly 06-10-2004 08:30 AM

"Turning off" USB memory stick before unplugging/disconnecting
 
Dist: RedHat 9; Kernel 2.4.20-8

After a few initial problems, I can now mount and use my Transcend Jetflash USB memory stick under Linux. My problem now, however, lies in disconnecting it. Unmounting goes fine, and causes no errors or problems. On other systems, though (Windows 98+, Mac OS9-X), after the drive has been unmounted (or whatever they call it) the little red LED goes off to indicate that it's no longer in use. Under Linux, though, this doesn't happen.

If I simply unplug it (after unmounting it), I get the following message:

Code:

sda : READ CAPACITY failed.
sda : status = 1, message = 00, host = 0, driver = 08
Info fld=0xa00 (nonstd), Current sd00:00: sense key Not Ready
sda : block size assumed to be 512 bytes, disk size 1GB.
 I/O error: dev 08:00, sector 0
 unable to read partition table

The latest from dmesg is:

Code:

usb.c: USB disconnect on device 00:04.2-2 address 2
Device not ready.  Make sure there is a disc in the drive.
sda : READ CAPACITY etc, as above

From /var/log/messages:

Code:

Jun 10 20:31:15 localhost kernel: usb.c: USB disconnect on device 00:04.2-2 address 2
Jun 10 20:31:16 localhost kernel: Device not ready.  Make sure there is a disc in the drive.
Jun 10 20:31:16 localhost kernel: sda : READ CAPACITY failed.
Jun 10 20:31:16 localhost kernel: sda : status = 1, message = 00, host = 0, driver = 08
Jun 10 20:31:16 localhost kernel: Info fld=0xa00 (nonstd), Current sd00:00: sense key Not Ready
Jun 10 20:31:16 localhost kernel: sda : block size assumed to be 512 bytes, disk size 1GB. 
Jun 10 20:31:16 localhost kernel:  sda: I/O error: dev 08:00, sector 0
Jun 10 20:31:16 localhost kernel:  I/O error: dev 08:00, sector 0
Jun 10 20:31:16 localhost kernel:  unable to read partition table
Jun 10 20:31:16 localhost devlabel: devlabel service started/restarted

I have discovered, by chance, that if I do:
modprobe -r usb-uhci
then the light goes off and I don't get any errors. This doesn't really strike me as a good solution since I can't do this as a non-root user (apart from which it seems like a bit of a hack).

Now despite all of this, there are no errors or problems with the memory stick afterwards. But I'm sure there's a standard way of doing such a thing. :)

b0uncer 06-10-2004 09:15 AM

modprobe -r usb-uhci

removes the usb-uhci module from your kernel. I don't think this is needed....simply umounting the stick should do, because that's what you do with floppies too - mount it, use it, umount it, and take it off. the led burning indicates, I think, that the system knows about the stick and the stick knows it's plugged to something...I think that when you plug it in in windows, it gets "mounted" automatically - when you choose to take the device off, it gets "umounted" and at the same time windows system just thinks there is no device in the usb anymore. these are my thoughts only, but as far as I know, it's no harm to plug it out after umounting even if you get errors...

the errors occur, I think, because the kernel module doesn't know when you're going to remove the stick and just tells you that you have done so and it didn't know of it beforehand (or something like this...hey, it doesn't say 'you did this one wrong' or anything :) heh)

modprobe -r:ing the usb-uhci removes the kernel module so after that your kernel doesn't know about your stick (or actually, it can't handle it because it doesn't know what to do without the module) - but it doesn't mean that you have to do it. I've used my stick happily by mounting and umounting it, and haven't cared about the errors. and everything has worked. I took the burning led as a signal that everything is ok and the stick is recognized...

detly 06-11-2004 12:14 AM

Well, seeing as there aren't any real problems caused, I'm probably just being paranoid...

Thank you :)

axlmad 03-15-2005 12:34 PM

Turn off led!
 
As USB sticks are seen by the OS as SCSI drives you may try this command:
eject -s <stick device or stick mount point>
This worked for me to turn off the led of a 256 Mb Transcend JetFlash, on Fedora Core 2, kernel 2.6.8, but yet I had other problems that I wanted to
solve regarding mounting/unmounting the stick (more precisely after an unmount/eject operation the system couldn't detect the stick anymore). In the mean time I updated to kernel 2.6.10 and things are better, yet I donno the effect of eject on the uhci module neither I tested that command again. What I'm trying to tell you is 'use it with caution and at your own risk'!


All times are GMT -5. The time now is 04:28 AM.