LinuxCommandLibrary

lsscsi

List SCSI devices (or hosts) and attributes

TLDR

List all SCSI devices

$ lsscsi
copy

List all SCSI devices with detailed attributes
$ lsscsi [[-L|--list]]
copy

List all SCSI devices with human-readable disk capacity
$ lsscsi [[-s|--size]]
copy

SYNOPSIS

lsscsi [options]

PARAMETERS

-g, --generic
    Shows the associated SCSI generic (sg) device name, e.g., /dev/sg0.

-G, --gbytes
    For storage devices, shows the capacity in Gibibytes (GiB) instead of bytes.

-h, --help
    Displays a short help message and exits.

-H, --hosts
    Lists SCSI host adapters only, without showing individual SCSI devices.

-k, --kname
    Shows the kernel device name (e.g., sda) or sg device name (e.g., sg0), which is the default behavior.

-L, --lun
    Displays the LUN field in hexadecimal format.

-l, --list
    Outputs device attributes one per line, useful for scripting or detailed inspection.

-p, --protection
    Shows protection information (DIF/DIX) for devices that support it.

-P, --parse
    Parses the output of the lsscsi command itself, intended for internal use or complex scripting.

-r, --raw
    Displays the raw SCSI peripheral device type code (e.g., 0 for disk, 5 for CD/DVD).

-s, --size
    For storage devices, shows their capacity in bytes.

-S, --scsifs
    Uses the older /proc/scsi/scsi file system for device information, primarily for compatibility with older kernels. Defaults to sysfs.

-t, --tree
    Displays devices in a tree-like format, showing the host and device hierarchy.

-T, --transport
    Shows transport specific information for SCSI devices (e.g., SAS address, iSCSI details).

-U, --unit
    Includes the LUN as part of the peripheral device name (e.g., sda[0]).

-v, --verbose
    Increases verbosity, displaying additional details such as kernel driver and device node paths.

-V, --version
    Prints the version information of the lsscsi command and exits.

-w, --wwn
    Displays the World Wide Name (WWN) for devices that provide it, typically for Fibre Channel or SAS devices.

DESCRIPTION

The lsscsi command lists SCSI devices (or hosts) connected to the system. It queries the Linux sysfs file system (typically mounted at /sys) to gather detailed information about each device. This includes the SCSI host adapter, channel, target ID, and LUN (Logical Unit Number), often represented as [H:C:T:L]. For each device, it typically displays the vendor, product, revision, device type (e.g., disk, CD/DVD, tape, processor), and the associated block device name (e.g., /dev/sda) or SCSI generic (sg) device name (e.g., /dev/sg0).

lsscsi is an invaluable tool for system administrators to quickly inventory and verify the presence and configuration of SCSI-based storage, optical drives, or other SCSI peripherals. Its output helps in understanding the SCSI topology, identifying specific hardware components, and correlating them with their respective device nodes in the /dev directory. It can also show devices that are not yet 'ready' or are currently in a state of flux.

CAVEATS

lsscsi primarily relies on the Linux sysfs file system for information. If sysfs is not properly mounted (typically at /sys) or if device information is incomplete within sysfs, lsscsi's output may be limited or inaccurate. On very old kernel versions where sysfs support might be limited, the --scsifs option might be necessary to query /proc/scsi/scsi. The command only reports detected devices; it does not perform any device discovery or configuration.

OUTPUT FORMAT

The default output of lsscsi typically displays columns for host, channel, target, and LUN (e.g., [H:C:T:L]), followed by the vendor, product, revision, SCSI device type (e.g., disk, CD/DVD), and the associated kernel device name (e.g., /dev/sda or /dev/sr0). Other options can alter or add to these columns.

USAGE EXAMPLES

To list all SCSI devices with their block device names: lsscsi
To list all SCSI devices with their SCSI generic device names: lsscsi -g
To list only SCSI host adapters: lsscsi -H
To show device capacity: lsscsi -s
To show devices in a tree-like format: lsscsi -t

HISTORY

lsscsi is part of the sg3_utils package, a suite of utilities for sending SCSI commands. It was developed by Doug Gilbert. Its primary purpose was to provide a more structured and user-friendly way to list SCSI devices on Linux systems, moving beyond direct parsing of the older /proc/scsi/scsi interface to leverage the more robust and standardized sysfs file system (introduced around Linux 2.6). It became a de-facto standard for quickly inventorying SCSI hardware due to its simple syntax and clear output.

SEE ALSO

sg_scan(8), scsi_id(8), lsblk(8), fdisk(8), parted(8), hwinfo(8)

Copied to clipboard