Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

lsscsi command

News Linux SCSI subsystem

Recommended Books

Recommended Links

Reference

Man Page

        Humor Etc

The lsscsi command scans the sysfs pseudo file system that was introduced in the 2.6 Linux kernel series. Since most users have permissions to read sysfs (usually mounted at /sys  ) then meta information can be found on some or all SCSI devices without a user needing elevated permissions to access special files (e.g. /dev/sda ).

The lsscsi command accesses the sysfs file system (usually mounted under /sys ) to obtain information rather than opening the SCSI device nodes (e.g. /dev/sda ) in the system. Reading information within the sysfs file system is usually available to all users (as is the information in procfs). However the permissions on SCSI device nodes are necessarily tight which precludes normal users from directly interrogating these devices. The lsscsi command  typically is available to all users.

When executed without any options lsscsi outputs one line for each SCSI device attached to the system:
$ lsscsi
[0:0:8:0]    disk    FUJITSU  MAM3184MP        0105  /dev/sda
[2:0:0:0]    cd      CREATIVE CD5233E          1.00  /dev/sr0
[3:0:5:0]    tape    HP       C5713A           H910  /dev/st0
[3:0:5:1]    mediumx HP       C5713A           H910  -
[4:0:0:0]    disk    Linux    scsi_debug       0004  /dev/sdb


