Tape drives are named /dev/st<num> or /dev/nst<num> where <num> starts at zero.
CD, DVD and BD readers (and writers) are named /dev/sr<num> where <num> start at zero.
There is also a SCSI device driver which offers alternate generic access to SCSI devices. It uses names of the form /dev/sg<num> where <num> starts at zero.
There’s also a block SCSI generic driver with names are of the form /dev/bsg/<h:c:t:l> where h, c, t and l are numbers.
Initiator and target
a SCSI initiator is the endpoint that initiates a SCSI session, that is, sends a SCSI command.
a SCSI target is the endpoint that does not initiate sessions, but instead waits for initiators’ commands and provides required input/output data transfers. The target usually provides to the initiators one or more LUNs, because otherwise no read or write command would be possible.
Logical unit number
LUN = logical unit number (disk, tape drive, whatever)
- ‘H’ is the host number
- ‘C’ is the controller number
- ”T’ is the target number
- ‘L’ is the Logical Unit Number (LUN)
lsscsi – list SCSI devices (or hosts) and their attributes
lsscsi lsscsi --classic lsscsi --hosts lsscsi -t --hosts
-g, –generic: Output the SCSI generic device file name. Note that if the sg driver is a module it may need to be loaded otherwise ‘-‘ may appear.
sg_map – displays mapping between Linux sg and other SCSI devices
$ sg_map /dev/sg0 /dev/sg1 /dev/sda /dev/sg2 /dev/nst0 /dev/sg3 /dev/nst1 /dev/sg4 /dev/sg5 /dev/sdb /dev/sg6 /dev/sg7 /dev/sdc /dev/sg8 /dev/sg9 /dev/sdd /dev/sg10 /dev/sg11 /dev/sde /dev/sg12 /dev/sg13 /dev/sdf /dev/sg14 /dev/sg15 /dev/sdg /dev/sg16 /dev/sg17 /dev/sdh /dev/sg18 /dev/sg19 /dev/sdi /dev/sg20
sg_reset – sends SCSI device, target, bus or host reset; or checks reset state
sg_reset --device /dev/sg5
sg_reset --host /dev/sg5
sg_logs – access log pages with SCSI LOG SENSE command
sg_logs -a /dev/tape/by-id/scsi-3500110a00169f43e-nst
Delete a LUN ( [11:0:2:1] ):
echo 1 > '/sys/class/scsi_host/host8/device/rport-8:0-10/target8:0:10/8:0:10:0/delete'
After removing a LUN (here my fiber card is host5):
echo "- - -" > /sys/class/scsi_host/host5/scan
If the size of a LUN changed:
echo 1 > /sys/block/sdX/device/rescan
Delete a block device:
echo 1 > /sys/block/sdaa/device/delete