1lsscsi(8)                           LSSCSI                           lsscsi(8)
2
3
4

NAME

6       lsscsi - list SCSI devices (or hosts) and their attributes
7

SYNOPSIS

9       lsscsi  [--classic] [--device] [--generic] [--help] [--hosts] [--kname]
10       [--list] [--lunhex] [--long]  [--protection]  [--protmode]  [--scsi_id]
11       [--size]   [--sysfsroot=PATH]   [--transport]  [--verbose]  [--version]
12       [--wwn] [H:C:T:L]
13

DESCRIPTION

15       Uses information in sysfs (Linux kernel series 2.6 and later)  to  list
16       SCSI  devices  (or hosts) currently attached to the system. Options can
17       be used to control the amount and form of information provided for each
18       device.
19
20       If  a  H:C:T:L  argument  is  given  then  it acts as a filter and only
21       devices that match it are listed. The colons don't have to be  present,
22       and  '-',  '*',  '?' or missing arguments at the end are interpreted as
23       wildcards. The default is '*:*:*:*' which means  to  match  everything.
24       Any  filter  string  using '*' of '?' should be surrounded by single or
25       double quotes to stop shell expansions. If '-' is used  as  a  wildcard
26       then the whole filter argument should be prefixed by '-- ' to tell this
27       utility there are no more options on the  command  line  to  be  inter‐
28       preted.   A  leading '[' and trailing ']' are permitted (e.g. '[1:0:0]'
29       matches all LUNs on 1:0:0). May also be used to filter --hosts in which
30       case  only  the  H  is active and may be either a number or in the form
31       "host<n>" where <n> is a host number.
32
33       By default in this  utility  device  node  names  (e.g.  "/dev/sda"  or
34       "/dev/root_disk")  are  obtained  by noting the major and minor numbers
35       for the listed  device  obtained  from  sysfs  (e.g.  the  contents  of
36       "/sys/block/sda/dev") and then looking for a match in the "/dev" direc‐
37       tory. This "match by major and minor" will allow devices that have been
38       given  a  different name by udev (for example) to be correctly reported
39       by this utility.
40
41       In some situations it may be useful to see the device  node  name  that
42       Linux  would produce by default, so the --kname option is provided.  An
43       example of where this may be useful is kernel error logs which tend  to
44       report disk error messages using the disk's default kernel name.
45

OPTIONS

