You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEAT] PhysicalDisk: opt-in drive health (NVMe wear / available spare / SMART critical warning) #2726
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:
Is health as a PhysicalDisk option (off by default) the right approach, or would you prefer a separate module?
On Linux, is a D-Bus call to udisks2 acceptable for an opt-in field?
Are the field names and JSON keys above OK?
I'd start with macOS (smallest change), then Windows, then Linux.
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?
Activity
CarterLi commentedon Nov 16, 2026
Seems a good idea to me. As long as the performance cost of this feature is acceptable, I am ok to accept this.
giovannilentini commentedon Nov 16, 2026
Thanks I'll start working on it and then let you know.
PhysicalDisk: adds health option and result fields
DBus: supports calling methods with an empty a{sv} argument
PhysicalDisk (Linux): adds health detection via udisks2
PhysicalDisk: adds health option and result fields
DBus: supports calling methods with an empty a{sv} argument
PhysicalDisk (Linux): adds health detection via udisks2
PhysicalDisk: adds health option and result fields
DBus: supports calling methods with an empty a{sv} argument
PhysicalDisk (Linux): adds health detection via udisks2
PhysicalDisk (macOS): adds health detection
PhysicalDisk (Windows): adds health detection
PhysicalDisk (macOS): adds health detection
PhysicalDisk (Windows): adds health detection
giovannilentini commentedon Nov 17, 2026
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?
CarterLi commentedon Nov 18, 2026
Better to support it in both Windows and macOS
giovannilentini commentedon Nov 18, 2026
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
giovannilentini commentedon Nov 18, 2026
Ok, on Windows it seems to work without admin rights, but I could only test it in a VM. I wasn't able to test the SATA support on macOS.
PhysicalDisk (Linux): adds SMART failing status for ATA disks
PhysicalDisk (Windows): adds SMART failing status for ATA disks
PhysicalDisk (macOS): adds SMART failing status for ATA disks
PhysicalDisk (Linux): adds SMART failing status for ATA disks
PhysicalDisk (Windows): adds SMART failing status for ATA disks
PhysicalDisk (macOS): adds SMART failing status for ATA disks