Disk detection tool smartctl

1. Tool Introduction

Smartmontools is a hard disk detection tool, which is realized through the SMART (Self Monitoring Analysis and Reporting Technology) technology that controls and manages hard disks.

​ SMART technology can monitor the magnetic head unit of the hard disk, the disk motor drive system, the internal circuit of the hard disk, and the medium material on the surface of the disk. loss. SMART technology can only work if the motherboard supports it, and SMART technology cannot guarantee to predict all possible hard disk failures.

​ Windows does not have built-in SMART-related tools, and third-party tool software needs to be installed. The hard disk of the vmware virtual machine does not support SMART, and Linux has long supported SMART.

2. Usage syntax and parameter description

1. Use grammar

smartctl [options] device

2. Parameter description

2.1. Information display parameter options

-h, --help, --usage 	获取命令帮助
-V, --version, --copyright, --license 打印显示软件版本、授权等信息
-i, --info 				显示指定设备的身份信息
-g NAME, --get=NAME 	查看设备设置值,name可选值包括all, aam, apm, dsn, lookahead, security,wcache, rcache, wcreorder, wcache-sct
-a, --all 				打印显示设备的所有smart信息
-x, --xall 				打印显示设备的所有信息
–scan 					扫描磁盘设备
–scan-open 				扫描磁盘设备并参数开启设备

2.2, smart running parameter options

-j, --json[=[cgiosuv]] 		打印输出为json格式
-q TYPE, --quietmode=TYPE 	安静模式,TYPE可选值为errorsonly, silent, noserial
-d TYPE, --device=TYPE 		指定设备类型,TYPE可选值为ata, scsi[+TYPE], nvme[,NSID], sat[,auto][,N][+TYPE], usbcypress[,X], usbjmicron[,p][,x][,N], usbprolific, usbsunplus, sntjmicron[,NSID], intelliprop,N[+TYPE], marvell, areca,N/E, 3ware,N, hpt,L/M/N, megaraid,N, aacraid,H,L,ID, cciss,N, auto, test
-T TYPE, --tolerance=TYPE 	公差类型,可选值为normal, conservative, permissive, verypermissive
-b TYPE, --badsum=TYPE 		设置校验和有错的扇区执行操作,可选TYPE值有warn, exit, ignore
-r TYPE, --report=TYPE 		报告事务设置
-n MODE[,STATUS], --nocheck=MODE[,STATUS] 检查介绍后的操作never, sleep, standby, idle

2.3. Device smart function start and stop parameter options

-s VALUE, --smart=VALUE 		开启或禁用设备device功能,VALUE值为on/off
-o VALUE, --offlineauto=VALUE 	开启或者禁用离线测试,VALUE值为on/off
-S VALUE, --saveauto=VALUE 		开启或者禁用属性自动保存,VALUE值为on/off
-s NAME[,VALUE], --set=NAME[,VALUE] 开启或者关闭指定类型设备

2.4. Read and display data parameter options

-H, --health 		查看设备smart健康状况
-c, --capabilities 	查看设备smart能力
-A, --attributes 	查看生成厂商smart属性和属性值
-f FORMAT, --format=FORMAT 设置输出格式属性
-l TYPE, --log=TYPE 查看指定类型日志,常用日志类型error, selftest, selective, directory,background, scttemp[sts,hist]
-v N,OPTION , --vendorattribute=N,OPTION 	设置供应商属性N的显示选项

2.5. Disk self-test parameter options

-t TEST, --test=TEST TEST可选值包括offline, short, long, conveyance, force, vendor,N,select,M-N, pending,N, afterselect,[on|off]
-C, --captive 	捕获模式下运行,即前台运行
-t short 		后台检测硬盘,消耗时间短
-t long 		后台检测硬盘,消耗时间长
-C -t short 	前台检测硬盘,消耗时间短
-C -t long 		前台检测硬盘,消耗时间长
-X, --abort 	中断任何后台自测

3. Example of use