47       Arguments to long options are mandatory for short options as well.  The
48       options are arranged in alphabetical order based  on  the  long  option
49       name.
50
51       -c, --classic
52              The   output   is   similar   to   that   obtained   from   'cat
53              /proc/scsi/scsi'
54
55       -d, --device
56              After outputting the (probable) SCSI device name the device node
57              major   and   minor   numbers   are   shown  in  brackets  (e.g.
58              "/dev/sda[8:0]").
59
60       -g, --generic
61              Output the SCSI generic device file name. Note that  if  the  sg
62              driver  is  a  module it may need to be loaded otherwise '-' may
63              appear.
64
65       -h, --help
66              Output the usage message and exit.
67
68       -H, --hosts
69              List the SCSI hosts currently attached to the  system.  If  this
70              option is not given then SCSI devices are listed.
71
72       -k, --kname
73              Use Linux default algorithm for naming devices (e.g. block major
74              8, minor 0 is "/dev/sda") rather than the "match  by  major  and
75              minor" in the "/dev" directory as discussed above.
76
77       -L, --list
78              Output additional information in <attribute_name>=<value> pairs,
79              one pair per line preceded by two spaces. This  option  has  the
80              same effect as '-lll'.
81
82       -l, --long
83              Output  additional  information for each SCSI device (host). Can
84              be used multiple times for more output in which case the shorter
85              option  form  is  more convenient (e.g. '-lll'). When used three
86              times (i.e. '-lll') outputs SCSI device  (host)  attributes  one
87              per    line;    preceded    by   two   spaces;   in   the   form
88              "<attribute_name>=<value>".
89
90       -x, --lunhex
91              when this option is used once the LUN in the tuple (at the start
92              of  each device line) is shown in "T10" format which is up to 16
93              hexadecimal digits. It is prefixed by "0x"  to  distinguish  the
94              LUN  from the decimal value shown in the absence of this option.
95              Also hierarchal LUNs are shown with a "_"  character  separating
96              the  levels.  For  example the two level LUN: 0x0355006600000000
97              will appear as 0x0355_0066. If this option is given twice  (e.g.
98              using the short form: '-xx') then the full 16 hexadecimal digits
99              are shown for each LUN, prefixed by "0x".
100
101       -p, --protection
102              Output target (DIF) and initiator (DIX) protection types.
103
104       -P, --protmode
105              Output effective  protection  information  mode  for  each  disk
106              device.
107
108       -i, --scsi_id
109              outputs    the    udev    derived    matching    id   found   in
110              /dev/disk/by-id/scsi* .  This is only for disk (and  disk  like)
111              devices.  If  no match is found then "dm-uuid-mpath*" and "usb*"
112              are searched in the same directory.  If there is still no  match
113              then  the /sys/class/block/<disk>/holders directory is searched.
114              The matching id is  printed  following  the  device  name  (e.g.
115              /dev/sdc) and if there is no match "-" is output.
116
117       -s, --size
118              Print disk capacity in human readable form.
119
120       -t, --transport
121              Output  transport  information.  This  will  be a target related
122              information or, if --hosts is given, initiator related  informa‐
123              tion.  When  used without --list, a name or identifier (or both)
124              are output on a single line, usually prefixed  by  the  type  of
125              transport. For devices this information replaces the normal ven‐
126              dor, product and revision strings. When  the  --list  option  is
127              also    given    then    additionally    multiple    lines    of
128              attribute_name=value pairs are output, each indented by two spa‐
129              ces. See the section on transports below.
130
131       -v, --verbose
132              outputs directory names where information is found. Use multiple
133              times for more output.
134
135       -V, --version
136              outputs version information then exits.
137
138       -w, --wwn
139              outputs the WWN for disks instead  of  manufacturer,  model  and
140              revision  (or  instead of transport information). The World Wide
141              Name (WWN) is typically 64 bits long (16 hex digits)  but  could
142              be  up  to 128 bits long. To indicate the WWN is hexadecimal, it
143              is prefixed by "0x".
144
145       -y, --sysfsroot=PATH
146              assumes sysfs is mounted at PATH instead of the default '/sys' .
147              If  this  option  is given PATH should be an absolute path (i.e.
148              start with '/').
149

TRANSPORTS

