Smartctl(S.M.A.R.T自監控,分析和報告技術)是類Unix下實施SMART任務命令行套件或工具,它用於打印SMART自檢和錯誤日志,啟用並禁用SMRAT自動檢測,以及初始化設備自檢。
Smartctl對於Linux物理服務器非常有用,在這些服務器上,可以智能的對磁盤進行錯誤檢查,並將硬件RAID相關的磁盤信息摘錄下來。
在Linux上很早就有了SMART支持了。如果把Linux裝在VMware等虛擬機上,在系統啟動時可以看到有個服務啟動報錯:smartd
這個服務就是smart的daemon進程(因為VMware虛擬機的硬盤不支持SMART,所以報錯)
首先通過dmesg工具,確認一下硬盤的設備符號
hdb中的h代表IDE,如果顯示位sdb,則代表SATA和SCSI。
最后一個字幕b代表Primary總線,第二塊硬盤即Slave位置
下面是一些常用的smartctl命令:
命令 | 描述 |
---|---|
-i | 指定設備 |
-d | 指定設備類型,例如:ata,scsi,marvell,sat,3ware,N |
-a或A | 顯示所有信息 |
-l | 指定日志類型,例如:TYPE:error,selftest,selecttive,directory,background,scttemp[sts,hist] |
-H | 查看硬盤健康狀態 |
-t short | 后台檢測硬盤,消耗時間短 |
-t long | 后台檢測硬盤,消耗時間長 |
-C -t short | 前台檢測硬盤,消耗時間短 |
-C -t long | 前台檢測硬盤,消耗時間長 |
-X | 中斷后台檢測硬盤 |
-l selftest | 顯示硬盤檢測日志 |
首先應確認硬盤是否打開了SMART支持 smartctl -i /dev/sda
[root@A01-R04-I255-59 bjzhangxinglong]# smartctl -i /dev/sda smartctl 5.43 2012-06-30 r3573 [x86_64-linux-2.6.32-504.16.2.el6.x86_64] (local build) Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net Vendor: DELL Product: PERC H710P Revision: 3.13 User Capacity: 1,197,759,004,672 bytes [1.19 TB] Logical block size: 512 bytes Logical Unit id: 0x6b083fe0c1c7230020b080c10502c367 Serial number: 0067c30205c180b0200023c7c1e03f08 Device type: disk Local Time is: Tue Dec 22 15:10:01 2020 CST Device does not support SMART
如果看到不支持這需要我們手動開啟支持
smartctl --smart=on --offlineauto=on --saveauto=on
命令:smartctl -a /dev/sda
smartctl 5.39 2008-10-24 22:33 [x86_64-suse-linux-gnu] (openSUSE RPM) Copyright (C) 2002-8 by Bruce Allen, http://smartmontools.sourceforge.net Device: SEAGATE ST9146803SS Version: 0006 #硬件廠商 Serial number: 6SD2A3ZZ0000B127LJJM #硬盤序列號 Device type: disk Transport protocol: SAS #接口類型 Local Time is: Fri Mar 4 16:58:30 2016 CST Device supports SMART and is Enabled #是否支持smart管理,有的不支持 Temperature Warning Enabled SMART Health Status: OK #健康狀態ok Current Drive Temperature: 21 C #當前溫度 Drive Trip Temperature: 68 C #此溫度是啥?有待考證 Elements in grown defect list: 0 Vendor (Seagate) cache information Blocks sent to initiator = 1044970503 Blocks received from initiator = 2476401867 Blocks read from cache and sent to initiator = 106869375 Number of read and write commands whose size <= segment size = 364621421 Number of read and write commands whose size > segment size = 0 Vendor (Seagate/Hitachi) factory information number of hours powered up = 37638.07 number of minutes until next internal SMART test = 54 Error counter log: Errors Corrected by Total Correction Gigabytes Total ECC rereads/ errors algorithm processed uncorrected fast | delayed rewrites corrected invocations [10^9 bytes] errors read: 15099690 0 0 15099690 15099690 2734.048 0 write: 0 0 0 0 0 71719.613 0 verify: 10434 0 0 10434 10434 0.000 0 Non-medium error count: 0 [GLTSD (Global Logging Target Save Disable) set. Enable Save with '-S on'] No self-tests have been logged Long (extended) Self Test duration: 3600 seconds [60.0 minutes]