在Mac下想要监控硬盘的S.M.A.R.T.
信息还是有很多办法的,很多软件可以办到,比如:
SMART Utility
、SoftRAID
,Disk Drill
不过这些软件都是收费的,另外也比较占资源。这些我都用过,不过感觉Disk Drill
并不太准,这个工具主要是恢复数据用的。
我有个盘出现了坏道,上面三个工具中,前两个都能识别,最后一个却显示正常~~
后来决定还是用开源的工具smartmontools:
smartmontools-7.1-1
最新版安装之后,路径为:/usr/local/sbin
,所以装完之后需要将该目录加到环境变量中,添加方法如下:
添加之后就可以使用了,使用方法为:
smartctl -a /dev/disk0
这样就可以查看disk0
的S.M.A.R.T.
信息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
mcj@mcjdeiMac:~$ smartctl -a /dev/disk0 smartctl 7.1 2019-12-30 r5022 [Darwin 19.3.0 x86_64] (sf-7.1-1) Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Device Model: KingBANK KP330 Serial Number: I23563J002995 LU WWN Device Id: 5 02b2a2 01d1c1b1a Add. Product Id: mavlsata Firmware Version: Q0616A User Capacity: 120,034,123,776 bytes [120 GB] Sector Size: 512 bytes logical/physical Rotation Rate: Solid State Device Device is: Not in smartctl database [for details use: -P showall] ATA Version is: ACS-3 T13/2161-D revision 4 SATA Version is: SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s) Local Time is: Wed Dec 2 00:24:55 2020 CST SMART support is: Available - device has SMART capability. SMART support is: Enabled === START OF READ SMART DATA SECTION === SMART overall-health self-assessment test result: PASSED General SMART Values: Offline data collection status: (0x02) Offline data collection activity was completed without error. Auto Offline Data Collection: Disabled. Self-test execution status: ( 0) The previous self-test routine completed without error or no self-test has ever been run. Total time to complete Offline data collection: ( 0) seconds. Offline data collection capabilities: (0x35) SMART execute Offline immediate. No Auto Offline data collection support. Abort Offline collection upon new command. No Offline surface scan supported. Self-test supported. Conveyance Self-test supported. No Selective Self-test supported. SMART capabilities: (0x0002) Does not save SMART data before entering power-saving mode. Supports SMART auto save timer. Error logging capability: (0x00) Error logging NOT supported. General Purpose Logging supported. Short self-test routine recommended polling time: ( 1) minutes. Extended self-test routine recommended polling time: ( 1) minutes. Conveyance self-test routine recommended polling time: ( 1) minutes. SMART Attributes Data Structure revision number: 5 Vendor Specific SMART Attributes with Thresholds: ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE 5 Reallocated_Sector_Ct 0x0033 100 100 010 Pre-fail Always - 0 9 Power_On_Hours 0x0033 100 100 010 Pre-fail Always - 20195 12 Power_Cycle_Count 0x0033 100 100 010 Pre-fail Always - 112 161 Unknown_Attribute 0x0033 100 100 010 Pre-fail Always - 0 164 Unknown_Attribute 0x0033 100 100 010 Pre-fail Always - 32891 165 Unknown_Attribute 0x0033 100 100 010 Pre-fail Always - 167 166 Unknown_Attribute 0x0033 100 100 010 Pre-fail Always - 26 167 Unknown_Attribute 0x0033 100 100 010 Pre-fail Always - 71 169 Unknown_Attribute 0x0033 100 100 010 Pre-fail Always - 0 176 Erase_Fail_Count_Chip 0x0033 100 100 010 Pre-fail Always - 0 177 Wear_Leveling_Count 0x0033 100 100 010 Pre-fail Always - 0 178 Used_Rsvd_Blk_Cnt_Chip 0x0033 100 100 010 Pre-fail Always - 0 192 Power-Off_Retract_Count 0x0033 100 100 010 Pre-fail Always - 16 194 Temperature_Celsius 0x0033 100 100 010 Pre-fail Always - 46 195 Hardware_ECC_Recovered 0x0033 100 100 010 Pre-fail Always - 0 199 UDMA_CRC_Error_Count 0x0033 100 100 010 Pre-fail Always - 0 241 Total_LBAs_Written 0x0033 100 100 010 Pre-fail Always - 11763 242 Total_LBAs_Read 0x0033 100 100 010 Pre-fail Always - 8876 243 Unknown_Attribute 0x0033 100 100 010 Pre-fail Always - 0 244 Unknown_Attribute 0x0033 100 100 010 Pre-fail Always - 0 245 Unknown_Attribute 0x0033 100 100 010 Pre-fail Always - 0 246 Unknown_Attribute 0x0033 100 100 010 Pre-fail Always - 0 250 Read_Error_Retry_Rate 0x0033 100 100 010 Pre-fail Always - 0 251 Unknown_Attribute 0x0033 100 100 010 Pre-fail Always - 0 252 Unknown_Attribute 0x0033 100 100 010 Pre-fail Always - 0 253 Unknown_Attribute 0x0033 100 100 010 Pre-fail Always - 0 254 Unknown_SSD_Attribute 0x0033 100 100 010 Pre-fail Always - 0 SMART Error Log not supported SMART Self-test Log not supported Selective Self-tests/Logging not supported |
如果你看到的不是这么详细的信息,而是短短的:
那就应该手动打开:
/usr/local/sbin/smartctl -s on -S on -o on /dev/disk0
之后就是后台监控S.M.A.R.T.
信息了:
/dev/disk0 -a -d sat -S on -s (S/../.././02|L/../../6/03)
这里的-d sat
是指定你设备的连接类型为SATA
,后面指定每天凌晨2点运行一个简短测试,每周六的凌晨3点跑一个长测试,输出的日志会体现在/var/log/system.log
里,你可以打开控制台看,也可以自己根据需要用-l
参数配置输出到其他地方。这里举例只写了一个设备,有多个设备需要监控的,再加一行就行了。
最后需要注意的是OS X
上用LaunchDaemon
来启动服务,因此到/Library/LaunchDaemons/
下增加一个plist
文件吧,plist
下载地址见文末。
附
件
下
载