151       This utility lists SCSI devices which are known as logical  units  (LU)
152       in  the  SCSI  Architecture Model (ref: SAM-4 at http://www.t10.org) or
153       hosts when the --hosts option is given. A host is called  an  initiator
154       in  SAM-4.  A  SCSI  command  travels out via an initiator, across some
155       transport to a target and then onwards to  a  logical  unit.  A  target
156       device  may  contain  several logical units. A target device has one or
157       more ports that can be viewed as transport end points. Each FC and  SAS
158       disk  is  a  single  target that has two ports and contains one logical
159       unit. If both target ports on a FC or SAS disk are connected and  visi‐
160       ble  to  a machine, then lsscsi will show two entries. Initiators (i.e.
161       hosts) also have one or more ports and some HBAs in Linux have  a  host
162       entry  per  initiator port while others have a host entry per initiator
163       device.
164
165       When the --transport option is given for  devices  (i.e.   --hosts  not
166       given)  then  most  of the information produced by lsscsi is associated
167       with the target, or more precisely: the target port, through which SCSI
168       commands pass that access a logical unit.
169
170       Typically  this  utility  provides  one  line of output per "device" or
171       host.  Significantly more information can be  obtained  by  adding  the
172       --list  option.  When  used together with the --transport option, after
173       the summary line, multiple lines of transport specific  information  in
174       the  form  "<attribute_name>=<value>"  are output, each indented by two
175       spaces.  Using a filter argument will reduce the volume of output if  a
176       lot of devices or hosts are present.
177
178       The  transports  that are currently recognized are: IEEE 1394, ATA, FC,
179       iSCSI, SAS, SATA, SPI and USB.
180
181       For IEEE 1394 (a.k.a. Firewire and "SBP" when storage is involved), the
182       EUI-64  based  target port name is output when --transport is given, in
183       the absence of the --hosts option. When the  --hosts  option  is  given
184       then  the  EUI-64  initiator port name is output. Output on the summary
185       line specific to the IEEE 1394 transport is prefixed by "sbp:".
186
187       to detect ATA and SATA a crude check is performed on  the  driver  name
188       (after  the  checks  for  other transports are exhausted). Based on the
189       driver name either ATA or SATA transport type is chosen. Output on  the
190       summary  line  is  either  "ata:"  or  "sata:". No other attributes are
191       given.  Most device and hosts flagged as "ata:" will use  the  parallel
192       ATA transport (PATA).
193
194       For  Fibre  Channel  (FC)  the port name and port identifier are output
195       when --transport is given. In the absence of the --hosts  option  these
196       ids  will  be  for  the target port associated with the device (logical
197       unit) being listed. When the --hosts option is given then the  ids  are
198       for  the  initiator  port  used by the host. Output on the summary line
199       specific to the FC transport is prefixed by "fc:".  If FCoE (over  Eth‐
200       ernet) is detected the prefix is changed to "fcoe:".
201
202       For  iSCSI the target port name is output when --transport is given, in
203       the absence of the --hosts option. This is made up of  the  iSCSI  name
204       and the target portal group tag. Since the iSCSI name starts with "iqn"
205       no further prefix is used. When the --hosts option is given  then  only
206       "iscsi:" is output on the summary line.
207
208       For Serial Attached SCSI the SAS address of the target port (or initia‐
209       tor port if --hosts option is also given) is output.  This  will  be  a
210       naa-5 address. For SAS HBAs and SAS targets (such as SAS disks and tape
211       drives) the SAS address will be  world  wide  unique.  For  SATA  disks
212       attached  to  a  SAS expander, the expander provides the SAS address by
213       adding a non zero value to its (i.e. the expander's) SAS address  (e.g.
214       expander_sas_address + phy_id + 1). SATA disks directly attached to SAS
215       HBAs seem to have an indeterminate SAS address. Output on  the  summary
216       line specific to the SAS transport is prefixed by "sas:".
217
218       For  the SCSI Parallel Interface (SPI) the target port identifier (usu‐
219       ally a number between 0 and 15 inclusive) is output when --transport is
220       given, in the absence of the --hosts option. When the --hosts option is
221       given then only "spi:" is output on the summary line.
222
223       When a USB transport is detected, the summary line will contain  "usb:"
224       followed  by  a  USB  device  name.  The  USB  device name has the form
225       "<b>-<p1>[.<p2>[.<p3>]]:<c>.<i>" where <b> is the USB bus number,  <p1>
226       is  the  port  on  the host. <p2> is a port on a host connected hub, if
227       present.  If needed <p3> is a USB hub port closer to  the  USB  storage
228       device.  <c> refers to the configuration number while <i> is the inter‐
229       face number. There is a separate SCSI host for each USB (SCSI)  target.
230       A  USB  SCSI  target  may contain multiple logical units. Thus the same
231       "usb: <device_name>" string appears for a USB SCSI host and all logical
232       units  that belong to the USB SCSI target associated with that USB SCSI
233       host.
234

LUNS

236       For historical reasons and as used by several other Unix based  Operat‐
237       ing  Systems,  Linux uses a tuple of integers to describe (a path to) a
238       SCSI device (also know as a Logical Unit (LU)).  The  last  element  of
239       that  tuple  is the so-called Logical Unit Number (LUN). And originally
240       in SCSI a LUN was an integer, at first 3 bits  long,  then  8  then  16
241       bits.  SCSI  LUNs  today (SAM-5 section 4.7) are 64 bits but SCSI stan‐
242       dards now consider a LUN to be an array of 8 bytes.
243
244       Up until 2013, Linux mapped SCSI LUNs to a 32 bit integer by taking the
245       first  4  bytes  of  the  SCSI LUN and ignoring the last 4 bytes. Linux
246       treated the first two bytes of the SCSI LUN as a unit (a word)  and  it
247       became the least significant 16 bits in the Linux LUN integer. The next
248       two bytes of the SCSI LUN became the upper 16 bits  in  the  Linux  LUN
249       integer.  The  rationale  for this was to keep commonly used LUNs small
250       Linux LUN integers. The most common LUN (by  far)  in  SCSI  LUN  (hex)
251       notation  is  00  00  00  00 00 00 00 00 and this becomes the Linux LUN
252       integer 0. The next most common LUN is 00 01 00 00 00 00 00 00 and this
253       becomes the Linux LUN integer 1.
254
255       In  2013  it  is proposed to increase Linux LUNs to a 64 bit integer by
256       extending the mapping outlined above. In this case all information that
257       is  possible  to represent in a SCSI LUN is mapped a Linux LUN (64 bit)
258       integer. And the mapping can be reversed without losing information.
259
260       This version of the utility supports both 32 and 64 bit Linux LUN inte‐
261       gers.  By default the LUN shown at the end of the tuple commencing each
262       line is a Linux LUN as a decimal integer. When the --lunhex  option  is
263       given then the LUN is in SCSI LUN format with the 8 bytes run together,
264       with the output in hexadecimal and prefixed by '0x'. The LUN is decoded
265       according to SAM-5's description and trailing zeros (i.e. digits to the
266       right) are not shown. So LUN 0 (i.e. 00 00 00 00 00 00 00 00) is  shown
267       as 0x0000 and LUN 65 (i.e. 00 41 00 00 00 00 00 00) is shown as 0x0041.
268       If the --lunhex option is given twice then the full 64  bits  (i.e.  16
269       hexadecimal digits) are shown.
270
271       If  the --lunhex option is not given on the command line then the envi‐
272       ronment variable LSSCSI_LUNHEX_OPT is checked. If LSSCSI_LUNHEX_OPT  is
273       present  then  its  associated  value  becomes  the number of times the
274       --lunhex is set internally. So, for example, 'LSSCSI_LUNHEX_OPT=2  lss‐
275       csi' and 'lsscsi -xx' are equivalent.
276

