Tuesday, June 3, 2014

Querying SCSI devices

Sometimes we want to query about our devices present in our computer. e.g. Hard Disks , DVD drives etc.These devices comes into the family of SCSI (Small Computer Systems Interface) devices.So we can use some of the SCSI commands to query the status of the SCSI devices.I use linux system to demonstrate this.

First installation of sg3-utils package is required.You can get more information on sg3-utils package by clicking on below link:


So first step is to install sg3-utils package using command: sudo apt-get install sg3-utils

E.g. a-saurabh@a-saurabh:~$ sudo apt-get install sg3-utils

Now once the package is installed , we get access to numerous and helpful utilities which makes possible to send SCSI commands from terminal to SCSI devices.

Suppose I want to see serial number of my hard disk, I can issue the below command.

a-saurabh@a-saurabh:~$ sudo sg_inq -p 0x80 /dev/sda
VPD INQUIRY: Unit serial number page
  Unit serial number:      WD-WMC2E7086390

Basically we have send an SCSI INQUIRY command with page code 0x80 (Representing Unit Serial Number) to our hard disk node under /dev directory.

We can also list the supported pages by the SCSI device by sending the command:

a-saurabh@a-saurabh:~$ sudo sg_inq -p 0x00 /dev/sda
 Only hex output supported. sg_vpd decodes more pages.
VPD INQUIRY, page code=0x00:
   [PQual=0  Peripheral device type: disk]
   Supported VPD pages:
     0x0 Supported VPD pages
     0x80 Unit serial number
     0x83 Device identification
     0x89 ATA information
     0xb0 Block limits (sbc2)
     0xb1 Block device characteristics (sbc3)
     0xb2 Logical block provisioning (sbc3)

Here we query about the supported inquiry pages by the device.

We use -p option in the sg_inq command for specifying the page which is being queried,

Likewise we can request information for more inquiry pages from SCSI devices.

No comments:

Post a Comment