This utility scans for physical drives (a.k.a. "hard drives"), cd/dvd drives and tape drives and maps them to the corresponding volumes. There may be many, one or no corresponding volumes. There is one line output per device with identification strings to the right. Its purpose is to list the storage device names that can be used by other utilities in this package.
In later versions of Windows this utility may need to be "run as Administrator" for disks and other devices to be seen. If not those devices will simply not appear as calls to query them fail with access permission problems.
There is an optional SCSI adapter scan which may find additional storage devices other than the ones listed above. An example is a SCSI Enclosure Services (SES) device typically found in disk arrays.
Storage and related devices can have several device names in Windows. Probably the most common in the volume name (e.g. "D:"). There is also a "class" device name, and this utility scans for three of them: "PhysicalDrive<n>", "CDROM<n>" and "TAPE<n>". <n> is an integer starting at 0 allocated in ascending order as devices are discovered (and sometimes rediscovered).
Some storage devices have a SCSI lower level device name which starts with a SCSI (pseudo) adapter name of the form "SCSI<n>:". To this is added sub-addressing in the form of a "bus" number, a "target" identifier and a LUN (Logical Unit Number). The "bus" number is also known as a "PathId". These components are combined by the utility to make a device name of the form: "SCSI<n>:<bus>,<target>,<lun>". This utility allows the trailing ",<lun>" to be omitted in which case a LUN of zero is assumed. This lower level device name cannot often be used directly since Windows blocks attempts to use it if a class driver has "claimed" the device. There are SCSI device types (e.g. Automation/Drive interface type) for which there is no class driver. At least two transports ("bus types" in Windows jargin): USB and IEEE 1394 do not have a "scsi" device names of this form.
In keeping with DOS file system conventions, the various device names can be given in upper, lower or mixed case. Since "PhysicalDrive<n>" is tedious to write, a shortened form of "PD<n>" is permitted by all utilities in this package.
A single device (e.g. a disk) can have many device names! For example: "PDO" can also be "C:", "D:" and "SCSI0:0,1,0". The two volume names reflect that the disk has two partitions on it. Disk partitions that are not recognised by Windows are not usually given a volume name. However Vista does show a volume name for a disk which has no partitions recognised by it and when selected invites the user to format it (which is rather unfriendly to other OSes).
The scanning logic and output of this command changed significantly in sg3_utils version 1.27 . The SCSI adapter based scanned is now an optional extra.
For more information see the NOTES section below.
-b, --bus show the bus type (or transport) by which the device is attached to the operating systems. Two or more transports may be involved. For example, a SATA disk may be in the external enclosure connected to the computer via USB in which case the bus type is USB.
-h, --help outputs the usage message summarizing command line options then exits.
-l, --letter=VL normally a device that has multiple volume names has up to four listed. If there are more than that a "+" is added after the fourth. When this option is given the VL argument is assumed to be a volume name (i.e. 'C' to 'Z') and if found in the scan, only that volume name appears in the output. If there are novolume names in the output then VL was not found.
-s, --scsi do a SCSI adapter based scan after the normal storage device based scan. There is a blank line between the normal scan and the SCSI adapter based scan. If this option is given twice then only the SCSI adapter based scan is done.
-v, --verbose increases the level or verbosity. Can be used multiple times to display more of the internal data, both in normal and error processing.
-V, --version print out version string
When the --scsi option is given the SCSI adapter tuple is followed by a list of two or three fields. First is "claimed=0|1" indicating whether a class driver has claimed the device. The next field is "pdt=<num>" where <num> is the "peripheral device type" as defined in the SCSI INQUIRY command (see SPC-4 at https://www.t10.org). The <num> has a trailing "h" to indicate that it is hexadecimal. Sometimes a third field with the word "dubious" appears. This flags that what is supposed to be a SCSI INQUIRY command response has a badly formed "additional length" field. Thus the corresponding device is unlikely to be a native SCSI device.
The DOS device names given the the CreateFile() call all start with a "\\\\.\\" string. That can be given but if not will be supplied automatically.
Scanning devices that are hot unplugged and replugged often can be problematic, especially with the class device names. Each time a device is removed and re-added it gets a larger class device name (e.g. "PD3" becomes "PD4" leaving "PD3" unused). This utility stops scanning class devices after it find 8 consecutive "holes".
# sg_scan
PD0 [C] FUJITSU MHY2160BH 0000
PD1 [DF] WD 2500BEV External 1.05 WD-WXE90
CDROM0 [E] MATSHITA DVD/CDRW UJDA775 CB03
Now request bus types as well. BTW That is a SATA disk holding volume C: and there is a "Sata" bus type.
# sg_scan -b
PD0 [C] <Ata > FUJITSU MHY2160BH 0000
PD1 [DF] <Usb > WD 2500BEV External 1.05 WD-WXE90
CDROM0 [E] <Atapi> MATSHITA DVD/CDRW UJDA775 CB03
Now request a SCSI adapter scan as well.
# sg_scan -b -s
PD0 [C] <Ata > FUJITSU MHY2160BH 0000
PD1 [DF] <Usb > WD 2500BEV External 1.05 WD-WXE90
CDROM0 [E] <Atapi> MATSHITA DVD/CDRW UJDA775 CB03
SCSI0:0,0,0 claimed=1 pdt=0h FUJITSU MHY2160BH 0000
SCSI1:0,0,0 claimed=1 pdt=5h MATSHITA DVD/CDRW UJDA775 CB03
This software is distributed under a FreeBSD license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.