Show wear level of SDcard + SSD (RPi)

How do I get the value of the wear level of my:

  • SSD and
  • SDCard ?
    on Raspberry Pi?

(I've seen someone a year ago on a dashboard to showing this value, but can not find where it was.)

Would be important to auto-send a notification if it's lowering.

Generally I don't think you can, unless I am out of date. Some devices may have that in the SMART data, others don't, or it is not understandable if it is there. See hard disk - How to check the life left in SSD or the medium's wear level? - Unix & Linux Stack Exchange

Your link had an important hint: smartmontool

Found this:

sudo apt install smartmontools

To check:

df 

This will list available devices. (I'm rather using an installed app: gnome-disks)

Now we can check SMART data:

sudo smartctl -i /dev/sda

And the result is:

smartctl 6.6 2017-11-05 r4594 [armv7l-linux-5.10.63-v7l+] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     ADATA SU800
Serial Number:    2I4420019349
LU WWN Device Id: 5 707c18 100700a9d
Firmware Version: R0427ANR
User Capacity:    128.035.676.160 bytes [128 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Form Factor:      2.5 inches
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ACS-3 T13/2161-D revision 5
SATA Version is:  SATA 3.3, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Sat Nov 27 15:57:22 2021 CET
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

Sadly it can not read any infos from my SD card:

sudo smartctl --identify /dev/mmcblk0

Gives only:

/dev/mmcblk0: Unable to detect device type
Please specify device type with the -d option.

And I don't think it tells you anything useful about the SSD either, does it?

To get ALL Smart info about a device:

sudo smartctl --all /dev/sda

Gives:

smartctl 6.6 2017-11-05 r4594 [armv7l-linux-5.10.63-v7l+] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     ADATA SU800
Serial Number:    2I4420019349
LU WWN Device Id: 5 707c18 100700a9d
Firmware Version: R0427ANR
User Capacity:    128.035.676.160 bytes [128 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Form Factor:      2.5 inches
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ACS-3 T13/2161-D revision 5
SATA Version is:  SATA 3.3, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Sat Nov 27 16:45:54 2021 CET
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART Status not supported: Incomplete response, ATA output registers missing
SMART overall-health self-assessment test result: PASSED
Warning: This result is based on an Attribute check.

General SMART Values:
Offline data collection status:  (0x80)	Offline data collection activity
					was never started.
					Auto Offline Data Collection: Enabled.
Self-test execution status:      (   0)	The previous self-test routine completed
					without error or no self-test has ever 
					been run.
Total time to complete Offline 
data collection: 		(    0) seconds.
Offline data collection
capabilities: 			 (0x7b) SMART execute Offline immediate.
					Auto Offline data collection on/off support.
					Suspend Offline collection upon new
					command.
					Offline surface scan supported.
					Self-test supported.
					Conveyance Self-test supported.
					Selective Self-test supported.
SMART capabilities:            (0x0002)	Does not save SMART data before
					entering power-saving mode.
					Supports SMART auto save timer.
Error logging capability:        (0x01)	Error logging supported.
					General Purpose Logging supported.
Short self-test routine 
recommended polling time: 	 (   2) minutes.
Extended self-test routine
recommended polling time: 	 (  30) minutes.
Conveyance self-test routine
recommended polling time: 	 (   2) minutes.
SCT capabilities: 	       (0x0035)	SCT Status supported.
					SCT Feature Control supported.
					SCT Data Table supported.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x0000   100   100   000    Old_age   Offline      -       0
  5 Reallocated_Sector_Ct   0x0000   100   100   000    Old_age   Offline      -       0
  9 Power_On_Hours          0x0000   100   100   000    Old_age   Offline      -       1027
 12 Power_Cycle_Count       0x0000   100   100   000    Old_age   Offline      -       118
148 Unknown_Attribute       0x0000   100   100   000    Old_age   Offline      -       329
149 Unknown_Attribute       0x0000   100   100   000    Old_age   Offline      -       41
150 Unknown_Attribute       0x0000   100   100   000    Old_age   Offline      -       3
151 Unknown_Attribute       0x0000   100   100   000    Old_age   Offline      -       21
159 Unknown_Attribute       0x0000   100   100   000    Old_age   Offline      -       0
160 Unknown_Attribute       0x0000   100   100   000    Old_age   Offline      -       0
161 Unknown_Attribute       0x0000   100   100   000    Old_age   Offline      -       33
163 Unknown_Attribute       0x0000   100   100   000    Old_age   Offline      -       24
164 Unknown_Attribute       0x0000   100   100   000    Old_age   Offline      -       11585
165 Unknown_Attribute       0x0000   100   100   000    Old_age   Offline      -       42
166 Unknown_Attribute       0x0000   100   100   000    Old_age   Offline      -       11
167 Unknown_Attribute       0x0000   100   100   000    Old_age   Offline      -       25
168 Unknown_Attribute       0x0000   100   100   000    Old_age   Offline      -       1500
169 Unknown_Attribute       0x0000   100   100   000    Old_age   Offline      -       99
177 Wear_Leveling_Count     0x0000   100   100   050    Old_age   Offline      -       0
181 Program_Fail_Cnt_Total  0x0000   100   100   000    Old_age   Offline      -       0
182 Erase_Fail_Count_Total  0x0000   100   100   000    Old_age   Offline      -       0
192 Power-Off_Retract_Count 0x0000   100   100   000    Old_age   Offline      -       60
194 Temperature_Celsius     0x0000   100   100   000    Old_age   Offline      -       37
195 Hardware_ECC_Recovered  0x0000   100   100   000    Old_age   Offline      -       0
196 Reallocated_Event_Count 0x0000   100   100   016    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0000   100   100   050    Old_age   Offline      -       0
232 Available_Reservd_Space 0x0000   100   100   000    Old_age   Offline      -       100
241 Total_LBAs_Written      0x0000   100   100   000    Old_age   Offline      -       22798
242 Total_LBAs_Read         0x0000   100   100   000    Old_age   Offline      -       19695
245 Unknown_Attribute       0x0000   100   100   000    Old_age   Offline      -       104265

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged.  [To run self-tests, use: smartctl -t]

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Completed [00% left] (0-65535)
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

But is any of that what you are looking for?

This is useful information .. especially the Read Errors, Reallocated Sectors and possibly the Power On hours.

can you use --json with that utility ?

Yes of course !

Reallocated_Sector_Ct   = 0
Wear_Leveling_Count    = 0
Available_Reservd_Space = RAW 100
Temperature_Celsius     = RAW 37

These 4 are the most important ones to watch.
If Wear_Leveling_Count grows or
Available_Reservd_Space reducing from 100 radically,
than we have a big problem and need a popup warning or even voice alert.

If Temp > 40 °C than most SSDs can damage much faster and usually fail if >50 °C

I don't think it will be necessary.
There is an extensive documentation about how to use alllllll those parameters.
I have the feeling it is possible to ask those important values one by one.

https://www.smartmontools.org/browser/trunk/smartmontools/smartctl.8.in

are you planning to pass this information in node-red? .. thats why i was asking about json

[reading the link] nice .. its well documented

I've understood your question :slight_smile:
I don't know yet what will be the best method to analyse the text with Node-Red.
I have not many experience yet how to convert some text to json with NR or node.js or javascript.

I thought wear levelling count started at 100 and went down.

It depends on the brand of the SSD.
https://www.smartmontools.org/wiki/FAQ#TheSSD_Life_LeftAttributeofmynewSandForcebasedSSDreportszero

Yours is showing 100 not 0, unless you are looking at the RAW field. I think it is generally best to look at the Value field, which should be normalised to give you a percentage still available.

Most of the FAQ and doc on that page recommends that too.
They are already pushing lot's of effort to deal with different manufacturer's calculations.
(It's a pity it is not standardized more generally.)

But it will give wrong number, if you ask for an "optimised number" of a manufacturer it can not handle well.
So I think NR node should give both 4 values and the user should decide what to do with those.

Help needed:

I'm still looking what type of controller is handling the SD card.

I think these controllers are supported:
https://www.smartmontools.org/wiki/Supported_RAID-Controllers

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.