Mastering lsscsi: Understand SCSI, Install, Options, and Debugging
This guide explains the SCSI protocol and common disk interfaces, details how to install and use the lsscsi command on various Linux distributions, describes its options and output formats, and provides examples of querying devices, interpreting results, and enabling SCSI logging for debugging.
What is SCSI?
SCSI (Small Computer System Interface) is a comprehensive data‑transfer protocol that enables hosts to send commands, receive status, and exchange block data with storage devices such as disks, tapes, optical drives, and printers. It typically resides in device drivers or host‑adapter firmware.
Common Disk Interfaces
IDE
IDE (Integrated Drive Electronics) integrates the drive controller with the disk platter. Historically referred to ATA‑1, it has been superseded by newer standards such as ATA, Ultra ATA, DMA, and Ultra DMA. IDE is inexpensive and compatible but offers slower data transfer and no hot‑plug support.
SCSI
SCSI is a high‑speed data‑transfer technology originally designed for minicomputers. It supports multiple devices, multitasking, large bandwidth, low CPU usage, and hot‑plug capability, making it common in mid‑ to high‑end servers and workstations despite its higher cost.
SATA
SATA (Serial Advanced Technology Attachment) is the modern serial interface for disks. It uses an embedded clock, provides stronger error‑correction, and can verify command integrity. SATA also offers a simple structure and hot‑plug support.
lsscsi Command
Installation
# Debian/Ubuntu
apt-get install lsscsi
# Alpine
apk add lsscsi
# Arch Linux
pacman -S lsscsi
# CentOS
yum install lsscsi
# Fedora
dnf install lsscsi
# Docker (run container)
docker run cmd.cat/lsscsi lsscsiManual and Options
The command lists SCSI/SATA devices such as hard‑disk and optical‑drive units. Its syntax is: lsscsi [options] [H:C:T:L] Key options include:
-g : show generic SCSI device file name
-k : display kernel name instead of device node name
-d : show major/minor numbers of the device node
-H : list SCSI hosts rather than devices
-l : display additional per‑device information
-c : output equivalent to cat /proc/scsi/scsi -p : show data‑integrity (DIF/DIX) protection info
-t : display transport information (ATA, FC, SAS, etc.)
-L : present extra attributes as key=value -v : output the directory name when information is found
-y<path> : assume sysfs is mounted at the given path
-s : show human‑readable capacity
-x : display LUN number in hexadecimal
-P : output valid protection mode information
-i : show udev‑related attributes
-w : display WWN (World Wide Name)
Examples
List all SCSI devices:
peng@ubuntu:~$ lsscsi
[3:0:0:0] cd/dvd NECVMWar VMware SATA CD01 1.00 /dev/sr0
[32:0:0:0] disk VMware, VMware Virtual S 1.0 /dev/sdaShow detailed attributes with -L:
peng@ubuntu:~$ lsscsi -L
[3:0:0:0] cd/dvd ... /dev/sr0
device_blocked=0
iocounterbits=32
...
[32:0:0:0] disk ... /dev/sda
device_blocked=0
iocounterbits=32
queue_depth=32
...Show human‑readable capacity with -s:
peng@ubuntu:~$ lsscsi -s
[3:0:0:0] cd/dvd ... /dev/sr0 -
[32:0:0:0] disk ... /dev/sda 536GBRelated SCSI File Nodes
Key locations in the Linux filesystem:
/proc/scsi/ – contains device_info, mptspi, scsi, sg directories.
/sys/class/scsi_host – lists host adapters (host0, host1, …).
/sys/class/scsi_device – shows devices by H:C:T:L identifiers.
/sys/class/scsi_disk – disk‑specific entries.
/sys/class/scsi_generic – generic SCSI device nodes (sg0, sg1, …).
/sys/bus/scsi – contains drivers and device trees.
Example of reading /proc/scsi/scsi:
Attached devices:
Host: scsi32 Channel: 00 Id: 00 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi3 Channel: 00 Id: 00 Lun: 00
Vendor: NECVMWar Model: VMware SATA CD01 Rev: 1.00
Type: CD-ROM ANSI SCSI revision: 05Enabling SCSI Logging for Debugging
To compile the kernel with SCSI logging support, enable CONFIG_SCSI_LOGGING in the kernel configuration. After boot, logging can be turned on via the /proc/sys/dev/scsi/logging_level interface.
Set the logging level (bitmask) to enable specific log types, for example:
# echo 0 > /proc/sys/dev/scsi/logging_level # disable all SCSI logs
# echo -1 > /proc/sys/dev/scsi/logging_level # enable all SCSI logs (send to syslog)The scsi_logging_level variable is a 32‑bit integer where each 3‑bit field represents a different logging category (error, ioctl, etc.). Adjust the bitmask according to the desired verbosity.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