1. Command installation

apt  install smartmontools

2. Check whether the disk supports smart

2.1. Operation instructions

smartctl -i /dev/sda

2.2. The information is as follows

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital Purple
Device Model:     WDC WD40PURX-78NZ6Y0
Serial Number:    WD-WCC7K4AN0E4C
LU WWN Device Id: 5 0014ee 20fdccc05
Firmware Version: 80.00A80
User Capacity:    4,000,787,030,016 bytes [4.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5400 rpm
Form Factor:      3.5 inches
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-3 T13/2161-D revision 5
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Thu Mar 30 09:18:37 2023 CST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

2.3. Information description

Available表示硬盘支持SMART,Enabled表示启用了SMART

3. Enable SMART

3.1. Operation instructions

smartctl --smart=on --offlineauto=on --saveauto=on /dev/sda

3.2. The information is as follows

=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Enabled.
SMART Attribute Autosave Enabled.
SMART Automatic Offline Testing Enabled every four hours.

4. View all SMART information of the hard disk

smartctl -a /dev/sda

5. View the health status of the hard disk

5.1. Operation instructions

smartctl -H /dev/sda

5.2. The information is as follows

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

5.3. Information Description

​ The result after result: PASSED, which means that the hard disk is in good health. If Failure is displayed here, it is best to replace the hard disk for the server immediately.

6. View device SMART manufacturer attributes and values

6.1. Operation instructions

smartctl -A /dev/sda

6.2. The information is as follows

=== START OF READ SMART DATA SECTION ===
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 0x000b 100 100 016 Pre-fail Always - 0
2 Throughput_Performance 0x0005 142 142 054 Pre-fail Offline - 68
3 Spin_Up_Time 0x0007 122 122 024 Pre-fail Always - 185 (Average 189)
4 Start_Stop_Count 0x0012 100 100 000 Old_age Always - 715
5 Reallocated_Sector_Ct 0x0033 100 100 005 Pre-fail Always - 0
7 Seek_Error_Rate 0x000b 100 100 067 Pre-fail Always - 0
8 Seek_Time_Performance 0x0005 115 115 020 Pre-fail Offline - 34
9 Power_On_Hours 0x0012 099 099 000 Old_age Always - 12687
10 Spin_Retry_Count 0x0013 100 100 060 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 372
192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always - 830
193 Load_Cycle_Count 0x0012 100 100 000 Old_age Always - 830
194 Temperature_Celsius 0x0002 193 193 000 Old_age Always - 31 (Min/Max 7/41)
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

7. Display hard disk history error information

7.1. Operation instructions

smartctl -l error /dev/sda

7.2. The information is as follows

=== START OF READ SMART DATA SECTION ===
SMART Error Log Version: 1
No Errors Logged

8. Execute the smartctl test in the background

8.1. Operation instructions

smartctl --test=long /dev/sda

8.2. The information is as follows

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: “Execute SMART Extended self-test routine immediately in off-line mode”.
Drive command “Execute SMART Extended self-test routine immediately in off-line mode” successful.
Testing has begun.
Please wait 119 minutes for test to complete.
Test will complete after Tue Oct 12 17:14:21 2021

Use smartctl -X to abort test.

9. Execute smart self-test at the foreground

9.1. Operation instructions

smartctl -C -t short /dev/sda

9.2. The information is as follows

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: “Execute SMART Short self-test routine immediately in captive mode”.
Drive command “Execute SMART Short self-test routine immediately in captive mode” successful.
Testing has begun.
Please wait 1 minutes for test to complete.
Test will complete after Tue Oct 12 16:03:19 2021

10. Interrupt smart self-test

10.1. Operation instructions

smartctl -X /dev/sda

10.2. The information is as follows

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: “Abort SMART off-line mode self-test routine”.
Self-testing aborted!

11. Display smart self-test log

smartctl -l selftest /dev/sda

Guess you like

Origin blog.csdn.net/weixin_35804181/article/details/130170416