smartctl output explained and usage examples
What is smartctl
smartctl
is a powerful tool for monitoring the health and performance of your storage devices, helping to prevent data loss by providing early warnings of potential drive failures.
smartctl
is a command-line utility that is part of the SMART Monitoring Tools (smartmontools) package. It is used to control and monitor storage devices using the Self-Monitoring, Analysis, and Reporting Technology (SMART) system built into most modern hard drives (HDDs) and solid-state drives (SSDs). smartctl
can provide detailed information about the health and performance of these drives, which can help in diagnosing potential issues and predicting drive failures.
Key Features of smartctl
- SMART Status: Check the overall health status of the drive.
- Attributes: Retrieve detailed SMART attributes, such as read error rates, power-on hours, temperature, and more.
- Self-tests: Run built-in self-tests on the drive to check for errors.
- Error Logs: Access and display the error logs maintained by the drive.
- Device Information: Display detailed information about the drive, including model number, serial number, firmware version, and more.
Common smartctl
Commands
To get a quick overview of a drive’s health status and attributes, you can run:
smartctl -a /dev/sdX
This command will display all available information about the drive, including health status, attributes, self-test results, and error logs.
Check Health Status:
smartctl -H /dev/sdX
Checks the overall health status of the drive (replace /dev/sdX with the appropriate device identifier).
Display SMART Attributes:
smartctl -A /dev/sdX
Displays detailed SMART attributes of the drive.
Run a Short Self-Test:
smartctl -t short /dev/sdX
Initiates a short self-test on the drive.
Run an Extended Self-Test:
smartctl -t long /dev/sdX
Initiates a longer and more thorough self-test on the drive.
Display Device Information:
smartctl -i /dev/sdX
Displays detailed information about the drive.
Display Error Logs:
smartctl -l error /dev/sdX
Displays the error logs from the drive.
Install smartctl
Ubuntu/Debian:
sudo apt-get install smartmontools
CentOS/RHEL:
sudo yum install smartmontools
Arch Linux:
sudo pacman -S smartmontools
MacOS:
brew install smartmontools
smartctl test type explained
smartctl
can perform various types of tests on storage devices to assess their health and performance. Here are the primary test types it offers:
1. Short Self-Test (-t short
)
- Purpose: Quickly checks the most common problems with the drive.
- Duration: Typically takes a few minutes (usually 1-2 minutes).
- Scope: Tests electrical properties, the read/write head, and a small portion of the surface.
- Use Case: Useful for quick diagnostics and regular checks.
2. Long Self-Test (-t long
)
- Purpose: Thoroughly checks the entire surface of the drive and all internal functions.
- Duration: Can take several hours depending on the size and speed of the drive.
- Scope: Comprehensive test that includes all aspects of the short test but covers the entire surface.
- Use Case: Ideal for in-depth diagnostics, periodic health checks, or when problems are suspected.
3. Conveyance Self-Test (-t conveyance
)
- Purpose: Designed to detect damage incurred during transport of the device.
- Duration: Typically takes a few minutes (around 5 minutes).
- Scope: Focuses on areas likely to be affected by physical transport.
- Use Case: Useful for newly shipped drives to ensure they have not been damaged during shipping.
4. Selective Self-Test
- Purpose: Allows testing of specific ranges of the drive’s surface.
- Duration: Variable, depends on the size of the selected range and drive speed.
- Scope: User-defined segments of the drive.
- Use Case: Targeted diagnostics, particularly if specific sections are suspected to have issues.
5. Offline Data Collection
- Purpose: Performs background tests and updates SMART attributes without impacting normal drive operation.
- Duration: Runs continuously in the background, may pause during heavy I/O operations.
- Scope: Varies based on the drive’s capabilities and the tests it performs.
- Use Case: Continuous monitoring and data collection for proactive health assessment.
Command Usage Example
To perform a short self-test on a drive, you would use the following command:
smartctl -t short /dev/sdX
Here, /dev/sdX
represents the device identifier for the drive you wish to test (e.g., /dev/sda
).
By running these tests periodically, you can monitor the health of your storage devices and preemptively address potential failures.
Sample smartctl output and explanation
$ smartcl -a /dev/sdb
...
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000b 100 100 016 Pre-fail Always - 0
2 Throughput_Performance 0x0004 129 129 054 Old_age Offline - 112
3 Spin_Up_Time 0x0007 207 207 024 Pre-fail Always - 344 (Average 293)
4 Start_Stop_Count 0x0012 099 099 000 Old_age Always - 4121
5 Reallocated_Sector_Ct 0x0033 100 100 005 Pre-fail Always - 0
7 Seek_Error_Rate 0x000a 100 100 067 Old_age Always - 0
8 Seek_Time_Performance 0x0004 128 128 020 Old_age Offline - 18
9 Power_On_Hours 0x0012 099 099 000 Old_age Always - 12042
10 Spin_Retry_Count 0x0012 100 100 060 Old_age Always - 0
12 Power_Cycle_Count 0x0032 099 099 000 Old_age Always - 4120
22 Helium_Level 0x0023 100 100 025 Pre-fail Always - 100
192 Power-Off_Retract_Count 0x0032 097 097 000 Old_age Always - 4450
193 Load_Cycle_Count 0x0012 097 097 000 Old_age Always - 4450
194 Temperature_Celsius 0x0002 240 240 000 Old_age Always - 27 (Min/Max 12/55)
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0
197 Current_Pending_Sector 0x0022 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0008 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x000a 200 200 000 Old_age Always - 0
...
Column Breakdown
- ID#: Attribute identifier.
- ATTRIBUTE_NAME: Name of the attribute.
- FLAG: Attribute flags indicating how and when the attribute is updated.
- VALUE: Current normalized value of the attribute. Higher values are typically better.
- WORST: The worst (lowest) normalized value recorded for the attribute.
- THRESH: Threshold value below which the attribute is considered to have failed.
- TYPE: Indicates if the attribute is related to pre-failure (Pre-fail) or old age (Old_age).
- UPDATED: Indicates when the attribute is updated (Always or Offline).
- WHEN_FAILED: Indicates when the attribute failed, if applicable.
- RAW_VALUE: The raw, unprocessed value of the attribute.
Attribute Details
Raw_Read_Error_Rate
- Type: Pre-fail
- Current Value: 100
- Worst Value: 100
- Threshold: 16
- Raw Value: 0
- Interpretation: No read errors detected.
Throughput_Performance
- Type: Old_age
- Current Value: 129
- Worst Value: 129
- Threshold: 54
- Raw Value: 112
- Interpretation: Good overall throughput performance.
Spin_Up_Time
- Type: Pre-fail
- Current Value: 207
- Worst Value: 207
- Threshold: 24
- Raw Value: 344 (Average 293)
- Interpretation: Spin-up time is within acceptable range.
Start_Stop_Count
- Type: Old_age
- Current Value: 99
- Worst Value: 99
- Threshold: 0
- Raw Value: 4121
- Interpretation: The drive has been started and stopped 4121 times.
Reallocated_Sector_Ct
- Type: Pre-fail
- Current Value: 100
- Worst Value: 100
- Threshold: 5
- Raw Value: 0
- Interpretation: No sectors have been reallocated.
Seek_Error_Rate
- Type: Old_age
- Current Value: 100
- Worst Value: 100
- Threshold: 67
- Raw Value: 0
- Interpretation: No seek errors detected.
Seek_Time_Performance
- Type: Old_age
- Current Value: 128
- Worst Value: 128
- Threshold: 20
- Raw Value: 18
- Interpretation: Seek time performance is good.
Power_On_Hours
- Type: Old_age
- Current Value: 99
- Worst Value: 99
- Threshold: 0
- Raw Value: 12042
- Interpretation: The drive has been powered on for 12,042 hours.
Spin_Retry_Count
- Type: Old_age
- Current Value: 100
- Worst Value: 100
- Threshold: 60
- Raw Value: 0
- Interpretation: No spin-up retries have occurred.
Power_Cycle_Count
- Type: Old_age
- Current Value: 99
- Worst Value: 99
- Threshold: 0
- Raw Value: 4120
- Interpretation: The drive has gone through 4,120 power cycles.
Helium_Level
- Type: Pre-fail
- Current Value: 100
- Worst Value: 100
- Threshold: 25
- Raw Value: 100
- Interpretation: Helium level is within acceptable range.
Power-Off_Retract_Count - Type: Old_age - Current Value: 97 - Worst Value: 97 - Threshold: 0 - Raw Value: 4450 - Interpretation: The head has been retracted 4,450 times during power-off.
Load_Cycle_Count - Type: Old_age - Current Value: 97 - Worst Value: 97 - Threshold: 0 - Raw Value: 4450 - Interpretation: The drive’s heads have been loaded and unloaded 4,450 times.
Temperature_Celsius - Type: Old_age - Current Value: 240 - Worst Value: 240 - Threshold: 0 - Raw Value: 27 (Min/Max 12/55) - Interpretation: The current temperature is 27°C, with a range of 12°C to 55°C.
Reallocated_Event_Count - Type: Old_age - Current Value: 100 - Worst Value: 100 - Threshold: 0 - Raw Value: 0 - Interpretation: No reallocation events have occurred.
Current_Pending_Sector - Type: Old_age - Current Value: 100 - Worst Value: 100 - Threshold: 0 - Raw Value: 0 - Interpretation: No sectors are pending reallocation.
Offline_Uncorrectable - Type: Old_age - Current Value: 100 - Worst Value: 100 - Threshold: 0 - Raw Value: 0 - Interpretation: No uncorrectable errors detected during offline scans.
UDMA_CRC_Error_Count - Type: Old_age - Current Value: 200 - Worst Value: 200 - Threshold: 0 - Raw Value: 0 - Interpretation: No CRC errors detected.
Summary
The drive appears to be in good health, with no significant errors or issues detected. The key pre-fail and old-age indicators are within acceptable ranges, and no attributes have exceeded their threshold values.
smartctl usage reference
% smartctl
smartctl 7.4 2023-08-01 r5530 [Darwin 23.5.0 arm64] (local build)
Copyright (C) 2002-23, Bruce Allen, Christian Franke, www.smartmontools.org
ERROR: smartctl requires a device name as the final command-line argument.
Use smartctl -h to get a usage summary
(venv) ming@M2 djangocas-homepage % smartctl -h
smartctl 7.4 2023-08-01 r5530 [Darwin 23.5.0 arm64] (local build)
Copyright (C) 2002-23, Bruce Allen, Christian Franke, www.smartmontools.org
Usage: smartctl [options] device
============================================ SHOW INFORMATION OPTIONS =====
-h, --help, --usage
Display this help and exit
-V, --version, --copyright, --license
Print license, copyright, and version information and exit
-i, --info
Show identity information for device
--identify[=[w][nvb]]
Show words and bits from IDENTIFY DEVICE data (ATA)
-g NAME, --get=NAME
Get device setting: all, aam, apm, dsn, lookahead, security,
wcache, rcache, wcreorder, wcache-sct
-a, --all
Show all SMART information for device
-x, --xall
Show all information for device
--scan
Scan for devices
--scan-open
Scan for devices and try to open each device
================================== SMARTCTL RUN-TIME BEHAVIOR OPTIONS =====
-j, --json[=cgiosuvy]
Print output in JSON or YAML format
-q TYPE, --quietmode=TYPE (ATA)
Set smartctl quiet mode to one of: errorsonly, silent, noserial
-d TYPE, --device=TYPE
Specify device type to one of:
ata, scsi[+TYPE], nvme[,NSID], sat[,auto][,N][+TYPE], usbasm1352r,N, usbcypress[,X], usbjmicron[,p][,x][,N], usbprolific, usbsunplus, sntasmedia, sntjmicron[,NSID], sntrealtek, jmb39x[-q],N[,sLBA][,force][+TYPE], jms56x,N[,sLBA][,force][+TYPE], auto, test
-T TYPE, --tolerance=TYPE (ATA)
Tolerance: normal, conservative, permissive, verypermissive
-b TYPE, --badsum=TYPE (ATA)
Set action on bad checksum to one of: warn, exit, ignore
-r TYPE, --report=TYPE
Report transactions (see man page)
-n MODE[,STATUS[,STATUS2]], --nocheck=MODE[,STATUS[,STATUS2]] (ATA, SCSI)
No check if: never, sleep, standby, idle (see man page)
============================== DEVICE FEATURE ENABLE/DISABLE COMMANDS =====
-s VALUE, --smart=VALUE
Enable/disable SMART on device (on/off)
-o VALUE, --offlineauto=VALUE (ATA)
Enable/disable automatic offline testing on device (on/off)
-S VALUE, --saveauto=VALUE (ATA)
Enable/disable Attribute autosave on device (on/off)
-s NAME[,VALUE], --set=NAME[,VALUE]
Enable/disable/change device setting: aam,[N|off], apm,[N|off],
dsn,[on|off], lookahead,[on|off], security-freeze,
standby,[N|off|now], wcache,[on|off], rcache,[on|off],
wcreorder,[on|off[,p]], wcache-sct,[ata|on|off[,p]]
======================================= READ AND DISPLAY DATA OPTIONS =====
-H, --health
Show device SMART health status
-c, --capabilities (ATA, NVMe)
Show device SMART capabilities
-A, --attributes
Show device SMART vendor-specific Attributes and values
-f FORMAT, --format=FORMAT (ATA)
Set output format for attributes: old, brief, hex[,id|val]
-l TYPE, --log=TYPE
Show device log. TYPE: error, selftest, selective, directory[,g|s],
xerror[,N][,error], xselftest[,N][,selftest], background,
sasphy[,reset], sataphy[,reset], scttemp[sts,hist],
scttempint,N[,p], scterc[,N,M][,p|reset], devstat[,N], defects[,N],
ssd, gplog,N[,RANGE], smartlog,N[,RANGE], nvmelog,N,SIZE
tapedevstat, zdevstat, envrep, farm
-v N,OPTION , --vendorattribute=N,OPTION (ATA)
Set display OPTION for vendor Attribute N (see man page)
-F TYPE, --firmwarebug=TYPE (ATA)
Use firmware bug workaround:
none, nologdir, samsung, samsung2, samsung3, xerrorlba, swapid
-P TYPE, --presets=TYPE (ATA)
Drive-specific presets: use, ignore, show, showall
-B [+]FILE, --drivedb=[+]FILE (ATA)
Read and replace [add] drive database from FILE
[default is +/opt/homebrew/etc/smart_drivedb.h
and then /opt/homebrew/Cellar/smartmontools/7.4/share/smartmontools/drivedb.h]
============================================ DEVICE SELF-TEST OPTIONS =====
-t TEST, --test=TEST
Run test. TEST: offline, short, long, conveyance, force, vendor,N,
select,M-N, pending,N, afterselect,[on|off]
-C, --captive
Do test in captive mode (along with -t)
-X, --abort
Abort any non-captive test on device
=================================================== SMARTCTL EXAMPLES =====
smartctl -a disk0 (Prints all SMART information)
smartctl -t long /dev/disk0 (Executes extended disk self-test)
smartctl --smart=on --saveauto=on /dev/rdisk0 (Enables SMART on first disk)
smartctl --attributes --log=selftest --quietmode=errorsonly /dev/disk0
(Prints Self-Test & Attribute errors)
smartctl -a IOService:/MacRISC2PE/pci@f4000000/AppleMacRiscPCI/ata-6@D/AppleKauaiATA/ATADeviceNub@0/IOATABlockStorageDriver/IOATABlockStorageDevice
(You can use IOService: ...)
smartctl -c IODeviceTree:/pci@f4000000/ata-6@D/@0:0
(... Or IODeviceTree:)
Summary
By running smartctl
tests periodically, you can monitor the health of your storage devices and preemptively address potential failures.
OmniLock - Block / Hide App on iOS
Block distractive apps from appearing on the Home Screen and App Library, enhance your focus and reduce screen time.
DNS Firewall for iOS and Mac OS
Encrypted your DNS to protect your privacy and firewall to block phishing, malicious domains, block ads in all browsers and apps