Inspect SCSI VPD Pages Safely with sg_vpd

sg_vpd asks a SCSI device which Vital Product Data (VPD) pages it supports, then decodes the ones that matter, such as device identification. It opens the device read-only and issues SCSI INQUIRY commands, but it still talks directly to storage hardware, so check the device path before running it. It can also save a raw response for later analysis.

This guide follows the locally installed sg_vpd from sg3_utils 1.46, whose program reports version 1.63 (20210328).

1. Confirm the program and identify the device

Check the installed program before troubleshooting output from a different machine. Then identify the intended disk or generic SCSI device using your normal inventory tools. Replace the placeholder below; do not paste it unchanged.

sg_vpd --version
lsblk -o NAME,MODEL,SERIAL,TYPE
sg_vpd /dev/sdX

The final command fetches page 0x00, called Supported VPD pages, when no page option is supplied. Typical output names pages with short abbreviations, for example di for Device identification and ei for Extended inquiry data. The installed command reports version: 1.63 20210328 on this system.

Checkpoint: Stop if the page list is for the wrong disk, or if the device returns an error. Confirm the path and transport first. A failed probe is not evidence that another disk is safe to query.

2. Find a page by name and decode it

Use --enumerate to see the page abbreviations known to this build. It does not need a device and exits after listing names. This is useful when a document gives a page number but you want to find the matching decoder.

sg_vpd --enumerate | less
sg_vpd --page=di /dev/sdX
sg_vpd --page=ei --long /dev/sdX

A page is normally checked against page 0 first. If a device omits a page from its supported list but you have a reason to query it, --force bypasses that check.

Safety boundary: Use --force sparingly. The manual warns that the preliminary page-0 check has crashed certain USB devices, but skipping it can also send a request the device does not support. Test unusual USB bridges on a non-critical device first.

3. Control the response size on unreliable hardware

By default, the utility requests up to 252 bytes and can issue another INQUIRY when the response says more is available. The ATA Information VPD page uses a 572-byte default. Some simple devices implement INQUIRY badly, so a small explicit allocation length can be safer.

sudo sg_vpd --page=di --maxlen=36 /dev/sdX

With a positive --maxlen, only one INQUIRY is sent. The locally installed manual describes 36 as the safest value for many basic devices, although it may truncate a page. Use this as a compatibility probe, not as a promise that every field will be present.

Checkpoint: If the command succeeds with --maxlen=36 but not with the default, record the bridge or enclosure model and keep the smaller request for that hardware. Do not interpret missing trailing fields as proof that the device has no such data.

4. Capture raw data for later decoding

Use --hex when you want a human-readable hexadecimal view. Four H characters, written as -HHHH, produce unadorned hexadecimal suitable for a later --inhex invocation. Redirect it to a new file rather than overwriting an existing capture.

sg_vpd --page=di -HHHH /dev/sdX > device-identification.hex
sg_vpd --page=di --inhex=device-identification.hex
sg_vpd --all -HHHH /dev/sgN > all-vpds.hex
sg_vpd --all --inhex=all-vpds.hex

The file input is treated as ASCII hexadecimal by default. Whitespace or commas may separate bytes, and text from a hash mark to the end of a line is ignored. If you capture binary instead, both the capture and replay commands need --raw:

sg_vpd --all --raw /dev/sgN > all-vpds.bin
sg_vpd --all --raw --inhex=all-vpds.bin

Recovery: These commands only create or replace the named output through shell redirection. If a path already contains valuable evidence, choose a different filename. To discard a capture, remove that specific file after confirming its path, for example rm -- all-vpds.hex; sg_vpd itself does not alter the device.

5. Investigate pages that are not advertised

Some vendors fail to list standard pages or leave vendor-specific pages out of page 0. --examine scans for pages instead of trusting that list. Once, without a page limit, it scans 0x80 through 0xff. With --examine twice, it starts at page 0x00. Adding --page=0xbf limits a single scan to 0x80 through 0xbf, excluding the usual vendor-specific range above it.

sudo sg_vpd --examine --page=0xbf /dev/sdX
sg_vpd --page=0xb0 --enumerate

The second command lists known page names sharing number 0xb0. This matters for vendor-specific interpretations, because the same numeric page can mean different things for different products. The --vendor=VP option selects a known vendor or vendor/product acronym. The manual also documents a special value that lists the available acronyms; check sg_vpd --help on the installed build before using it in a script.

Common failure patterns

Done means