Friday, 17 February 2017

Understanding the SCSI sg and sd driver in Linux

The sg driver allows users to send SCSI commands to SCSI aware devices - for example scan for disks. Once the scan has completed the SCSI disk drive (sd) can be initialised providing block level access to the media - typically only performing 'SCSI READ' and 'SCSI WRITE' commands.

In order to retrieve a list of SCSI devices we can use the 'lsscsi' command (I prefer this than the normal lsblk since it conveniently provides additional information such as the SCSI bus, channel and LUN numbers etc.)

lsscsi

[0:0:0:0]    disk    ATA      WDC WD1111111-111 1A01  /dev/sda
[1:0:0:0]    cd/dvd  HL-DT-ST DVD-RAM GHC0N    MA01  /dev/sr0
[4:0:0:0]    disk    Generic- Multi-Card       1.00  /dev/sdb

The sg driver is commonly used to interact with devices such as scanners and CD-ROM drives.

Interestingly you might have noticed that almost all disk types use the sd driver - but quite often these disks might be ATA or SATA drives. The SCSI driver is used to abstract the many different disk types - so in fact it is compatible with a whole host of different disk types.

0 comments:

Post a comment