SG_MAPSection: SG3_UTILS (8)Updated: January 2001 |
SG_MAPSection: SG3_UTILS (8)Updated: January 2001 |
Sometimes it is difficult to determine which SCSI device a sg device name (e.g. /dev/sg0) refers to. This command loops through the sg devices and finds the corresponding SCSI disk, cdrom or tape device name (if any). Scanners are an example of SCSI devices that have no alternate SCSI device name apart from their sg device name.
If no options starting with "-s" are given then the mapping to all SCSI disk, cdrom and tape device names is shown.
If the device file system (devfs) is present a line noting this is output. The "native" devfs scsi hierarchy makes the relationship between a sg device name and any corresponding disk, cdrom or tape device name easy to establish. This replaces the need for this command. However many applications will continue to look for Linux SCSI device names in their traditional places. [Devfs supplies a compatibility daemon called devfsd whose default configuration adds back the Linux device names in their traditional positions.
Quite often the mapping information can be derived by observing the output of the command: "cat /proc/scsi/scsi". However if devices have been added since boot this can be deceptive.
My system has a SCSI disk, a cd writer and a dvd player:
$ sg_map
# Note: the devfs pseudo file system is present
/dev/sg0 /dev/sda
/dev/sg1 /dev/sr0
/dev/sg2 /dev/sr1
In order to find which sg device name corresponds to the disk:
$ sg_map -sd
# Note: the devfs pseudo file system is present
/dev/sg0 /dev/sda
/dev/sg1
/dev/sg2
The "-x" option gives the following output:
sg_map -x
# Note: the devfs pseudo file system is present
/dev/sg0 1 0 1 0 0 /dev/sda
/dev/sg1 2 0 4 0 5 /dev/sr0
/dev/sg2 2 0 6 0 5 /dev/sr1
When a SCSI scanner is added the output becomes:
$ sg_map
# Note: the devfs pseudo file system is present
/dev/sg0 /dev/sda
/dev/sg1 /dev/sr0
/dev/sg2 /dev/sr1
/dev/sg3
By process of elimination /dev/sg3 must be the scanner.