Devices naming

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 --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.

lsscsi -g

sg_map – displays mapping between Linux sg and other SCSI devices

$ sg_map
/dev/sg1  /dev/sda
/dev/sg2  /dev/nst0
/dev/sg3  /dev/nst1
/dev/sg5  /dev/sdb
/dev/sg7  /dev/sdc
/dev/sg9  /dev/sdd
/dev/sg11  /dev/sde
/dev/sg13  /dev/sdf
/dev/sg15  /dev/sdg
/dev/sg17  /dev/sdh
/dev/sg19  /dev/sdi

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

scsi_id – retrieve and generate a unique SCSI identifier

This thing is not in the PATH so you have to use the full path to it: /lib/udev/scsi_id

By default all devices are assumed black listed, the --whitelisted option must be specified on the command line or in the config file for any useful behavior.


How to get the WWID of a device

Local SATA drive:

$ sudo /lib/udev/scsi_id --whitelisted --device=/dev/sdb

Fiber attached drive (the end result includes the fiber controller information):

$ sudo /lib/udev/scsi_id --whitelisted --device=/dev/sdj



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