Skip to content

[FEAT] PhysicalDisk: opt-in drive health (NVMe wear / available spare / SMART critical warning) #2726

Open

Description

@giovannilentini

Description

Add an opt-in drive health readout to the PhysicalDisk module, next to the existing temp option. The data would come from SMART / the NVMe health log.

Proposed option (off by default, like temp):

{ "type": "physicaldisk", "temp": true, "health": true }

New format args. Each one is left empty when the data isn't available:

Arg Source Example
{health} 100 − NVMe Percentage Used (same value GNOME Disks / CrystalDiskInfo show as health) 97%
{percent-used} NVMe Percentage Used (raw) 3%
{available-spare} NVMe Available Spare 100%
{critical-warning} NVMe Critical Warning bits / ATA SMART overall status none, spare below threshold, failing

Example output (default format would only show the warning when it isn't "none"):

Physical Disk (Lexar SSD NM620 256GB): 238.47 GiB [SSD, NVMe] - 35°C - Health 97%
Physical Disk (WDC WD20EZRZ):          1.82 TiB [HDD, SATA] - SMART failing

Possible sources without root:

  • macOS: physicaldisk_apple.c already calls SMARTReadData() for the temperature. The same NVMeSMARTData struct has CRITICAL_WARNING, PERCENTAGE_USED and AVAILABLE_SPARE, so NVMe support adds almost nothing.
  • Windows: IOCTL_STORAGE_QUERY_PROPERTY (already used for StorageDeviceTemperatureProperty) with StorageDeviceProtocolSpecificProperty / NVMeDataTypeLogPage for the NVMe SMART log. Fallback: MSFT_PhysicalDisk.HealthStatus via WMI.
  • Linux: reading SMART directly (SG_IO, NVMe admin commands) needs root. udisks2 exposes it over D-Bus without root: org.freedesktop.UDisks2.Drive.Ata.SmartFailing for ATA. For NVMe (udisks ≥ 2.10), the org.freedesktop.UDisks2.NVMe.Controller interface has the SmartCriticalWarning property, and the SmartGetAttributes() method returns percent_used, avail_spare and media_errors. I tested this as a normal user on Fedora with two NVMe drives:
    $ busctl --system call org.freedesktop.UDisks2 /org/freedesktop/UDisks2/drives/Lexar_SSD_NM620_256GB_... \
        org.freedesktop.UDisks2.NVMe.Controller SmartGetAttributes 'a{sv}' 0
    ... "avail_spare" y 100 ... "percent_used" y 3 ... "media_errors" t 0 ...
    
    This would use the existing optional ENABLE_DBUS support, and the fields would just stay empty when udisks isn't running.
  • BSD / others: not supported at first.

Motivation

Drive wear and pending failure are hardware-level facts that fit next to size, type and temperature. NVMe wear in particular is something users want to see at a glance.

Why Command doesn't do the job:

  • smartctl needs root for most devices, so a command module running smartctl fails or prompts for sudo.
  • The output differs between platforms and between ATA and NVMe, so a portable script is fragile.
  • Spawning smartctl once per disk is much slower than reading data fastfetch already partly fetches (macOS, Windows).

Additional context

Questions for the maintainers before I start on a PR:

  1. Is health as a PhysicalDisk option (off by default) the right approach, or would you prefer a separate module?
  2. On Linux, is a D-Bus call to udisks2 acceptable for an opt-in field?
  3. Are the field names and JSON keys above OK?

I'd start with macOS (smallest change), then Windows, then Linux.

Activity

  1. CarterLi commented on Nov 16, 2026

    @CarterLi
    Member

    Seems a good idea to me. As long as the performance cost of this feature is acceptable, I am ok to accept this.

  2. giovannilentini commented on Nov 16, 2026

    @giovannilentini
    ContributorAuthor

    Thanks I'll start working on it and then let you know.

  3. giovannilentini commented on Nov 17, 2026

    @giovannilentini
    ContributorAuthor

    Thanks for merging #2728 and #2731. I have one small follow-up ready on Linux, ATA/SATA disks report the SMART "failing" status (from udisks2) as a failing critical warning. There's no standard wear percentage for SATA, so that's the only thing it adds. Should that PR close this issue, or would you rather close it now?

  4. CarterLi commented on Nov 18, 2026

    @CarterLi
    Member

    I have one small follow-up ready on Linux, ATA/SATA disks report the SMART "failing" status (from udisks2) as a failing critical warning

    Better to support it in both Windows and macOS

  5. giovannilentini commented on Nov 18, 2026

    @giovannilentini
    ContributorAuthor

    Ok ok I'll try. My only concern is whether those OSs need admin rights for the SATA SMART status, but in any case I'll let you know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions