Finding SCSI generic device names
Linux has a number of SCSI drivers, many devices are managed by their own driver as well as the sg
generic driver. Some tools need access to both devices provided by the specific driver (e.g. sr
for CD/DVD drives) and the generic one - requiring knowledge of which device files correspond to the same physical device to pass through to, e.g., Docker containers.
In order to find this mapping, first install the package providing lsscsi
. E.g. on Debian:
root@host# apt-get install lsscsi
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
lsscsi
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 49.7 kB of archives.
After this operation, 117 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 lsscsi amd64 0.30-0.1 [49.7 kB]
Fetched 49.7 kB in 0s (493 kB/s)
Selecting previously unselected package lsscsi.
(Reading database ... 84814 files and directories currently installed.)
Preparing to unpack .../lsscsi_0.30-0.1_amd64.deb ...
Unpacking lsscsi (0.30-0.1) ...
Setting up lsscsi (0.30-0.1) ...
Processing triggers for man-db (2.8.5-2) ...
To find the mapping, run lsscsi
with the -g
option, which will tell you the driver device and the generic device:
user@host$ lsscsi -g
[2:0:0:0] disk ATA Crucial_CT525MX3 R031 /dev/sda /dev/sg0
[3:0:0:0] cd/dvd HL-DT-ST BDDVDRW CH10LS20 1.02 /dev/sr0 /dev/sg1
[4:0:0:0] cd/dvd SONY DVD RW DRU-190S 1.63 /dev/sr1 /dev/sg2
[5:0:0:0] cd/dvd TSSTcorp DVD+-RW SN-208BB D300 /dev/sr2 /dev/sg3
[6:0:0:0] cd/dvd HL-DT-ST DVDRWBD CT10N A104 /dev/sr3 /dev/sg4