Home / Alt manpages / proc_scsi(5)

  • proc_scsi(5)
  • File format
  • linux

Inspect Linux SCSI State Through /proc/scsi

This guide shows you how to inspect the SCSI devices that the kernel knows about, find driver-specific host data, and, when there is a genuine need, ask one SCSI host to scan a specific address. It uses the /proc/scsi/ interface documented by Linux man-pages 6.7, installed here as the Debian manpages package version 6.7-2.

Allow about 10 minutes. The reading steps are normally unprivileged. The scan step writes to a kernel pseudo-file, needs root, and can change the devices visible to the system. Do not use it as a general storage rescan or paste an address from an untrusted source.

1. Confirm the interface exists

The /proc filesystem must be mounted, and the SCSI mid-layer must have created its directory. Check both without changing anything:

$ findmnt -T /proc/scsi -o TARGET,FSTYPE,OPTIONS
TARGET FSTYPE OPTIONS
/proc  proc   rw,relatime

$ test -d /proc/scsi && echo "/proc/scsi is present" || echo "/proc/scsi is missing"

Expected output has a proc filesystem for the first command and a present directory for the second. A missing directory is not evidence that a disk is faulty. Check that /proc is mounted and that the running kernel exposes the interface before changing storage configuration.

Checkpoint

Stop here if the directory is missing. Do not create /proc/scsi by hand. It is a kernel-provided interface, not an ordinary configuration directory.

2. Read the kernel's SCSI device list

/proc/scsi/scsi lists the SCSI devices currently known to the kernel. Read it as the current kernel view, not as a complete inventory of every physical disk or enclosure:

$ sed -n '1,80p' /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
  Vendor: ATA      Model: EXAMPLE-DISK Rev: 1.0
  Type:   Direct-Access                    ANSI SCSI revision: 05

The four address fields are the host, channel, target ID and logical unit number. In the example, the address is host 1, channel 0, ID 0, LUN 0. The model and vendor lines help you compare this output with the hardware you expect, but they are not a substitute for checking stable device identifiers under /dev/disk/by-id/.

Output varies with the machine. SATA or SAS disks may appear as SCSI devices because the kernel storage stack presents them through SCSI-compatible layers. An empty list can be valid on a system with no attached SCSI devices. It can also mean that a controller or transport has not discovered its devices, so compare with kernel logs and your normal storage tools before assuming absence.

3. Find driver-specific host files

The manpage describes driver directories below /proc/scsi/. Each registered low-level driver may have one file per host. List the tree and inspect small files without writing to them:

$ find /proc/scsi -maxdepth 2 -type f -print
/proc/scsi/scsi
/proc/scsi/sg/debug
/proc/scsi/sg/devices

$ for file in /proc/scsi/sg/debug /proc/scsi/sg/version; do
>     [ -r "$file" ] && { echo "--- $file"; sed -n '1,20p' "$file"; }
> done

The exact names depend on the kernel and loaded drivers. Files under a driver directory commonly expose configuration, counters or status. The local sg files, for example, describe the generic SCSI device layer and its version. Treat these files as diagnostics: the manpage says that some files accept commands, but each driver defines its own write behaviour.

Checkpoint

Use cat or sed only while you are learning the layout. Do not redirect output to a file under /proc/scsi/ unless the relevant driver documentation explicitly tells you which command is supported.

4. Scan one address only when required

The documented write interface for /proc/scsi/scsi supports add-single-device. It asks a particular host to scan one channel, target ID and LUN. This is useful for a hotplugged device that the kernel has not listed yet:

$ sudo sh -c 'printf "%s\n" "scsi add-single-device HOST CHANNEL ID LUN" > /proc/scsi/scsi'

Replace every capitalised placeholder with a verified decimal value. For example, to scan host 1, channel 0, ID 5, LUN 0, the exact command is:

$ sudo sh -c 'printf "%s\n" "scsi add-single-device 1 0 5 0" > /proc/scsi/scsi'

This is the only write command described by this installed manpage. The command needs elevated privileges because it changes kernel device discovery. It may cause a new block device to appear and can trigger normal udev and storage events. Verify the cabling, controller mapping and address first. A wrong address can return an error, but a valid address can still identify a different device than you intended.

Check the result immediately:

$ sed -n '1,120p' /proc/scsi/scsi
$ find /dev/disk/by-id -maxdepth 1 -type l -printf '%f -> %l\n' 2>/dev/null | sort

If the list is unchanged, read the command's error, check the host and address, and inspect kernel messages with your normal logging tools. Do not repeat the write blindly. There is no documented undo command in proc_scsi(5). If you added the wrong device, stop using it, preserve any needed data, and use the controller, kernel and distribution-specific device-removal procedure. A reboot may clear a temporary discovery change, but it is not a substitute for safely unmounting filesystems or stopping services that use the device.

Common traps

  • Confusing a missing path with a missing disk: /proc/scsi/ reflects kernel interfaces and registered drivers, not a physical inventory database.
  • Assuming every file is readable only: the directory contains status files, but some files accept driver-specific writes. Read the relevant driver documentation before sending input.
  • Using the wrong address: host numbering is assigned during initialisation and is not a portable disk label. Recheck the current listing on the same boot.
  • Expecting this interface to configure modern storage: the manpage documents a narrow scan operation. Prefer the storage subsystem's documented tools for multipath, RAID, enclosures and persistent naming.

Done means

  • /proc/scsi exists and you know whether proc is mounted.
  • You can read /proc/scsi/scsi and identify each listed host, channel, ID and LUN.
  • You checked driver-specific files without writing unsupported input.
  • If you performed a scan, it used a verified address, was run with sudo, and the resulting device list was checked.