smartctl [options] device
系统需要安装smartmontools才可以使用smartctl命令。smartmontools 就是利用硬盘 S.M.A.R.T. (Self-Monitoring_Analysis_and_Reporting) 特性特性监测硬盘的软件包,包含 smartctl 和 smartd 两个程序,前者是前台命令行工具、后者是后台运行程序。
# yum install kernel-utils
在 CentOS/Fedora 下安装smartmontools
# apt-get install smartmontools
在 Debian/Ubuntu 下安装
smartctl -a
smartctl -i
smartctl -s on
smartctl -t short
smartctl -t long
smartctl -C -t short
smartctl -C -t long
smartctl -X
smartctl -l selftest
smartctl -l error
hdparm 、 smartctl
# smartctl -i /dev/sda
smartctl version 5.38 [x86_64-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen Home page is http://smartmontools.sourceforge.net/ START OF INFORMATION SECTION Model Family: Western Digital Caviar Second Generation Serial ATA family Device Model: WDC WD3200JS-55PDB0 Serial Number: WD-WCAPD1876075 Firmware Version: 21.00M21 User Capacity: 320,072,933,376 bytes Device is: In smartctl database [for details use: -P show] ATA Version is: 7 ATA Standard is: Exact ATA specification draft version not indicated Local Time is: Mon Dec 19 17:21:12 2011 CST SMART support is: Available - device has SMART capability. SMART support is: Enabled
检查一下硬盘是否具有 SMART 特性
# smartctl -H /dev/sda
smartctl version 5.38 [x86_64-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen Home page is http://smartmontools.sourceforge.net/ START OF READ SMART DATA SECTION SMART overall-health self-assessment test result: PASSED
查看硬盘健康状态
# smartctl -t short /dev/sda
smartctl version 5.38 [x86_64-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen Home page is http://smartmontools.sourceforge.net/ START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION Sending command: "Execute SMART Short self-test routine immediately in off-line mode". Drive command "Execute SMART Short self-test routine immediately in off-line mode" successful. Testing has begun. Please wait 2 minutes for test to complete. Test will complete after Mon Dec 19 17:33:51 2011 Use smartctl -X to abort test.
快速检测硬盘。
# smartctl -l selftest /dev/sda
查看硬盘测试结果
#smartctl -l error /dev/sda
-a 显示设备所有的SMART信息。
-l error 列出硬盘错误日志。如果显示没有错误最好,如果显示了大量的错误信息,那就该着手准备替换硬盘了。
-l selftest 列出自行测试结果。