S.M.A.R.T.
檢測你的硬碟健康狀態
Installation
sudo apt-get install smartmontools
當硬碟不支援時顯示 Unavailable :
test_user@test-VirtualBox [stp:1] { /var/www }$ sudo smartctl -i /dev/sda1
smartctl 5.43 2012-06-30 r3573 [x86_64-linux-3.8.0-19-generic] (local build)
Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net
=== START OF INFORMATION SECTION ===
Device Model: VBOX HARDDISK
Serial Number: VB47e46d42-bbe471de
Firmware Version: 1.0
User Capacity: 8,589,934,592 bytes [8.58 GB]
Sector Size: 512 bytes logical/physical
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 6
ATA Standard is: ATA/ATAPI-6 published, ANSI INCITS 361-2002
Local Time is: Fri May 17 10:08:11 2013 CST
SMART support is: Unavailable - device lacks SMART capability.
To check if the device has SMART capability:
己打開會顯示:
test_user@test { ~ }$ sudo smartctl -i /dev/sda1
smartctl 6.1 2013-03-16 r3800 [x86_64-linux-3.7.4-1-ARCH] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Western Digital RE3 Serial ATA
Device Model: WDC WD5002ABYS-18B1B0
Serial Number: WD-WCASY6863830
LU WWN Device Id: 5 0014ee 2ade88ff2
Add. Product Id: DELL▒
Firmware Version: 02.03B04
User Capacity: 500,107,862,016 bytes [500 GB]
Sector Size: 512 bytes logical/physical
Rotation Rate: 7200 rpm
Device is: In smartctl database [for details use: -P show]
ATA Version is: ATA8-ACS (minor revision not indicated)
SATA Version is: SATA 2.5, 3.0 Gb/s
Local Time is: Mon May 13 13:51:20 2013 CST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
沒打開smart會顯示 Disabled:
test_user@test { /usr/sbin }$ sudo smartctl -i /dev/sda1
smartctl 6.1 2013-03-16 r3800 [x86_64-linux-3.7.4-1-ARCH] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Western Digital RE3 Serial ATA
Device Model: WDC WD5002ABYS-18B1B0
Serial Number: WD-WCASY6863830
LU WWN Device Id: 5 0014ee 2ade88ff2
Add. Product Id: DELL▒
Firmware Version: 02.03B04
User Capacity: 500,107,862,016 bytes [500 GB]
Sector Size: 512 bytes logical/physical
Rotation Rate: 7200 rpm
Device is: In smartctl database [for details use: -P show]
ATA Version is: ATA8-ACS (minor revision not indicated)
SATA Version is: SATA 2.5, 3.0 Gb/s
Local Time is: Mon May 13 16:04:42 2013 CST
SMART support is: Available - device has SMART capability.
SMART support is: Disabled
If SMART is not enabled, it can be enabled by doing:
打開:
test_user@test { ~ }$ sudo smartctl -s on /dev/sda1
smartctl 6.1 2013-03-16 r3800 [x86_64-linux-3.7.4-1-ARCH] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Enabled.
沒打開:
test_user@test { /usr/sbin }$ sudo smartctl -s off /dev/sda1
smartctl 6.1 2013-03-16 r3800 [x86_64-linux-3.7.4-1-ARCH] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Disabled. Use option -s with argument 'on' to enable it.
check device
test_user@test { ~/test (master) }$ sudo smartctl -P show /dev/sda
smartctl 5.43 2012-06-30 r3573 [x86_64-linux-3.8.0-25-generic] (local build)
Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net
ATA device successfully opened
Use 'smartctl -a' (or '-x') to print SMART (and more) information
Test the device health :
- Short (runs tests that have a high probability of detecting device problems)
- Extended (or Long; a short check with complete disk surface examination)
- Conveyance (identifies if damage incurred during transportation of the device)
打開:
test_user@test { ~ }$ sudo smartctl -c /dev/sda1
smartctl 6.1 2013-03-16 r3800 [x86_64-linux-3.7.4-1-ARCH] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
General SMART Values:
Offline data collection status: (0x85) Offline data collection activity
was aborted by an interrupting command from host.
Auto Offline Data Collection: Enabled.
Self-test execution status: ( 248) Self-test routine in progress...
80% of test remaining.
Total time to complete Offline
data collection: ( 9480) 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: (0x0003) Saves 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: ( 112) minutes.
Conveyance self-test routine
recommended polling time: ( 5) minutes.
SCT capabilities: (0x303f) SCT Status supported.
SCT Error Recovery Control supported.
SCT Feature Control supported.
SCT Data Table supported.
沒打開會顯示SMART Disabled:
test_user@test { /usr/sbin }$ sudo smartctl -c /dev/sda1
smartctl 6.1 2013-03-16 r3800 [x86_64-linux-3.7.4-1-ARCH] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
SMART Disabled. Use option -s with argument 'on' to enable it.
(override with '-T permissive' option)
To run the tests do:
smartctl -t short /dev/<device>
smartctl -t long /dev/<device>
smartctl -t conveyance /dev/<device>
Results
To view the test’s overall health status (compiled from all tests):
test_user@test { ~ }$ sudo smartctl -H /dev/sda1
smartctl 6.1 2013-03-16 r3800 [x86_64-linux-3.7.4-1-ARCH] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
PASSED表示硬碟健康狀態良好
Failure表示硬碟有問題
To view the test’s result errors:
test_user@test { ~ }$ sudo smartctl -l selftest /dev/sda1
smartctl 6.1 2013-03-16 r3800 [x86_64-linux-3.7.4-1-ARCH] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
1 Extended offline Completed without error 00% 95 -
2 Short offline Completed without error 00% 94 -
To view the test’s detailed results:
sudo smartctl -a /dev/sda1
或使用↓顯示部份資訊
sudo smartctl -A /dev/sda1
If no errors are reported the device is likely healthy.
If there are a few errors this may or may not indicate a problem and should be investigated further.
When a device starts to fail it is recommended to backup the data and replace it.
ID#
- This ID for the attribute is displayed as a decimal number in this report but other reports may display it in its native hexadecimal format.
Attribute Name
- The human readable description of the ID#
Flag
- This is a hexadecimal description of the purposes of this attribute combined so they can be represented by a number.
- For example is it for performance, error rates or pre-fail or some combination of these and others.
Value
- This is a normalized version of the data that starts at its best possible value (like 200 for this attribute) and then decreases as it gets worse (now 192 for this attribute).
Worst
- The worst that the Value has ever been.
- Note that some vendors firmware may actually increase the “Worst” value for some rate-type Attributes.
Threshold (THRESH)
- These are defined by the vendor.
- The threshold for the Value. Once the Value goes below this, the drive will consider it to be FAILED for this attribute and depending on the attribute (like this one) the whole drive will be considered to be failing and warnings will be sent to backup and replace it.
Type
- A human readable version of the Flag value but not as detailed.
- Note that if an Attribute is of type ‘Pre-fail’, it does not mean that your disk is about to fail! It only has this meaning if the Attribute’s current Normalized value is less than or equal to the threshold value.
Updated
- How often the attribute’s value is updated.
- Some SMART attributes values, that are updated only during off-line data collection activities are labeled “Offline” in column “UPDATED”.
When Failed
- If there was a failure where the value reached or went below the threshold value, the power-on lifetime is displayed here (usually in hours )
- If the Attribute’s current “Normalized value” is less than or equal to the threshold value, then the attribute is marked with “FAILING_NOW” in column WHEN_FAILED.
Raw Value
- The raw non-normalized value of the attribute.
- Please keep in mind that the conversion from RAW value to a quantity with physical units is not specified by the SMART standard! smartctl only reports the different Attribute types, values, and thresholds as read from the device. It does not carry out the conversion between “Raw” and “Normalized” values: this is done by the disk’s firmware.
- In most cases, the values printed by smartctl are sensible. For example the temperature Attribute generally has its raw value equal to the temperature in Celsius. However in some cases vendors use unusual conventions. For example the Hitachi disk on my laptop reports its power-on hours in minutes, not hours. Some IBM disks track three temperatures rather than one, in their raw values. Have a look at our wiki pages on topic SMART attributes.
狀態:
- Worst = 曾經發生過最壞時的值
- Value = 目前的值
- Threshold = 門檻值,超過此值代表硬碟瑕疵已超過容許的範圍
- T.E.C. = 一個預估你的硬碟壽命的日期
補充:
參數說明:
- -h 顯示參數說明及範例
- -V 顯示版本等相關資訊
- -i 顯示該硬碟的相關資訊(包括是否啟動 SMART)
- -a 顯示硬碟所有相關資訊
- -H 顯示硬碟 SMART 健康狀況 (健康 PASSED、生病 FAILED)
- -c 顯示硬碟支援的檢查、測試項目
- -A 顯示硬碟檢查後的相關屬性值 (例如 194 Temperature_Celsius 最後值為 HDD 溫度)
- -l TYPE 顯示硬碟檢查後 Log (TYPE: error, selftest, selective, directory)
- -t TEST 執行硬碟測試 (TEST: offline, short, long, conveyance, select,M-N pending,N afterselect,on afterselect,off)
- -X 放棄執行硬碟測試
中斷背景檢測硬碟:
test_user@test { ~ }$ sudo smartctl -X /dev/sda1
smartctl 6.1 2013-03-16 r3800 [x86_64-linux-3.7.4-1-ARCH] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Abort SMART off-line mode self-test routine".
Self-testing aborted!
顯示硬碟錯誤log:
test_user@test { ~ }$ smartctl -l error /dev/sda1
smartctl 6.1 2013-03-16 r3800 [x86_64-linux-3.7.4-1-ARCH] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
Smartctl open device: /dev/sda1 failed: Permission denied
test_user@test { ~ }$ sudo smartctl -l error /dev/sda1
smartctl 6.1 2013-03-16 r3800 [x86_64-linux-3.7.4-1-ARCH] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
SMART Error Log Version: 1
No Errors Logged
-d指定設備類型,例如: ata, scsi, marvell, sat, 3ware,N
$ smartctl -s on -d ata /dev/sdb
disk判斷項目 :
假設 exec() 第3參數為 $is_fail
- 有安裝但不支援,$is_fail = 0 (解析第2參數判斷Unavailable)
- 有安裝但沒打開,$is_fail = 0 (解析第2參數判斷Disabled)
- 沒安裝smart,$is_fail = 1
- disk路徑亂打(/devx/sda8),$is_fail = 1 or 127
- 指定不存在的disk (/dev/sda8),$is_fail = 2
參考來源:
https://sites.google.com/site/lab586/linuxnote/hddchecktip
https://wiki.archlinux.org/index.php/SMART
http://space.itpub.net/12823785/viewspace-504042
http://www.weithenn.org/cgi-bin/wiki.pl?Smartmontools-%E6%AA%A2%E6%9F%A5%E6%B8%AC%E8%A9%A6%E7%A1%AC%E7%A2%9F%E5%A3%BD%E5%91%BD
http://southdogs.blogspot.tw/2008/05/smart.html
http://www.adminii.com/486.html
http://html5.litten.com/accessing-and-assessing-a-hard-drives-s-m-a-r-t-data/
http://sourceforge.net/apps/trac/smartmontools/wiki/Howto_ReadSmartctlReports_ATA