Linux command
sg_inq 命令
安全
权限或系统影响较大,执行前请核对目标。
常用示例
Query SCSI device
sudo sg_inq [/dev/sda]
Get device identification
sudo sg_inq --id [/dev/sda]
Display VPD page
sudo sg_inq --vpd --page=[0x83] [/dev/sda]
Output response in hexadecimal
sudo sg_inq --hex [/dev/sda]
Decode version descriptors
sudo sg_inq --descriptors [/dev/sda]
Query ATA device
sudo sg_inq --ata [/dev/sda]
Output in JSON format
sudo sg_inq --json [/dev/sda]
Decode INQUIRY data from file
sg_inq --inhex=[path/to/file.hex]
说明
sg_inq sends a SCSI INQUIRY command to a device and outputs the decoded response. All SCSI devices are required to respond to a standard INQUIRY command with at least 36 bytes containing vendor, product, and revision information. The utility supports Vital Product Data (VPD) pages which provide additional information such as device serial number (page 0x80), device identification with WWN (page 0x83), and block device characteristics. The --id option specifically decodes the device identification page which is mandatory for SPC-3 compliant devices. Beyond SCSI, sg_inq can query ATA/ATAPI devices using the --ata option and NVMe devices where it sends an Identify controller NVMe Admin command. This makes it useful for querying various storage device types on Linux systems.
参数
- -a, --ata
- Treat device as ATA/ATAPI and use ATA IDENTIFY command instead of SCSI INQUIRY.
- -B, --block=_0|1_
- Control blocking mode when opening device. 0 for non-blocking, 1 for blocking.
- -c, --cmddt
- Set Command Support Data bit for opcode queries. Obsolete in SPC-2.
- -d, --descriptors
- Decode version descriptors from the INQUIRY response.
- -e, --vpd
- Enable Vital Product Data bit to fetch VPD pages.
- -f, --force
- Skip sanity checks before accessing VPD pages.
- -H, --hex
- Output response in hexadecimal format.
- -i, --id
- Decode device identification VPD page (0x83).
- -I, --inhex=_FN_
- Decode INQUIRY response from file instead of querying device.
- -j, --json=_JO_
- Output in JSON format.
- -l, --len=_LEN_
- Set allocation length for response buffer.
- -o, --only
- Only output standard INQUIRY response, skip serial number VPD.
- -p, --page=_PG_
- Specify VPD page number or abbreviation to fetch.
- -q, --quiet
- Suppress decoding output and errors.
- -r, --raw
- Output response in binary format.
- -s, --vendor
- Display vendor-specific fields as ASCII.
- -v, --verbose
- Increase verbosity level.
- -V, --version
- Display version information.
FAQ
What is the sg_inq command used for?
sg_inq sends a SCSI INQUIRY command to a device and outputs the decoded response. All SCSI devices are required to respond to a standard INQUIRY command with at least 36 bytes containing vendor, product, and revision information. The utility supports Vital Product Data (VPD) pages which provide additional information such as device serial number (page 0x80), device identification with WWN (page 0x83), and block device characteristics. The --id option specifically decodes the device identification page which is mandatory for SPC-3 compliant devices. Beyond SCSI, sg_inq can query ATA/ATAPI devices using the --ata option and NVMe devices where it sends an Identify controller NVMe Admin command. This makes it useful for querying various storage device types on Linux systems.
How do I run a basic sg_inq example?
Run `sudo sg_inq [/dev/sda]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -a, --ata do in sg_inq?
Treat device as ATA/ATAPI and use ATA IDENTIFY command instead of SCSI INQUIRY.