1lsscsi(8) LSSCSI lsscsi(8)
2
3
4
6 lsscsi - list SCSI devices (or hosts), list NVMe devices
7
9 lsscsi [--brief] [--classic] [--controllers] [--device] [--generic]
10 [--help] [--hosts] [--kname] [--list] [--long] [--long-unit] [--lunhex]
11 [--no-nvme] [--pdt] [--protection] [--protmode] [--scsi_id] [--size]
12 [--sysfsroot=PATH] [--sz-lbs] [--transport] [--unit] [--verbose]
13 [--version] [--wwn] [H:C:T:L]
14
16 Uses information in sysfs (Linux kernel series 2.6 and later) to list
17 SCSI devices (or hosts) currently attached to the system. Many non-SCSI
18 storage devices (but not all) used the SCSI subsystem in Linux. In lss‐
19 csi version 0.30 support was added to list NVMe devices.
20
21 In single line per device (LU or NVMe namespace) mode, the default,
22 each line starts with a 4 element tuple surrounded by square brackets.
23 For SCSI devices the first element 'H' is the host number, the second
24 element 'C' is the controller number, the third element 'T' is the tar‐
25 get number and the final element is the Logical Unit Number (LUN). All
26 four are integers. For NVMe namespaces see two paragraphs down. When
27 the --hosts option is given for SCSI devices the tuple is reduced to
28 one element: the host number.
29
30 If a H:C:T:L tuple is given as an argument on the command line then it
31 acts as a filter and only devices that match it are listed. The colons
32 don't have to be present, and '-', '*', '?' or missing components at
33 the end are interpreted as wildcards. The default is '*:*:*:*' which
34 means to match devices (i.e. Logical Units). Any filter string using
35 '*' of '?' should be surrounded by single or double quotes to stop
36 shell expansions. If '-' is used as a wildcard then the whole filter
37 tuple should be prefixed by '-- ' to tell this utility there are no
38 more options on the command line to be interpreted. A leading '[' and
39 trailing ']' are permitted ( e.g. '[1:0:0]' matches all LUNs on 1:0:0).
40 May also be used to filter --hosts in which case only the H is active
41 and may be either a number or in the form "host<n>" where <n> is a host
42 number.
43
44 For NVMe devices and controllers almost all of the previous paragraph
45 applies. The main difference is that "N" appears in the 'H' (first)
46 position. The 'C' position for NVMe is the controller's Linux gener‐
47 ated "char" device minor number which is the first number that appears
48 in a typical NVMe controller name, for example: "/dev/nvme2". The 'T'
49 position for NVMe is the "CNTLID" value. The final 'L' position is the
50 NVMe namespace identifier which is typically a sequential value start‐
51 ing at 1. The leading explicit "N" for NVMe devices is converted inter‐
52 nally into a large value (32,767) that should not interfere with any
53 Linux generated SCSI host number; it also means that the numeric sort
54 used to show hosts (controllers) and devices (LUs or logical units)
55 will always place NVMe devices and controllers after those that use the
56 SCSI subsystem. To filter using a H:C:T:L argument for NVMe con‐
57 trollers, "hostN", "hostN:<num>", "N" or "N:<num>" may be used; when no
58 "<num>" is given, only NVMe controllers will be listed (i.e. it lists
59 no SCSI hosts (HBAs)).
60
61 By default in this utility device node names (e.g. "/dev/sda" or
62 "/dev/root_disk") are obtained by noting the major and minor numbers
63 for the listed device obtained from sysfs (e.g. the contents of
64 "/sys/block/sda/dev") and then looking for a match in the "/dev" direc‐
65 tory. This "match by major and minor" will allow devices that have been
66 given a different name by udev (for example) to be correctly reported
67 by this utility.
68
69 In some situations it may be useful to see the device node name that
70 Linux would produce by default, so the --kname option is provided. An
71 example of where this may be useful is kernel error logs which tend to
72 report disk error messages using the disk's default kernel name.
73
75 Arguments to long options are mandatory for short options as well. The
76 options are arranged in alphabetical order based on the long option
77 name. Hyphenated long options can also take underscore, and vice versa
78 (e.g. --scsi_id or --scsi-id are acceptable).
79
80 -b, --brief
81 reduces one line per device output to the tuple and the primary
82 device name. This may simplify scripts that process the output
83 of this utility. With the --generic option it will show on each
84 line the tuple (from which the bsg pass-through device name can
85 be deduced), the primary device name (which the block subsystem
86 uses) and the sg device name (also a pass-through).
87 When the --pdt option is used together with this option the SCSI
88 Peripheral Device Type (PDT) is displayed in hex (with a leading
89 "0x") between the tuple and the primary device name. For NVMe
90 namespaces "0x0" is displayed (for a disk or direct access
91 device).
92
93 -c, --classic
94 The output is similar to that obtained from 'cat
95 /proc/scsi/scsi'
96
97 -C, --controllers
98 Lists NVMe controllers and SCSI hosts. This is a synonym for the
99 --hosts option.
100
101 -d, --device
102 After outputting the (probable) SCSI device name the device node
103 major and minor numbers are shown in brackets (e.g.
104 "/dev/sda[8:0]").
105
106 -g, --generic
107 Output the SCSI generic device file name. Note that if the sg
108 driver is a module it may need to be loaded otherwise '-' may
109 appear.
110 NVMe does not have generic (char) devices in the same sense as
111 SCSI. Instead NVMe Admin, NVM (i.e. block type commands such as
112 Read and Write) and MI (Management Interface (e.g. to an enclo‐
113 sure)) commands are all sent to the containing controller whose
114 device name is shown when the --hosts option is used.
115 To unclutter the single line per device mode the --brief option
116 combined with this option should help.
117
118 -h, --help
119 Output the usage message and exit.
120
121 -H, --hosts
122 List the SCSI hosts and NVMe controllers currently attached to
123 the system. If this option is not given (and the --controllers
124 option is not given) then SCSI devices (logical units (LUs))
125 followed by NVMe devices (namespaces) are listed.
126
127 -k, --kname
128 Use Linux default algorithm for naming devices (e.g. block major
129 8, minor 0 is "/dev/sda") rather than the "match by major and
130 minor" in the "/dev" directory as discussed above.
131
132 -L, --list
133 Output additional information in <attribute_name>=<value> pairs,
134 one pair per line preceded by two spaces. This option has the
135 same effect as '-lll'.
136
137 -l, --long
138 Output additional information for each SCSI device (host). Can
139 be used multiple times for more output in which case the shorter
140 option form is more convenient (e.g. '-lll'). When used three
141 times (i.e. '-lll') outputs SCSI device (host) attributes one
142 per line; preceded by two spaces; in the form
143 "<attribute_name>=<value>".
144
145 -U, --long-unit
146 Output logical unit name in full, if available. It replaces the
147 normal vendor, product and revision strings given in the single
148 logical unit per line mode. If no logical unit name is found
149 "none" is printed. If the logical unit name is long (e.g. a
150 UUID) then following fields are pushed further to the right as
151 required. This option is functionally equivalent to the '-uuu'
152 option.
153 If the option is used twice (e.g. '-UU') then EUI, NAA, UUID and
154 T10 vendor ID formats are prefixed by "eui.", "naa.", "uuid."
155 and "t10." respectively. Note that SCSI name format used by
156 iSCSI should already be prefixed by 'iqn.'. Using the '--unit'
157 option 4 or more times (e.g. '-uuuu') will have the same action
158 as '-UU'.
159 --long_unit is also an acceptable form when invoking this
160 option.
161
162 -x, --lunhex
163 when this option is used once the LUN in the tuple (at the start
164 of each device line) is shown in "T10" format which is up to 16
165 hexadecimal digits. It is prefixed by "0x" to distinguish the
166 LUN from the decimal value shown in the absence of this option.
167 Also hierarchal LUNs are shown with a "_" character separating
168 the levels. For example the two level LUN: 0x0355006600000000
169 will appear as 0x0355_0066. If this option is given twice (e.g.
170 using the short form: '-xx') then the full 16 hexadecimal digits
171 are shown for each LUN, prefixed by "0x".
172 For NVMe, the namespace identifier (nsid) is shown in the "L"
173 position. The nsid is a 32 bit unsigned quantities with 0x0 and
174 0xffffffff reserved. Without this option, the nsid is shown in
175 decimal. When this option is used once the nsid is output in hex
176 with a lead 0x and with up to 3 leading zeros. When this option
177 is used twice the nsid is output in hex with up to 7 leading
178 zeros.
179
180 -N, --no-nvme
181 this option excludes NVMe devices and controllers for the out‐
182 put. This option may be needed to stop NVMe device output inter‐
183 fering with specific format output like that produced when the
184 --classic option is used.
185 To only show NVMe devices, use 'lsscsi N', to only show NVMe
186 controllers, use 'lsscsi -H N'.
187
188 -D, --pdt
189 this option displays the SCSI Peripheral Device Type (PDT) in
190 hex preceded by "0x". For NVME namespaces "0x0' is displayed
191 which corresponds to a disk ("Direct Access Device" or SSD). In
192 single line output this hex PDT replaces the device type abbre‐
193 viation (e.g. "0x0 " replaces "disk ") and appears after
194 the tuple.
195
196 -p, --protection
197 Output target (DIF) and initiator (DIX) protection types.
198
199 -P, --protmode
200 Output effective protection information mode for each disk
201 device.
202
203 -i, --scsi_id
204 outputs the udev derived matching id found in
205 /dev/disk/by-id/scsi* . This is only for disk (and disk like)
206 devices. If no match is found then "dm-uuid-mpath*" and "usb*"
207 are searched in the same directory. If there is still no match
208 then the /sys/class/block/<disk>/holders directory is searched.
209 The matching id is printed following the device name (e.g.
210 /dev/sdc) and if there is no match "-" is output.
211
212 -s, --size
213 Print disk capacity in human readable form. When given once,
214 normal base 10 SI units are used as a prefix for 'B' which is
215 bytes (aka octets). For example MB, GB and TB stand for 10^6,
216 10^9 and 10^12 bytes respectively. When given twice, IEC 80000-3
217 prefixes for 'B' are used; for example MiB, GiB and TiB stand
218 for 2^20, 2^30 and 2^40 bytes respectively. The output is
219 rounded to 3 or less significant figures in order to fit on a
220 single line.
221 If given three times (short form is the more convenient: '-sss')
222 then the disk capacity as a logical block count is given. This
223 is an exact figure in decimal reported by the storage device at
224 discovery. Discovery is typically just after boot time, or when
225 it was last attached if the storage device is removable.
226 To unclutter the single line per device mode the --brief option
227 combined with this option should help.
228
229 -y, --sysfsroot=PATH
230 assumes sysfs is mounted at PATH instead of the default '/sys' .
231 If this option is given PATH should be an absolute path (i.e.
232 start with '/').
233
234 -S, --sz-lbs
235 Print disk capacity as a number of logical blocks (which is the
236 same as '-sss'). When used twice a comma is added followed by
237 the logical block size in bytes. It should be a number like 512
238 or 4096.
239 If the logical block size cannot be found (e.g. because the ver‐
240 sion of Linux predates the /sys/block/<dev_name>/queue direc‐
241 tory) then the number of 512 byte blocks followed comma and then
242 '512' is output irrespective of what the true logical block size
243 of the device is. This special case action occurs whether this
244 option is given one or more times.
245 To unclutter the single line per device mode the --brief option
246 combined with this option should help.
247
248 -t, --transport
249 Output transport information. This will be target related infor‐
250 mation or, if --hosts is given, initiator related information.
251 When used without --list, a name or identifier (or both) are
252 output on a single line, usually prefixed by the type of trans‐
253 port. For devices this information replaces the normal vendor,
254 product and revision strings. When the --list option is also
255 given then additionally multiple lines of attribute_name=value
256 pairs are output, each indented by two spaces. See the section
257 on transports below.
258
259 -u, --unit
260 Output logical unit name, if available. If this option is given
261 once or twice, then the 30 character field where the vendor,
262 product and revision strings are usually placed is expanded to
263 32 characters and replaced by the logical unit name. If no logi‐
264 cal unit name is found "none" is printed. The first found of
265 the NAA, EUI-64 or SCSI name string is output unless a SCSI name
266 string is found and the associated target port indicates the
267 iSCSI protocol, in which case the SCSI name string is preferred.
268 Finally if there is no match on the above and a T10 Vendor ID
269 descriptor is found then it is used.
270 If the name cannot fit in the 32 character field then it is
271 truncated to the right and a trailing '_' character is used to
272 alert the reader to the truncation. The 32 character width is
273 chosen since that is large enough to hold 16 byte NAA or EUI-64
274 identifiers. However SCSI name strings as used by iSCSI can be
275 larger than that.
276 If this option is used twice then this field is also 32 charac‐
277 ter wide. If the logical unit name cannot fit then it will be
278 truncated to the left and a leading '_' character is used to
279 alert the reader to the truncation.
280 If this option is used three times the whole logical unit name
281 is output, followed by several spaces.
282 In order for this option to work, it needs a Linux kernel from
283 and including 3.15 . It accesses the sysfs vpd_pg83 file for the
284 device in question. Old SCSI and ATA (SATA) equipment may not
285 provide this information. If it is provided by ATA (SATA) then
286 it will be the WWN.
287
288 -v, --verbose
289 outputs directory names where information is found. Use multiple
290 times for more output.
291
292 -V, --version
293 outputs version information then exits. If used once outputs to
294 stderr; if used twice outputs to stdout and shortens the date to
295 yyyymmdd numeric format.
296
297 -w, --wwn
298 outputs the WWN for disks instead of manufacturer, model and
299 revision (or instead of transport information). The World Wide
300 Name (WWN) is typically 64 bits long (16 hex digits) but could
301 be up to 128 bits long. To indicate the WWN is hexadecimal, it
302 is prefixed by "0x". The ATA/SATA WWN is referred to as LU name
303 in SCSI jargon; hence this option is more or less superseded by
304 the --unit and --long-unit options.
305
307 This utility lists SCSI devices which are known as logical units (LU)
308 in the SCSI Architecture Model (ref: SAM-5 at http://www.t10.org) or
309 hosts when the --hosts option is given. A host is called an initiator
310 in SAM-5. A SCSI command travels out via an initiator, across some
311 transport to a target and then onwards to a logical unit. A target
312 device may contain several logical units. A target device has one or
313 more ports that can be viewed as transport end points. Each FC and SAS
314 disk is a single target that has two ports and contains one logical
315 unit. If both target ports on a FC or SAS disk are connected and visi‐
316 ble to a machine, then lsscsi will show two entries. Initiators (i.e.
317 hosts) also have one or more ports and some HBAs in Linux have a host
318 entry per initiator port while others have a host entry per initiator
319 device.
320
321 When the --transport option is given for devices (i.e. --hosts not
322 given) then most of the information produced by lsscsi is associated
323 with the target, or more precisely: the target port, through which SCSI
324 commands pass that access a logical unit.
325
326 Typically this utility provides one line of output per "device" or
327 host. Significantly more information can be obtained by adding the
328 --list option. When used together with the --transport option, after
329 the summary line, multiple lines of transport specific information in
330 the form "<attribute_name>=<value>" are output, each indented by two
331 spaces. Using a filter argument will reduce the volume of output if a
332 lot of devices or hosts are present.
333
334 The transports that are currently recognized are: IEEE 1394, ATA, FC,
335 iSCSI, SAS, SATA, SPI, SRP and USB.
336
337 For IEEE 1394 (a.k.a. Firewire and "SBP" when storage is involved), the
338 EUI-64 based target port name is output when --transport is given, in
339 the absence of the --hosts option. When the --hosts option is given
340 then the EUI-64 initiator port name is output. Output on the summary
341 line specific to the IEEE 1394 transport is prefixed by "sbp:".
342
343 To detect ATA and SATA devices a crude check is performed on the driver
344 name (after the checks for other transports are exhausted). Based on
345 the driver name either the ATA or SATA transport type is chosen. Output
346 on the summary line is either "ata:" or "sata:". A search is made for
347 an associated vpd_pg83 file in sysfs, if found it may contain the
348 device's WWN which is output if present. The WWN will not appear in
349 Linux kernels before 3.15 and with old PATA and SATA devices. Most
350 device and hosts flagged as "ata:" will use the parallel ATA transport
351 (PATA). For SATA devices that are attached via a SAS expander, see the
352 SAS paragraph below.
353
354 For Fibre Channel (FC) the port name and port identifier are output
355 when --transport is given. In the absence of the --hosts option these
356 ids will be for the target port associated with the device (logical
357 unit) being listed. When the --hosts option is given then the ids are
358 for the initiator port used by the host. Output on the summary line
359 specific to the FC transport is prefixed by "fc:". If FCoE (over Eth‐
360 ernet) is detected the prefix is changed to "fcoe:".
361
362 For iSCSI the target port name is output when --transport is given, in
363 the absence of the --hosts option. This is made up of the iSCSI name
364 and the target portal group tag. Since the iSCSI name starts with "iqn"
365 no further prefix is used. When the --hosts option is given then only
366 "iscsi:" is output on the summary line.
367
368 For Serial Attached SCSI the SAS address of the target port (or initia‐
369 tor port if --hosts option is also given) is output. This will be a
370 naa-5 address. For SAS HBAs and SAS targets (such as SAS disks and tape
371 drives) the SAS address will be world wide unique. For SATA disks
372 attached to a SAS expander, the expander provides the SAS address by
373 adding a non zero value to its (i.e. the expander's) SAS address (e.g.
374 expander_sas_address + phy_id + 1). SATA disks directly attached to SAS
375 HBAs seem to have an indeterminate SAS address. Output on the summary
376 line specific to the SAS transport is prefixed by "sas:".
377
378 For SATA devices, see the paragraph above on ATA devices. As noted in
379 the previous paragraph, SATA devices attached to SAS expanders will
380 display a manufactured SAS transport address (manufactured by the
381 expander) rather than the SATA device's WWN.
382
383 For the SCSI Parallel Interface (SPI) the target port identifier (usu‐
384 ally a number between 0 and 15 inclusive) is output when --transport is
385 given, in the absence of the --hosts option. When the --hosts option is
386 given then only "spi:" is output on the summary line.
387
388 For the PCIe transport (a.k.a. PCI Express) there at two possible stor‐
389 age types: NVMe and SOP/PQI (SCSI over PCIe). There are very few exam‐
390 ples of the latter currently so this utility concentrates on NVMe. NVMe
391 uses its own command set and not SCSI but has many things in common.
392 Rather than re-invent everything currently in use that SCSI has accumu‐
393 lated over nearly 40 years, NVMe is beginning to use some parts of
394 SCSI. A recent example is the SES-3 standard for enclosure management
395 which has been adopted by NVMe. In SCSI a SES device is a logical unit
396 with a peripheral device type (PDT) of 0xd (for enclosure) so it will
397 appear when the lsscsi utility is invoked without any options. In NVMe
398 is seems that an enclosure with appear as attached to the management
399 interface (MI) of a NVMe controller. This means it should appear when
400 "lsscsi --hosts" is invoked. It is unclear whether such a NVMe con‐
401 troller can have any storage namespaces associated with it. The sg_ses
402 utility (in the sg3_utils package) can then be given that NVMe con‐
403 troller's device name (e.g. /dev/nmve1).
404 When the --transport option is given, after "pcie" the NVMe con‐
405 troller's subsystem vendor id and device id are output, separated by a
406 colon (e.g. "pcie 0x8086:0x390a").
407
408 For the SCSI RDMA Protocol (SRP) the IB (InfiniBand) port's GUID is
409 given. As an example, it has a form like this: 0002:c903:00fa:abcd .
410
411 When a USB transport is detected, the summary line will contain "usb:"
412 followed by a USB device name. The USB device name has the form
413 "<b>-<p1>[.<p2>[.<p3>]]:<c>.<i>" where <b> is the USB bus number, <p1>
414 is the port on the host. <p2> is a port on a host connected hub, if
415 present. If needed <p3> is a USB hub port closer to the USB storage
416 device. <c> refers to the configuration number while <i> is the inter‐
417 face number. There is a separate SCSI host for each USB (SCSI) target.
418 A USB SCSI target may contain multiple logical units. Thus the same
419 "usb: <device_name>" string appears for a USB SCSI host and all logical
420 units that belong to the USB SCSI target associated with that USB SCSI
421 host.
422
424 For historical reasons and as used by several other Unix based Operat‐
425 ing Systems, Linux uses a tuple of integers to describe (a path to) a
426 SCSI device (also know as a Logical Unit (LU)). The last element of
427 that tuple is the so-called Logical Unit Number (LUN). And originally
428 in SCSI a LUN was an integer, at first 3 bits long, then 8 then 16
429 bits. SCSI LUNs today (SAM-5 section 4.7) are 64 bits but SCSI stan‐
430 dards now consider a LUN to be an array of 8 bytes.
431
432 Up until 2013, Linux mapped SCSI LUNs to a 32 bit integer by taking the
433 first 4 bytes of the SCSI LUN and ignoring the last 4 bytes. Linux
434 treated the first two bytes of the SCSI LUN as a unit (a word) and it
435 became the least significant 16 bits in the Linux LUN integer. The next
436 two bytes of the SCSI LUN became the upper 16 bits in the Linux LUN
437 integer. The rationale for this was to keep commonly used LUNs small
438 Linux LUN integers. The most common LUN (by far) in SCSI LUN (hex)
439 notation is 00 00 00 00 00 00 00 00 and this becomes the Linux LUN
440 integer 0. The next most common LUN is 00 01 00 00 00 00 00 00 and this
441 becomes the Linux LUN integer 1.
442
443 In 2013 it is proposed to increase Linux LUNs to a 64 bit integer by
444 extending the mapping outlined above. In this case all information that
445 is possible to represent in a SCSI LUN is mapped a Linux LUN (64 bit)
446 integer. And the mapping can be reversed without losing information.
447
448 This version of the utility supports both 32 and 64 bit Linux LUN inte‐
449 gers. By default the LUN shown at the end of the tuple commencing each
450 line is a Linux LUN as a decimal integer. When the --lunhex option is
451 given then the LUN is in SCSI LUN format with the 8 bytes run together,
452 with the output in hexadecimal and prefixed by '0x'. The LUN is decoded
453 according to SAM-5's description and trailing zeros (i.e. digits to the
454 right) are not shown. So LUN 0 (i.e. 00 00 00 00 00 00 00 00) is shown
455 as 0x0000 and LUN 65 (i.e. 00 41 00 00 00 00 00 00) is shown as 0x0041.
456 If the --lunhex option is given twice then the full 64 bits (i.e. 16
457 hexadecimal digits) are shown.
458
459 If the --lunhex option is not given on the command line then the envi‐
460 ronment variable LSSCSI_LUNHEX_OPT is checked. If LSSCSI_LUNHEX_OPT is
461 present then its associated value becomes the number of times the
462 --lunhex is set internally. So, for example, 'LSSCSI_LUNHEX_OPT=2 lss‐
463 csi' and 'lsscsi -xx' are equivalent.
464
466 Information about this utility including examples can also be found at:
467 http://sg.danny.cz/scsi/lsscsi.html .
468
470 Information for this command is derived from the sysfs file system,
471 which is assumed to be mounted at /sys unless specified otherwise by
472 the user. SCSI (pseudo) devices that have been detected by the SCSI
473 mid level will be listed even if the required upper level drivers (i.e.
474 sd, sr, st, osst or ch) have not been loaded. If the appropriate upper
475 level driver has not been loaded then the device file name will appear
476 as '-' rather than something like '/dev/st0'. Note that some devices
477 (e.g. scanners and medium changers) do not have a primary upper level
478 driver and can only be accessed via a SCSI generic (sg) device name.
479
480 Generic SCSI devices can also be accessed via the bsg driver in Linux.
481 By default, the bsg driver's device node names are of the form
482 '/dev/bsg/H:C:T:L'. So, for example, the SCSI device shown by this
483 utility on a line starting with the tuple '6:0:1:2' could be accessed
484 via the bsg driver with the '/dev/bsg/6:0:1:2' device node name.
485
486 lsscsi version 0.21 or later is required to correctly display SCSI
487 devices in Linux kernel 2.6.26 (and possibly later) when the CON‐
488 FIG_SYSFS_DEPRECATED_V2 kernel option is not defined.
489
491 Written by Doug Gilbert
492
494 Report bugs to <dgilbert at interlog dot com>.
495
497 Copyright © 2003-2018 Douglas Gilbert
498 This software is distributed under the GPL version 2. There is NO war‐
499 ranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR‐
500 POSE.
501
503 lspci lsusb lsblk
504
505
506
507lsscsi-0.30 June 2018 lsscsi(8)