Ubuntu: What happens after the core selects mass-storage


When a usb mass-storage device is attached to the host, enumeration of the device happens and the process where an address is given to the device, getting the descriptors occurs, then the core checks for the class driver required and assigns the mass-storage driver. What happens after that? Where does the SCSI comes in picture?

Check the following dmesg output:

[23870.089465] usb 3-2: new high-speed USB device number 5 using xhci_hcd  [23870.158769] usb 3-2: New USB device found, idVendor=058f, idProduct=6387  [23870.158778] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3  [23870.158782] usb 3-2: Product: Mass Storage  [23870.158785] usb 3-2: Manufacturer: Generic  [23870.158788] usb 3-2: SerialNumber: EEA1EE5B  [23870.202363] usb-storage 3-2:1.0: USB Mass Storage device detected  [23870.202469] scsi6 : usb-storage 3-2:1.0  


Once usb-storage attaches the device to a given interface, the kernel also starts the SCSI emulation process if applicable, defining sg and sd names (like /dev/sdb that is most important for us).

To check which device corresponds to scsi6 install the sg3-utils package:

sudo apt-get install sg3-utils  

And type the following command:

sudo sg_scan  

You'll get an output similar to this one:

/dev/sg0: scsi0 channel=0 id=0 lun=0 [em]  /dev/sg1: scsi1 channel=0 id=0 lun=0 [em]  /dev/sg2: scsi6 channel=0 id=0 lun=0 [em]  

Here scsi6 is defined as /dev/sg2.


USB mass-storage devices can also use SCSI commands defined by various SCSI standards.

The SCSI command sets specify a protocol for transferring blocks of data and status and control information such as a device's capacity and readiness to exchange data. Devices with USB and other hardware interfaces can use the SCSI command sets.

I does not mean that usb-storage gives control to SCSI, Hard drives, flash drives, and other USB mass-storage devices support commands in the SCSI Primary Command (SPC) Set and SCSI Block Command (SBC) Set from www.t10.org (INCITS Technical Committee T10).


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »