How does the kernel determine if a SCSI disk is HDD (rotational) or SSD (non-rotational)?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux (RHEL)

Issue

  • SSD drives have the rotational value within sysfs set to 1 versus the expected 0.

    # grep -Hv "zz" /sys/block/sd*/queue/rotational
    /sys/block/sda/queue/rotational:1
    /sys/block/sdb/queue/rotational:1
    /sys/block/sdc/queue/rotational:1
    
  • Is there a way to force the disk to be set to SSD vs HDD?

Resolution

  • The kernel determines whether a disk is rotational (HDD) or non-rotational (SDD) by a direct query of the disk using the SCSI INQUIRY command with a request for VPD (Vital Products Data) Page 0xB1. Page 0xB1 is the Block Characteristics (bdc) Page and, if supported, supplies a rotational value for the disk.

    • Use the sg_vpd --page=0xb1 /dev/sdX command to determine what the disk returns as rotation hints for the kernel.
      • If the page is not supported, returns a non-zero rotational value, or does not report a rotational value then the disk is set to rotational=1 (HDD).
      • If the page is supported and returns Non-rotating medium (e.g. solid state) as its rotational value, then it is set to rotational=0 (SDD).
  • There is no method of automatically forcing a disk marked as HDD (rotational=1) to be set to SSD (rotational=0) other than contacting the storage vendor to ascertain why VPD page 0xb1 is not being properly supplied.

NOTE   Many SSD devices may be behind a storage controller. When not directly attached to the system, the storage controller often assumes the responsibility for servicing SCSI VPD requests. And many such controllers do not support the VPD 0xB1 page. Check to see if the device is behind one of these common storage controllers whereby the SSD status is hidden from the kernel by the controller. The behavior of such controllers may be firmware version specific. Contact the hardware vendor for additional details. See the Diagnostics section below for additional information.
  • Smart Array (hpsa/smartpqi)
  • LSI RAID Controller (megaraid_sas)
  • DELLBOSS VD devices (RAID1 backplane controller)
    • In this case the DELL BOSS controller is a limited functionality RAID1 controller that mirrors two M2 SSD disks into on raid virtual disk (VD) and presents that VD as a SATA drive to the system.
  • VMware Virtual Disk(s)
  • For ATA devices (such as SATA drives), the kernel determines the device type based on the response from the IDENTIFY DEVICE command. Specifically, it uses the value of Word 217 (Nominal Media Rotation Rate).
    • SSD (Solid State Drive): The value is set to 0001h.
    • HDD (Hard Disk Drive): The value is a hexadecimal number representing the actual rotations per minute (rpm), in the range from 0401h to FFFEh (e.g., 7200 rpm is 1C20h).
    • Rate not reported: The value is set to 0000h.
    • This determination is reflected in the /sys/block/<device>/queue/rotational file, similar to SCSI devices. The value in this file is 1 for an HDD (a rotational device) and 0 for an SSD (a non-rotational device).

Diagnostic Steps

Using the sg_vpd (or sg_inq) command from the sg3_utils package can be done to determine what type of rotational value information is returned by storage to the kernel.

    1. sg_vpd --page=sv /dev/sdX ; determine if the VPD page 0xB1 is supported
    1. sg_vpd --page=bdc /dev/sdX ; determine the rotational value, if any, returned by the disk within this page

1. determine if the VPD page 0xB1 is supported
Example #1: controller|disk does not support VPD page 0xb1
# sg_vpd --page=sv /dev/sda
Supported VPD pages VPD page:
  Supported VPD pages [sv]
  Unit serial number [sn]
  Device identification [di]
  Date code (Seagate) [datc]

NOTE: no bdc (0xb1) page supported by this controller|disk, so kernel
defaults the disk to being rotational=1 (HDD). This can be a
common issue with backplane storage controllers.
NOTE: the sv (0x00) page simply requests the device to return the list
of VPD pages supported by this controller|disk.

Example #2: controller|disk supports VPD page 0xb1

sg_vpd --page=sv /dev/sda

Supported VPD pages VPD page:
Supported VPD pages [sv]
Unit serial number [sn]
Device identification [di]
ATA information (SAT) [ai]
Block limits (SBC) [bl]
Block device characteristics (SBC) [bdc] Logical block provisioning (SBC) [lbpv]

2. determine the rotational value, if any, returned by the disk within this page Example #1: VPD page 0xb1 not supported (HDD)

sg_vpd --page=bdc /dev/sda

fetching VPD page failed: Numerical argument out of domain sg_vpd failed: Numerical argument out of domain

Example #2: returns rotational value (HDD)

sg_vpd --page=bdc /dev/sda

Block device characteristics VPD page (SBC):
Nominal rotation rate: 7200 rpm Product type: Not specified
:

Example #3: returns no rotational value (HDD)

sg_vpd --page=0xb1 /dev/sda

Block device characteristics VPD page (SBC):
Medium rotation rate is not reported
Product type: Not specified
:

Example #4: returns non-rotating media value (SSD)

sg_vpd --page=0xb1 /dev/sda

Block device characteristics VPD page (SBC):
Non-rotating medium (e.g. solid state) Product type: Not specified
:

Unless the Non-rotating medium (e.g. solid state) is returned within VPD page 0xb1, then the kernel will set rotational=1 (HDD) for that disk.

From the SCSI specification on VPD page 0xB1, the following is the returned information with that page.


SCSI Inquiry 
VPD B1h  Block Device Characteristics (bdc)

bit→
↓byte 7 6 5 4 3 2 1 0
+-------+-------+-------+-------+-------+-------+-------+-------+
0 | Peripheral Qualifier | Peripheral Device Type(0h) |
+-------+-------+-------+-------+-------+-------+-------+-------+
1 | Page Code B1h |
+-------+-------+-------+-------+-------+-------+-------+-------+
2 | (MSB) |
+------- Page Length (003Ch) -------+
3 | (LSB) |
+-------+-------+-------+-------+-------+-------+-------+-------+
4 | (MSB) |
+------- Medium Rotation Rate -------+
5 | (LSB) |
+-------+-------+-------+-------+-------+-------+-------+-------+
6 | Product Type |
+-------+-------+-------+-------+-------+-------+-------+-------+
7 | WABEREQ | WACEREQ | Nominal Form Factor |
+-------+-------+-------+-------+-------+-------+-------+-------+
8 | Reserved |HAW_ZBC| Reserved | FUAB | VBULS |
+-------+-------+-------+-------+-------+-------+-------+-------+
9 | |
+------- -------+
: Reserved :
+------- -------+
63 | |
+-------+-------+-------+-------+-------+-------+-------+-------+

Medium Rotation Rate
Code Description
0000h Medium rotation not reported
0001h Non-rotating medium (e.g. solid state)
0002h-0400h Reserved
0401h-FFFEh Nominal medium rotation rate in revolutions per minute
(e.g. 7200rpm = 1C20h, 10k 2710h, 15k 3A98h ...)
FFFFh Reserved


This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.