Hi All, When a usb mass-storage is attached for the first time, it gets a device (/dev/sda). When it is mounted and the device is manually removed and then when it is attached again, it gets a different name ie /dev/sdb. This is because earlier the mass-storage device was removed (manually) when it was mounted, so scsi_disk_release() did not get called as the device (sda) had a reference count > 1. So, if my understanding is correct, I would like to know if the above mentioned behaviour is a bug or a limitation of the kernel? Regards, Ayan Kumar Halder
On Wed, Jul 09, 2014 at 12:13:28AM +0530, AYAN KUMAR HALDER wrote:
Hi All,
When a usb mass-storage is attached for the first time, it gets a device (/dev/sda).
When it is mounted and the device is manually removed and then when it is attached again, it gets a different name ie /dev/sdb.
Really? Not on my system, what kernel are you using?
This is because earlier the mass-storage device was removed (manually) when it was mounted, so scsi_disk_release() did not get called as the device (sda) had a reference count > 1.
It should have...
So, if my understanding is correct, I would like to know if the above mentioned behaviour is a bug or a limitation of the kernel?
What is wrong with the device node showing back up as /dev/sdb? You shouldn't be relying on a device node name for doing anything "real" anyway, that's what /dev/disk/ is there for, the persistent links are designed for you to mount with. thanks, greg k-h
On Tue, Jul 8, 2014 at 2:55 PM, Greg KH <greg@kroah.com> wrote:
On Wed, Jul 09, 2014 at 12:13:28AM +0530, AYAN KUMAR HALDER wrote:
Hi All,
When a usb mass-storage is attached for the first time, it gets a device (/dev/sda).
When it is mounted and the device is manually removed and then when it is attached again, it gets a different name ie /dev/sdb.
Really? Not on my system, what kernel are you using?
Greg, I just tried the experiment and had the above described behavior: - Connect external USB-3 drive, drive assigned /dev/sdb - mount -r /dev/sdb1 /mnt - pull the usb connector - wait 30 seconds, and reconnect - drive assigned /dev/sdc I'm running openSUSE with the distro kernel 3.11.6-4-desktop. I then added "umount /mnt" before pulling the usb connector and /dev/sdc was re-used on reconnect. <snip>
thanks,
greg k-h
the other greg
On Tue, Jul 08, 2014 at 06:17:56PM -0400, Greg Freemyer wrote:
On Tue, Jul 8, 2014 at 2:55 PM, Greg KH <greg@kroah.com> wrote:
On Wed, Jul 09, 2014 at 12:13:28AM +0530, AYAN KUMAR HALDER wrote:
Hi All,
When a usb mass-storage is attached for the first time, it gets a device (/dev/sda).
When it is mounted and the device is manually removed and then when it is attached again, it gets a different name ie /dev/sdb.
Really? Not on my system, what kernel are you using?
Greg, I just tried the experiment and had the above described behavior:
- Connect external USB-3 drive, drive assigned /dev/sdb - mount -r /dev/sdb1 /mnt - pull the usb connector - wait 30 seconds, and reconnect - drive assigned /dev/sdc
I'm running openSUSE with the distro kernel 3.11.6-4-desktop.
I then added "umount /mnt" before pulling the usb connector and /dev/sdc was re-used on reconnect.
If you use a "desktop automount system", you don't have to worry about this as you don't have to mount the filesystem, it will happen automagically at /var/run/media/ and then go away when the device is unplugged. But yes, you are right, if you explicitly mount the filesystem, the sd name will stay around, which is the correct kernel functionality. Same thing happens for lots of other types of dynamic devices (ttys, char devices, etc.) thanks, greg k-h
But yes, you are right, if you explicitly mount the filesystem, the sd name will stay around, which is the correct kernel functionality. Same thing happens for lots of other types of dynamic devices (ttys, char devices, etc.)
thanks,
greg k-h
Hi, Thanks for your response. The situation that I had described is analogous to what I have faced. I am trying to test the linux power management framework (for hibernation) on a ARM based custom SoC which has a usb host controller. I attach an external usb mass-storage device(hard disk), mount it (/dev/sda) and then hibernate the system. On resuming I see that the usb device gets detached, the controller re probes for the device, and the device gets re-attached as /dev/sdb. I see that in this situation too the scsi_disk_release do not get called because of the reference count. So I was wondering if it is expected behaviour of kernel or not. Regards, Ayan Kumar Halder
participants (3)
-
AYAN KUMAR HALDER -
Greg Freemyer -
Greg KH