# USB Mass Storage and scsi emulation

## Mankane

I can plug in my usb drive and I'm able to mount it from /dev/sda.

However, if I unplug the drive and later plug it back in, the device is now /dev/sdb.

Is there any way to prevent this from happening?

Thanks

CharlieLast edited by Mankane on Tue Oct 21, 2003 3:40 am; edited 1 time in total

----------

## Mankane

anyone?

----------

## MasquedAvenger

Did you perhaps issue the unmount command before removing it?

I suggest using supermount, a kernel option you can compile as a module or directly into the kernel, provided of course that your kernel is patched for it.  If you are using gentoo sources, it is, and if not, there is a website for the patch (sorry, I don't know where it is.)  Sorry I can't be of more help.

James

----------

## Mankane

 *MasquedAvenger wrote:*   

> Did you perhaps issue the unmount command before removing it?
> 
> I suggest using supermount, a kernel option you can compile as a module or directly into the kernel, provided of course that your kernel is patched for it.  If you are using gentoo sources, it is, and if not, there is a website for the patch (sorry, I don't know where it is.)  Sorry I can't be of more help.
> 
> James

 

Yes, I've always unmounted it.  Actually, it does the same if i plug in the drive, unplug it, and plug it right back in.  Does the same for my digital camera.

What I have noticed, however, is that this only happens with the 2.6 kernels.  With 2.4, my usb mass storage devices are always sda.

----------

## MasquedAvenger

huh.  That's interesting.  I haven't played with the 2.6 series yet, and probably won't for a while as I like the level of stability I'm at right now (I've been struggling for about a year now trying to get a stable Linux machine for normal desktop use, and I finally achieved it, at least for now, so I'm enjoying the ride while I can =P)  I'll probably setup a testbed machine and use that to play with the more experimental packages.  I'll remember this thread if I have problems with USB mass storage/scsi emulation.

James

----------

## rpodgorny

The same happens to me and it's really annoying... :-(

----------

## stonent

Did you eject the drive first?

umount /dev/sda(whatever)

eject /dev/sda

(now unplug the drive)

It doesn't actually "eject" the drive, but it does make it offline.

----------

## rpodgorny

 *stonent wrote:*   

> Did you eject the drive first?
> 
> umount /dev/sda(whatever)
> 
> eject /dev/sda
> ...

 

Thanks for the tip but it didn't help. The eject command succeeds (I used the --verbose flag) but the device files (sda and sda1) stay there even after unplugging the usb-stick. :-(

----------

## dub.wav

Try removing the usb-storage module after removing the device. (rmmod usb-storage)

----------

## rpodgorny

 *dub.wav wrote:*   

> Try removing the usb-storage module after removing the device. (rmmod usb-storage)

 

That works but is there any automatic way to do this? rmmod can be run only by root which is bad. I need to set up an entry in my fstab (say /dev/sda1) with "users" flag for the users to be able to bring their usb-sticks with them and mount them without problems. It's important to keep the device name from changing since the fstab way would be unsable then... :-(

Any tips?

----------

## MasquedAvenger

emerge hotplug  :Smile: 

James

----------

## rpodgorny

 *MasquedAvenger wrote:*   

> emerge hotplug :)
> 
> James

 

Tryied that too... :-) The truth is, I didn't have much time to do some deep configuration but just emerging and running it didn't make any difference. The modules were not unloaded either... :-(

----------

## Mankane

 *MasquedAvenger wrote:*   

> emerge hotplug 
> 
> James

 

I have hotplug emerged, but not configured for the jump drive.  The problem I see with hotplug, however, is that in the configuration file you specify the device that would get mounted.  This is a problem if the block device is always changing.

That said, I'm going to give it a shot and hope I'm wrong on the above statement.

----------

## tagswitch

Hi,

It is a known bug, seen in 2.6.0 series with USB keys/discs flash cards.

There seems to be some issues with either broken devices and/or the SCSI emulation layer

2.6.0-test8-mm1 seems to fix it, but has introduced some bugs with the framebuffer code and some ext3 oops. Rather wait to mm2 or use latest bk.

Regards,

R.

----------

## rpodgorny

 *tagswitch wrote:*   

> Hi,
> 
> It is a known bug, seen in 2.6.0 series with USB keys/discs flash cards.
> 
> There seems to be some issues with either broken devices and/or the SCSI emulation layer
> ...

 

Thanks for the info. I've tried to look up the kernl bugzilla bug found nothing... :-(

----------

## tagswitch

Well, It happens for some configs. I'm not sure but it depends on your kernel version, if using ACPI, etc... I'm having this problem myself, and I haven't been able to track it exactly

Some pointers:

http://www.google.fr/search?q=usb-storage+scsi+2.6.0+&ie=ISO-8859-1&hl=fr&btnG=Recherche+Google&meta=

http://lkml.org/lkml/2003/9/9/201

http://www.mail-archive.com/linux-usb-users@lists.sourceforge.net/msg07471.html

http://www.mail-archive.com/linux-usb-users@lists.sourceforge.net/msg07804.html

http://lists.insecure.org/lists/linux-kernel/2003/Sep/1487.html

http://sourceforge.net/mailarchive/forum.php?thread_id=3288464&forum_id=5395

try this patch

http://lkml.org/lkml/2003/9/9/248

----------

## Mankane

Ok, now using 2.6.0-test8 and all seems to be well.

----------

## Hall

 *MasquedAvenger wrote:*   

>  I suggest using supermount, a kernel option you can compile as a module or directly into the kernel, provided of course that your kernel is patched for it.  If you are using gentoo sources, it is...

  Is 'supermount' really patched into the gentoo kernel (gs-sources) ?? How can I verify that ?? Well, I suppose I could just try it, eh ??   :Razz: 

----------

## MasquedAvenger

Yes it is  :Smile: 

James

----------

## Mankane

Ok, well I'm able to plug in the device and manually mount and unmount it.

I've got hotplug configured to mount jump drive when i plug it in, however, upon removal i get a null pointer dereference.  If I explicitly unmount the drive, all is well.

The null pointer dereference is a known bug and I hope I can be hotplugging this baby soon.

Charlie

----------