EXAMPLES

278       Information about this utility including examples can also be found at:
279       http://sg.danny.cz/scsi/lsscsi.html .
280

NOTES

282       Information for this command is derived from  the  sysfs  file  system,
283       which  is  assumed  to be mounted at /sys unless specified otherwise by
284       the user.  SCSI (pseudo) devices that have been detected  by  the  SCSI
285       mid level will be listed even if the required upper level drivers (i.e.
286       sd, sr, st, osst or ch) have not been loaded. If the appropriate  upper
287       level  driver has not been loaded then the device file name will appear
288       as '-' rather than something like '/dev/st0'. Note  that  some  devices
289       (e.g.  scanners  and medium changers) do not have a primary upper level
290       driver and can only be accessed via a SCSI generic (sg) device name.
291
292       Generic SCSI devices can also be accessed via the bsg driver in  Linux.
293       By  default,  the  bsg  driver's  device  node  names  are  of the form
294       '/dev/bsg/H:C:T:L'. So, for example, the  SCSI  device  shown  by  this
295       utility  on  a line starting with the tuple '6:0:1:2' could be accessed
296       via the bsg driver with the '/dev/bsg/6:0:1:2' device node name.
297
298       lsscsi version 0.21 or later is  required  to  correctly  display  SCSI
299       devices  in  Linux  kernel  2.6.26  (and  possibly later) when the CON‐
300       FIG_SYSFS_DEPRECATED_V2 kernel option is not defined.
301

AUTHOR

303       Written by Doug Gilbert
304

REPORTING BUGS

306       Report bugs to <dgilbert at interlog dot com>.
307
309       Copyright © 2003-2013 Douglas Gilbert
310       This software is distributed under the GPL version 2. There is NO  war‐
311       ranty;  not  even  for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR‐
312       POSE.
313

SEE ALSO

315       lspci lsusb
316
317
318
319lsscsi-0.27                       March 2013                         lsscsi(8)
Impressum