Skip to main content

yuce.me

NVMe Health on OpenBSD

Typst on OpenBSD

I’m using a Thinkpad X1 Carbon Gen 7 as my OpenBSD laptop. This laptop has a 256GB NVMe drive, and today I got curious about the health of it. It’s not a young machine, and on top of that, I bought it used, so I have no idea how it was treated in its previous life. If the drive is getting bad, I want to know about it sooner, rather than later.

Smartmontools is a software bundle that consists of the smartctl and smartd utilities. Smartmontools supports a wide variety of disks, but I am after using it with my NVMe drive.

There’s a nice OpenBSD package (like almost always) for smartmontools. Installing smartmontools is just:

doas pkg_add smartmontools

And you have smartctl and a service that runs smartd installed (but not enabled).

Using smartctl could not be easier. First, get a list of drives:

$ doas smartctl --scan
/dev/sd0c -d nvme # /dev/sd0c, NVMe device

Then, use the -H flag to check the health of the drive:

$ doas smartctl -H /dev/sd0c
smartctl 7.4 2023-08-01 r5530 [OpenBSD 7.7 amd64] (local build)
Copyright (C) 2002-23, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

Phew, it seems the drive is healthy!

Using the -a flag prints all information about the drive, including its health:

$ doas smartctl -a /dev/sd0c
smartctl 7.4 2023-08-01 r5530 [OpenBSD 7.7 amd64] (local build)
Copyright (C) 2002-23, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Number:                       KXG6AZNV256G TOSHIBA
Serial Number:                      XXXXXXXXXXXX
Firmware Version:                   5108AGLA
PCI Vendor/Subsystem ID:            0x1179
IEEE OUI Identifier:                0x8ce38e
Total NVM Capacity:                 256,060,514,304 [256 GB]
Unallocated NVM Capacity:           0
Controller ID:                      0
NVMe Version:                       1.3
Number of Namespaces:               1
Local Time is:                      Fri Jul 11 21:12:05 2025 +03
Firmware Updates (0x14):            2 Slots, no Reset required
Optional Admin Commands (0x001f):   Security Format Frmw_DL NS_Mngmt Self_Test
Optional NVM Commands (0x005f):     Comp Wr_Unc DS_Mngmt Wr_Zero Sav/Sel_Feat Timestmp
Log Page Attributes (0x0e):         Cmd_Eff_Lg Ext_Get_Lg Telmtry_Lg
Maximum Data Transfer Size:         512 Pages
Warning  Comp. Temp. Threshold:     78 Celsius
Critical Comp. Temp. Threshold:     82 Celsius

Supported Power States
St Op     Max   Active     Idle   RL RT WL WT  Ent_Lat  Ex_Lat
 0 +     8.00W       -        -    0  0  0  0        1       1
 1 +     3.90W       -        -    1  1  1  1        1       1
 2 +     2.00W       -        -    2  2  2  2        1       1
 3 -   0.0500W       -        -    3  3  3  3     1500    1500
 4 -   0.0050W       -        -    4  4  4  4     6000   14000
 5 -   0.0030W       -        -    5  5  5  5    50000   80000

=== START OF SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

SMART/Health Information (NVMe Log 0x02)
Critical Warning:                   0x00
Temperature:                        43 Celsius
Available Spare:                    100%
Available Spare Threshold:          10%
Percentage Used:                    2%
Data Units Read:                    3,844,077 [1.96 TB]
Data Units Written:                 3,099,013 [1.58 TB]
Host Read Commands:                 43,110,455
Host Write Commands:                52,819,996
Controller Busy Time:               153
Power Cycles:                       272
Power On Hours:                     439
Unsafe Shutdowns:                   106
Media and Data Integrity Errors:    0
Error Information Log Entries:      2
Warning  Comp. Temperature Time:    0
Critical Comp. Temperature Time:    0
Temperature Sensor 1:               43 Celsius

Error Information (NVMe Log 0x01, 16 of 256 entries)
No Errors Logged

Self-test Log (NVMe Log 0x06)
Self-test status: No self-test in progress
No Self-tests Logged

There are more about smartctl, but those were the most useful stuff for me at the first glance.