The first entry on each line is the scsi_host,channel,target_id,lun tuple. It is placed in brackets and each element is colon separated. When there are multiple SCSI devices their entries are sorted in ascending tuple order. The next column is the SCSI peripheral type; rather than the formal name (e.g. "direct access device") a shorter name is used. Then follows the vendor name, the model name and the revision string. The last entry is the device file node name. This assumes that the naming of files in the /dev directory follows Linux conventions (if in doubt use the '-d' option to see the device node's major and minor numbers). Note that some distributions favour the "/dev/scd0" over the older "/dev/sr0" form for CD/DVD devices. Also note that the tape medium exchanger does not have a primary device name and thus can only be accessed via its corresponding scsi generic (sg) device name.

Here is a "long" variant of this command:
$ lscssi -l
[0:0:1:0]    disk    FUJITSU  MAM3184MP        0105  /dev/sda
  state=running queue_depth=16 scsi_level=4 type=0 device_blocked=0 timeout=30


The device node major and minor numbers can also be output with the '-d' option:
$ lsscsi -d
[0:0:1:0]    disk    FUJITSU  MAM3184MP        0105  /dev/sda[8:0]


The '-g' option can be used to show the corresponding scsi generic device name:
$ lsscsi -g
[0:0:1:0]    disk    FUJITSU  MAM3184MP        0105  /dev/sda  /dev/sg0


In "classic" mode lsscsi outputs a listing very similar to 'cat /proc/scsi/scsi'. This form of output should be familiar:
$ lsscsi -c
Attached devices:

Host: scsi0 Channel: 00 Id: 08 Lun: 00
  Vendor: FUJITSU  Model: MAM3184MP        Rev: 0105
  Type:   Direct-Access                    ANSI SCSI revision: 03
Host: scsi2 Channel: 00 Id: 00 Lun: 00
  Vendor: CREATIVE Model: CD5233E          Rev: 1.00
  Type:   CD-ROM                           ANSI SCSI revision: 02
Host: scsi3 Channel: 00 Id: 06 Lun: 00
  Vendor: SONY     Model: SDT-7000         Rev: 0192
  Type:   Sequential-Access                ANSI SCSI revision: 02
Host: scsi4 Channel: 00 Id: 00 Lun: 00
  Vendor: Linux    Model: scsi_debug       Rev: 0004
  Type:   Direct-Access                    ANSI SCSI revision: 03


SCSI host information can be listed with the '-H' option:
$ lsscsi -H
[0]    scsi_debug
[1]    aha152x

$ lsscsi -Hl
[0]    scsi_debug
  cmd_per_lun=3    host_busy=0    sg_tablesize=64   unchecked_isa_dma=0
[1]    aha152x
  cmd_per_lun=1    host_busy=0    sg_tablesize=255  unchecked_isa_dma=0

$ lsscsi -Hlv
[0]    scsi_debug
  cmd_per_lun=3    host_busy=0    sg_tablesize=64   unchecked_isa_dma=0
  dir: /sys/class/scsi_host/host0
  device dir: /sys/devices/pseudo_0/adapter0/host0
[1]    aha152x
  cmd_per_lun=1    host_busy=0    sg_tablesize=255  unchecked_isa_dma=0
  dir: /sys/class/scsi_host/host1
  device dir: /sys/devices/platform/host1

See "man lsscsi" for more information. The command also contains usage information that can be output by using "lsscsi -h" or "lsscsi --help".
 

Options

-c, --classic
The output is similar to that obtained from 'cat /proc/scsi/scsi'
-d, --device
After outputting the (probable) scsi device name the device node major and minor numbers are shown in brackets (e.g. "/dev/sda[8:0]").
-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.
-h, --help
Output the usage message and exit.
-H, --hosts
List the SCSI hosts currently attached to the system. If this option is not given then SCSI devices are listed.
-k, --kname
Use linux default algorithm for naming devices (e.g. block major 8, minor 0 is "/dev/sda") rather than the "match by major and minor" in the "/dev" directory as discussed above.
-L, --list
Output additional information in <attribute_name>=<value> pairs, one pair per line preceded by two spaces. This option has the same effect as '-lll'
-l, --long
Output additional information for each SCSI device (host). Can be used multiple times for more output in which case the shorter option form is more convenient (e.g. '-lll'). When used three times (i.e. '-lll') outputs SCSI device (host) attributes one per line; preceded by two spaces; in the form "<attribute_name>=<value>".
-p, --protection
Output additional data integrity (protection) information.
-t, --transport
Output transport information. This will be a target related information or, if --hosts is given, initiator related information. When used without --list, a name or identifier (or both) are output on a single line, usually prefixed by the type of transport. For devices this information replaces the normal vendor, product and revision strings. When the --list option is also given then additionally multiple lines of attribute_name=value pairs are ouput, each indented by two spaces. See the section on transports below.
-v, --verbose
outputs directory names where information is found. Use multiple times for more output.
-V, --version
outputs version information then exits.
-y, --sysfsroot=PATH
assumes sysfs is mounted at PATH instead of the default '/sys' . If this option is given PATH should be an absolute path (i.e. start with '/').


Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

[Sep 19, 2011] lsscsi utility for Linux

This is the page of the author, so it is the most authoritative.

The lsscsi command lists information about SCSI devices in Linux. Using SCSI terminology, lsscsi lists SCSI logical units (or SCSI targets when the '--transport' option is given). The default action is to produce one line of output for each SCSI device currently attached to the system.

When the '--hosts' option is given the lsscsi command lists information about SCSI hosts attached to the system. A host can be actual hardware (sometimes referred to as Host Bus Adapters (HBAs)) or virtual. An example of a virtual host is USB mass storage that bridges between USB and the SCSI subsystem. In SCSI parlance, a host is referred to as an SCSI initiator.

The lsscsi command scans the sysfs pseudo file system that was introduced in the 2.6 Linux kernel series. Since most users have permissions to read sysfs (usually mounted at /sys ) then meta information can be found on some or all SCSI devices without a user needing elevated permissions to access special files (e.g. /dev/sda ). The lsscsi command can also show the relationship between a device's primary node name, its SCSI generic (sg) node name and its kernel name.

Overview

When executed without any options lsscsi outputs one line for each SCSI device attached to the system:
$ lsscsi
[0:0:8:0] disk FUJITSU MAM3184MP 0105 /dev/sda
[2:0:0:0] cd CREATIVE CD5233E 1.00 /dev/scd0
[3:0:5:0] tape HP C5713A H910 /dev/st0
[3:0:5:1] mediumx HP C5713A H910 -
[4:0:0:0] disk Linux scsi_debug 0004 /dev/sdb

The first entry on each line is the scsi_host,channel,target_number,lun tuple. It is placed in brackets and each element is colon separated. When there are multiple SCSI devices their entries are sorted in ascending tuple order. The next column is the SCSI peripheral type; rather than using the formal name (e.g. "direct access device") a shorter name is used. Then follows the vendor name, the model name and the revision string. The last entry is the primary device node name. The "primary" device node name is associated with the upper level SCSI driver that "owns" the device. Examples of upper level SCSI drivers are sd (for disks), sr (for optical drives whose devices are often named /dev/scd<n> ) and st (for tapes). Some SCSI devices have peripheral types that either don't have upper level drivers to control them, or the associated driver module is not loaded. Such devices have '-' given for their device node name. All SCSI devices can be accessed via their corresponding scsi generic (sg) device node name (e.g. /dev/sg<n> ) which can be seen by adding a '--generic' option to the above lsscsi invocation.

By adding the '--size' option ('-s' in its short form) the size of disks is shown to the right of each line:
# lsscsi -s
[0:0:0:0] cd/dvd PIONEER DVD-RW DVR-212D 1.22 /dev/sr0 -
[1:0:0:0] disk ATA ST3320620AS 3.AA /dev/sda 320GB
[6:0:0:0] disk SEAGATE ST32000444SS 0006 /dev/sdb 2.00TB

If the device is not a disk or its size is not available than '-' is output instead of a size.

Here is a "long" variant of this command. The '-l' (or '--long') option can be used multiple time for more output.

lscssi -l
[0:0:1:0] disk FUJITSU MAM3184MP 0105 /dev/sda
state=running queue_depth=16 scsi_level=4 type=0 device_blocked=0 timeout=30

The device node major and minor numbers can also be output with the '-d' option:

$ lsscsi -d

[0:0:1:0] disk FUJITSU MAM3184MP 0105 /dev/sda[8:0]

The '-g' (or '--generic') option can be used to show the corresponding scsi generic device name:
$ lsscsi -g

[0:0:1:0] disk FUJITSU MAM3184MP 0105 /dev/sda /dev/sg0

In "classic" mode lsscsi outputs a listing very similar to 'cat /proc/scsi/scsi'. This form of output should be familiar:
$ lsscsi -c

Attached devices:
Host: scsi0 Channel: 00 Id: 08 Lun: 00
Vendor: FUJITSU Model: MAM3184MP Rev: 0105
Type: Direct-Access ANSI SCSI revision: 03
Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: CREATIVE Model: CD5233E Rev: 1.00
Type: CD-ROM ANSI SCSI revision: 02
Host: scsi3 Channel: 00 Id: 06 Lun: 00
Vendor: SONY Model: SDT-7000 Rev: 0192
Type: Sequential-Access ANSI SCSI revision: 02
Host: scsi4 Channel: 00 Id: 00 Lun: 00
Vendor: Linux Model: scsi_debug Rev: 0004
Type: Direct-Access ANSI SCSI revision: 03

SCSI host information can be listed with the '-H' option:
$ lsscsi -H
[0] scsi_debug
[1] aha152x

$ lsscsi -Hl
[0] scsi_debug
cmd_per_lun=3 host_busy=0 sg_tablesize=64 unchecked_isa_dma=0
[1] aha152x
cmd_per_lun=1 host_busy=0 sg_tablesize=255 unchecked_isa_dma=0

$ lsscsi -Hlv
[0] scsi_debug
cmd_per_lun=3 host_busy=0 sg_tablesize=64 unchecked_isa_dma=0
dir: /sys/class/scsi_host/host0
device dir: /sys/devices/pseudo_0/adapter0/host0
[1] aha152x
cmd_per_lun=1 host_busy=0 sg_tablesize=255 unchecked_isa_dma=0
dir: /sys/class/scsi_host/host1
device dir: /sys/devices/platform/host1

For transport information see the section of that name below. Online there is a "man" page (invoked by 'man lsscsi') which contains information specific to the version of lsscsi installed on a machine. The command also contains usage information that can be output by using "lsscsi -h" or "lsscsi --help".

Currently bsg device node names are not shown by lsscsi but are quite simple to construct from the information provided. bsg node names start with '/dev/bsg/' followed by a scsi_host,channel,target_number,lun tuple. For example for this device:
[4:0:0:0] disk Linux scsi_debug 0004 /dev/sdb
the bsg node name is '/dev/bsg/4:0:0:0'. Note that the shell may interpret ":" as a special character in certain contexts so it may need to be escaped.


Transports

When the '--transport' (or '-t') option is given lsscsi attempts to determine the transport being used and outputs information specific to that transport. In the case of modern transports that may include a world wide unique name or identifier. The transports for which extra information is provided are: Even though lsscsi, in the absence of the '--hosts' option, shows logical unit information, once the '--transport' option is specified the output relates to the target which contains the logical unit. This occurs since the computer (and thus sysfs) see a "transport" (or interconnect) whose near end is a host (i.e. a SCSI initiator) and whose far end is a target. A target may contain one or more logical units (and in special cases a target may contain no logical units). SCSI initiators and targets can also have one or more ports. Linux tends to show each port of a target (that contains one logical unit) as two devices; to be more precise, Linux shows a different device for each distinct path to a logical unit.

When the '--transport' option is given the SCSI INQUIRY strings (vendor, product and revision) usually output by lsscsi are replaced by a target name or identifier. Annex A in the SAM-4 document has been used as a guide for the appropriate initiator (i.e. host) and target names and identifiers to display.

ATA

The detection of parallel ATA devices is somewhat crude and is performed after checks are made for more traditional SCSI transports. The identification of an ATA transport is made on the basis of the low level driver name that the device or host uses. A similar mechanism is used to detect SATA devices and there is some overlap since some drivers support both SATA and PATA devices. No other attributes are provided. For example:
$ lsscsi
[0:0:0:0] disk ATA FUJITSU MHY2160B 0000 /dev/sda
[3:0:0:0] cd/dvd MATSHITA DVD/CDRW UJDA775 CB03 /dev/scd0
[5:0:0:0] disk USB 2.0 SD/MMC Reader /dev/sdb
[6:0:0:0] disk JetFlash TS2GJFVxx 8.01 /dev/sdc
$ lsscsi -t
[0:0:0:0] disk sata: /dev/sda
[3:0:0:0] cd/dvd ata: /dev/scd0
[5:0:0:0] disk usb: 7-1:1.0 /dev/sdb
[6:0:0:0] disk usb: 7-2.4:1.0 /dev/sdc
$ lsscsi -Ht
[0] ahci sata:
[1] ahci sata:
[2] ahci sata:
[3] ata_piix ata:
[4] ata_piix ata:
[5] usb-storage usb: 7-1:1.0
[6] usb-storage usb: 7-2.4:1.0

In this case the device at 3:0:0:0 (and device node /dev/scd0) is a DVD/CD drive whose transport is (parallel) ATA. That device is attached to host3 which is associated with the ata_piix driver.

FC

For FC devices (logical units), the '--transport' option will show the port name and the port identifier instead of the SCSI INQUIRY "strings". For example:
$ lsscsi -g
[3:0:0:0] enclosu HP A6255A HP04 - /dev/sg3
[3:0:1:0] disk HP 36.4G ST336753FC HP00 /dev/sdd /dev/sg4
[3:0:2:0] disk HP 36.4G ST336753FC HP00 /dev/sde /dev/sg5

$ lsscsi -g --transport
[3:0:0:0] enclosu fc:0x50060b00002e48a3,0x0b109b - /dev/sg3
[3:0:1:0] disk fc:0x21000004cf97de68,0x0b109f /dev/sdd /dev/sg4
[3:0:2:0] disk fc:0x21000004cf97e385,0x0b10a3 /dev/sde /dev/sg5

Notice that the port name for the enclosure is naa-5 while the port names for the disks are naa-2. Since SAS also uses naa-5 the leading "fc:" indicates that the transport has been identified as FC. When '--list' is added, more transport information is provided in "name=value" pairs, indented by two or more spaces. The output is restricted to one disk by added the 3:0:2:0 filter:
$ lsscsi -t --list [3:0:2:0]
[3:0:2:0] disk fc:0x21000004cf97e385,0x0b10a3 /dev/sde
transport=fc
node_name=0x20000004cf97e385
port_name=0x21000004cf97e385
port_id=0x0b10a3
port_state=Online
roles=FCP Target
scsi_target_id=2
supported_classes=Class 3
dev_loss_tmo=35

When the '--hosts' option is used with '--transport' then transport information for the initiator (port) is output:
$ lsscsi --hosts --transport 3
[3] qla2xxx fc:0x50060b00741cc28e,0x0b1900

This shows for host 3 the driver is called qla2xxx, the transport is FC, the initiator's port name is in naa-5 format with the final (hex) number being the initiator's port identifier. Adding '--list' will again add "name=value" pairs:
$ lsscsi -H -t --list 3
[3] qla2xxx fc:0x50060b00741cc28e,0x0b1900
transport=fc
node_name=0x50060b00741cc28f
port_name=0x50060b00741cc28e
port_id=0x0b1900
port_type=NPort (fabric via point-to-point)
speed=2 Gbit
supported_classes=Class 3
tgtid_bind_type=wwpn (World Wide Port Name)

The "name=value" pairs are fetched from a sysfs directory (apart from "transport=fc") so the meaning should be what is defined by the transport. Too see which directory (or directories) provide this information add '-vvv'.

1394

There are two versions of the SBP SCSI standard known as SBP-2 and SBP-3 for conveying SCSI command sets over a IEEE 1394 transport. The SCSI commands sets are typically for accessing storage devices. Hence the acronym "SBP" is often associated with the IEEE 1394 transport in the storage context.

SBP defines world wide unique names for a target and initiator (host) using EUI-64 format. These names are what the lsscsi command fetches when the '-t' option is given:
$ lsscsi
[6:0:1:0] sim dsk QUANTUM FIREBALL SE3.2A /dev/sdk

$ lsscsi -t
[6:0:1:0] sim dsk sbp:00043b000000071d:1:0 /dev/sdk

$ lsscsi -t -L
[6:0:1:0] sim dsk sbp:00043b000000071d:1:0 /dev/sdk
transport=sbp
ieee1394_id=00043b000000071d:1:0

$ lsscsi -t -H
[6] sbp2 sbp:005042b500004a48

$ lsscsi -t -H -L
[6] sbp2 sbp:005042b500004a48
transport=sbp

The SBP standard requires that disks (typically ATA disks in an external enclosure) use the SCSI peripheral device type: "simplified direct access device". The is abbreviated by the lsscsi command to "sim dsk".

iSCSI

The lsscsi command won't show anything iSCSI related on a machine with a iSCSI target running (either as a kernel driver or as a user space daemon). The following output is from a machine running a iSCSI initiator with a session established:
$ lsscsi
[2:0:0:0] disk IET VIRTUAL-DISK 0 /dev/sda

$ lsscsi -t
[2:0:0:0] disk iqn.2001-04.com.example:sda.sdb.sdc,t,0x1 /dev/sda

$ lsscsi -t -L
[2:0:0:0] disk iqn.2001-04.com.example:sda.sdb.sdc,t,0x1 /dev/sda
transport=iSCSI
targetname=iqn.2001-04.com.example:sda.sdb.sdc
tpgt=1
data_pdu_in_order=1
data_seq_in_order=1
erl=0
first_burst_len=65536
initial_r2t=1
max_burst_len=262144
max_outstanding_r2t=1
recovery_tmo=120

$ lsscsi -t -H
[2] iscsi_tcp iscsi:

$ lsscsi -t -H -L
[2] iscsi_tcp iscsi:
transport=iSCSI

As can be seen, there is no useful host information (e.g. the iSCSI initiator name) when the '-H' option (or the '--hosts' option) is given. The information given for the target is session related. An iSCSI session is made up of 1 or more connections which have available information in sysfs but the lsscsi command doesn't output them currently.

SAS

For SAS devices (logical units), the '--transport' option will show the target's SAS (port) address instead of the SCSI INQUIRY "strings". For example:
$ lsscsi -t
[4:0:3:0] disk sas:0x5000d50001b02139 /dev/sdd
[4:0:4:0] disk sas:0x5000d500005208ed /dev/sde
[5:0:0:0] disk sas:5000d50001b02139 /dev/sdf
[5:0:1:0] disk sas:5000d500005208ed /dev/sdg

The SAS address is prefixed by "sas:" to identify the transport. The are currently two different representations and lsscsi prints out whatever is in the relevant sysfs attribute. When a '--list' (or '-L) option is added more information is output:
$ lsscsi -t -L [4:0:4:0]
[4:0:4:0] disk sas:0x5000d500005208ed /dev/sde
transport=sas
initiator_port_protocols=none
initiator_response_timeout=10000
I_T_nexus_loss_timeout=1744
phy_identifier=11
ready_led_meaning=1
sas_address=0x5000d500005208ed
target_port_protocols=ssp

# lsscsi -t -L [5:0:1:0]
[5:0:1:0] disk sas:5000d500005208ed /dev/sdg
transport=sas
sub_transport=sas_class
device_name=0000000000000000
dev_type=end device
iproto=
iresp_timeout=0x2710
itnl_timeout=0x07d0
linkrate=3,0 Gbps
max_linkrate=3,0 Gbps
max_pathways=1
min_linkrate=3,0 Gbps
pathways=1
ready_led_meaning=1
rl_wlun=0
sas_addr=5000d500005208ed
tproto=SSP
transport_layer_retries=0

Both 4:0:4:0 and 5:0:1:0 are the same logical unit accessed via the same target port but from different hosts. The two drivers (one for each host) choose to represent the same (target port) information in different ways.

When the '--hosts' option is added, then the SAS address of the initiator is output. In the case of SAS a Linux host corresponds to a initiator device (not one of its ports):
$ ./lsscsi -t -H
[0] sata_nv
[1] sata_nv
[2] sata_nv
[3] sata_nv
[4] mptsas sas:0x500605b000f6f260
[5] aic94xx sas:50000d100f2dc000

Adding a '--list' option will print multiple 'name=value' pair lines, each indented with two or more spaces.

SATA

The detection of serial ATA (SATA) devices is somewhat crude and is performed after checks are made for more traditional SCSI transports. The identification of an SATA transport is made on the basis of the low level driver name that the device or host uses. A similar mechanism is used to detect parallel ATA devices and there is some overlap since some drivers support both SATA and PATA devices. No other attributes are provided. See the example in the ATA section, specifically device 0:0:0:0 and the associated host0.

SPI

The SCSI parallel interface (SPI) can be detected (as indicated by the "spi:" prefix) but sysfs provides no world wide unique names (there may be some in the device identification VPD page). The only thing that is available in sysfs is the target identifier which is usually a number between 0 and 15 inclusive. The initiator (host) identifier is not provided by by convention it is usually 7. Following are some examples of target and host transport information for SPI:
$ lsscsi [0:0:1:0]
[0:0:1:0] disk HP 36.4G ST336753LC HPC7 /dev/sdb

$ lsscsi -t [0:0:1:0]
[0:0:1:0] disk spi:1 /dev/sdb

$ lsscsi -t -L [0:0:1:0]
[0:0:1:0] disk spi:1 /dev/sdb
transport=spi
target_id=1
dt=1
max_offset=127
max_width=1
min_period=6.25
offset=63
period=6.25
width=1

$ lsscsi -t -H [0:0:1:0]
[0] mptspi spi:

$ lsscsi -t -H -L [0:0:1:0]
[0] mptspi spi:
transport=spi
signalling=unknown

USB

When a USB transport is detected the device or host summary line will contain "usb:" followed by a USB device name. The USB device name has the form "<b>-<p1>[.<p2>]+:<c>.<i>" where <b> is the USB bus number, <p1> is the port on the host. <p2> is a port on a host connected hub, if present. If needed <p3> is another USB hub port closer to the USB storage device. <c> refers to the configuration number while <i> is the interface number. There is a separate USB SCSI host for each USB (SCSI) target. A USB SCSI target may contain multiple logical units. Thus the same "usb: <device_name>" string appears for a USB SCSI host and all logical units that belong to the USB SCSI target associated with that USB SCSI host. See the example in the ATA section, specifically devices 5:0:0:0 and 6:0:0:0 . 5:0:0:0 is connected directly to a laptop while 6:0:0:0 is connected via an external hub.

Examples

Here is the output from a not so typical machine. It has a directly attached SATA DVD drive and one SATA disk (/dev/sda). The remaining devices are attached via an external SAS expander which has its own SES management device [6:0:2:0] :

# lsscsi
[0:0:0:0] cd/dvd PIONEER DVD-RW DVR-212D 1.22 /dev/sr0
[1:0:0:0] disk ATA ST3320620AS 3.AA /dev/sda
[6:0:0:0] disk SEAGATE ST32000444SS 0006 /dev/sdb
[6:0:1:0] disk ATA ST3500418AS CC34 /dev/sdc
[6:0:2:0] enclosu Intel RES2SV240 0600 -
[6:0:3:0] disk SEAGATE ST373455SS 2189 /dev/sdd

Now let's look at the sizes of the disks using the '--size' or '-s' option. The size of a DVD disk, even if there is one in the drive and it is mounted, is not shown. And there is no size associated with the enclosure (SES) device:

# lsscsi -s
[0:0:0:0] cd/dvd PIONEER DVD-RW DVR-212D 1.22 /dev/sr0 -
[1:0:0:0] disk ATA ST3320620AS 3.AA /dev/sda 320GB
[6:0:0:0] disk SEAGATE ST32000444SS 0006 /dev/sdb 2.00TB
[6:0:1:0] disk ATA ST3500418AS CC34 /dev/sdc 500GB
[6:0:2:0] enclosu Intel RES2SV240 0600 - -
[6:0:3:0] disk SEAGATE ST373455SS 2189 /dev/sdd 73.4GB

So how to access that enclosure (SES) device? Use the '--generic' or '-g' option to see the corresponding SCSI generic device names:

# lsscsi -g
[0:0:0:0] cd/dvd PIONEER DVD-RW DVR-212D 1.22 /dev/sr0 /dev/sg0
[1:0:0:0] disk ATA ST3320620AS 3.AA /dev/sda /dev/sg1
[6:0:0:0] disk SEAGATE ST32000444SS 0006 /dev/sdb /dev/sg2
[6:0:1:0] disk ATA ST3500418AS CC34 /dev/sdc /dev/sg3
[6:0:2:0] enclosu Intel RES2SV240 0600 - /dev/sg4
[6:0:3:0] disk SEAGATE ST373455SS 2189 /dev/sdd /dev/sg5

So the enclosure device can be accessed via /dev/sg4 (e.g. with a command like 'sg_ses /dev/sg4'). The lsscsi utility does not show the bsg device name but it is easily constructed from the above information; in this case it will be '/dev/bsg/6:0:2:0'. Note, depending on the context, those ":" characters may need to be escaped lest the shell interprets them as special characters.

lsscsi version 0.15 to 0.25 notes

These versions attempt to find the device name used in the /dev directory rather than the kernel generated name. The kernel generated name of the first SCSI disk discovered is /dev/sda . However in the lk 2.6 series kernels udev may be used to give this device some other name in the /dev directory, for example /dev/root_disk . By default this version will search for the device node name in the /dev directory whose type (i.e. block or char), major and minor numbers match the kernel device information found in sysfs. This change makes a SCSI (or USB, Firewire, etc) CD/DVD drive appear with a name like /dev/scd0 (as most distributions now use) rather than its kernel device node name of sr0 used by sysfs. There are other ways this could be done which would be more efficient in CPU usage, for example by lsscsi using the udevinfo facilities internally. This version of lsscsi can be given a '--kname' option to show the kernel (i.e. sysfs) device node name instead. Note that sysfs and SCSI errors and warning sent to the system log continue to use the kernel device node name.

By default lsscsi lists all SCSI devices (or hosts). This version allows select arguments to reduce the number of devices listed. For example "lsscsi 1" will list all channels, targets and LUNs within host1. A single SCSI device can be listed with 'lsscsi 1 0 0 0' (or 'lsscsi 1:0:0:0' or 'lsscsi [1:0:0:0]'). See man page for more information. This version of lsscsi uses the facilities of the scandir() library call to both select (filter) and sort the SCSI devices (or hosts) it finds in sysfs. Since libsysfs (version 1.2) doesn't have the ability to filter then this version of lsscsi uses scandir() [and not libsysfs]. Evidently a new version 2.0 API for libsysfs is under development (and I have requested a scandir() like select+sort facility).

Extra SCSI device and host attributes (as found in lk 2.6.12) can be seen by using the '--long' option twice (or more conveniently using '-ll'). Attributes are listed as "<name>=<value>" pairs, one per line (indented two spaces) when the '--list' option is given.

Recommended Links

Google matched content

Softpanorama Recommended

Top articles

Sites

lsscsi utility for Linux

lsscsi utility for Linux - The White House

Reference

options

long option format
short option format
version
added
description
--classic
-c

generate output similar to 'cat /proc/scsi/scsi'
--device
-d

show device node's major and minor numbers
--generic
-g

show scsi generic device node name
--help
-h

print usage message then exit
--hosts
-H

rather than list SCSI devices (logical units), list SCSI hosts instead
--kname
-k
0.15
show kernel name (as found in sysfs) instead of device node name (as found in the /dev directory)
--list
-L
0.19
show <attribute>=<value> pairs, one per line, indented by two or more spaces
--long
-l

show <attribute>=<value> pairs, several to a line. can be used multiple times for more output and different format.
--protection
-p
0.22
show protection information (T10-DIF).
--protmode
-P
0.25
show negotiated protection information mode
--size
-s
0.25
show disk size in human readable form
--sysfsroot=PATH
-y
0.23
Uses PATH as sysfs mount point (default sysfs mount point is '/sys')
--transport
-t
0.19
show transport information. If '--hosts' not given then this will be for targets. If '--hosts' is given then this will be for initiators (i.e. hosts). More information shown when used with '--list'.
--verbose
-v

increase verbosity of output. May be used multiple times to further increase verbosity.
--version
-V

print out the version and the date of last code change then exits

The lsscsi man page and the usage message in the executable also show the command line syntax.



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Haterís Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: March, 12, 2019