千家信息网

硬盘管理工具介绍:smartctl

发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,一、安装命令[root@localhost scripts]# smartctl --all /dev/sda -bash: smartctl: 未找到命令[root@localhost script
千家信息网最后更新 2025年12月02日硬盘管理工具介绍:smartctl

一、安装命令

[root@localhost scripts]# smartctl --all /dev/sda -bash: smartctl: 未找到命令[root@localhost scripts]# yum search smartctl -y已加载插件:fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com======================================================================================= 匹配:smartctl ========================================================================================smartmontools.x86_64 : Tools for monitoring SMART capable hard disks[root@localhost scripts]# yum install smartmontools.x86_64 -y

二、参数介绍:

smartctl -i 指定设备-d 指定设备类型,例如:ata, scsi, marvell, sat, 3ware,N-a 或A 显示所有信息-l 指定日志的类型,例如:TYPE: error, selftest, selective, directory,background, scttemp[sts,hist]-H 查看硬盘健康状态-t short 后台检测硬盘,消耗时间短-t long 后台检测硬盘,消耗时间长-C -t short 前台检测硬盘,消耗时间短-C -t long 前台检测硬盘,消耗时间长-X 中断后台检测硬盘-l selftest 显示硬盘检测日志

三、命令演示介绍:

运行 smartctl --scan 以打印附加设备id和RAID类型的所有设备:

[root@localhost scripts]# smartctl --scan /dev/sda -d scsi # /dev/sda, SCSI device/dev/sdb -d scsi # /dev/sdb, SCSI device/dev/bus/0 -d megaraid,0 # /dev/bus/0 [megaraid_disk_00], SCSI device/dev/bus/0 -d megaraid,1 # /dev/bus/0 [megaraid_disk_01], SCSI device在这里,megaraid 是RAID类型,megaraid_disk_00第一个0代表的是raid0  第二个0代表的是硬盘设备 id 0         megaraid 是RAID类型,megaraid_disk_01第一个0代表的是raid1  第二个1代表的是硬盘设备 id 1
[root@localhost scripts]#  smartctl -i /dev/sda1 smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-862.el7.x86_64] (local build)Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.orgSmartctl open device: /dev/sda1 failed: DELL or MegaRaid controller, please try adding '-d megaraid,N'由于演示的服务器是dell的,同时事先给这个机器的2块ssd硬盘做了raid0的[root@localhost scripts]# /opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aALL|grep -A7 "Virtual Drive Information"|sed '1d'Virtual Drive: 0 (Target Id: 0)Name                :RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0Size                : 223.0 GBState               : OptimalStrip Size          : 64 KBNumber Of Drives    : 1--Virtual Drive Information:Virtual Drive: 1 (Target Id: 1)Name                :RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0Size                : 223.0 GBState               : OptimalStrip Size          : 64 KBNumber Of Drives    : 1

查看硬盘设备类型(dell服务器,并且磁盘做了raid0的):

[root@localhost scripts]#  smartctl -i /dev/sda1  -d megaraid,0smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-862.el7.x86_64] (local build)Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org=== START OF INFORMATION SECTION ===Model Family:     Intel 730 and DC S35x0/3610/3700 Series SSDsDevice Model:     INTEL SSDSC2BB240G7Serial Number:    PHDV7234023C240AGNLU WWN Device Id: 5 5cd2e4 14e0aaaf5Firmware Version: N2010112User Capacity:    240,057,409,536 bytes [240 GB]Sector Sizes:     512 bytes logical, 4096 bytes physicalRotation Rate:    Solid State DeviceForm Factor:      2.5 inchesDevice is:        In smartctl database [for details use: -P show]ATA Version is:   ACS-3 T13/2161-D revision 5SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)Local Time is:    Fri Jan 17 17:13:49 2020 CSTSMART support is: Available - device has SMART capability.SMART support is: Enabled

super server 超威服务器:主板未绑定raid卡, 硬盘没有做raid

[root@localhost ~]# smartctl -i /dev/sda  smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-957.el7.x86_64] (local build)Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org=== START OF INFORMATION SECTION ===Device Model:     SanDisk SD8SBAT256G1122Serial Number:    161855404280LU WWN Device Id: 5 001b44 4a4b8c6caFirmware Version: Z2333000User Capacity:    256,060,514,304 bytes [256 GB]Sector Size:      512 bytes logical/physicalRotation Rate:    Solid State DeviceForm Factor:      2.5 inchesDevice is:        Not in smartctl database [for details use: -P showall]ATA Version is:   ACS-2 T13/2015-D revision 3SATA Version is:  SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)Local Time is:    Fri Jan 17 17:35:09 2020 CSTSMART support is: Available - device has SMART capability.SMART support is: Enabled

查看硬盘型号,检测硬盘状态,查看硬盘报错日志:

[root@localhost ~]# smartctl -i /dev/sda -H -l error smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-957.el7.x86_64] (local build)Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org=== START OF INFORMATION SECTION ===Device Model:     SanDisk SD8SBAT256G1122Serial Number:    161855404280LU WWN Device Id: 5 001b44 4a4b8c6caFirmware Version: Z2333000User Capacity:    256,060,514,304 bytes [256 GB]Sector Size:      512 bytes logical/physicalRotation Rate:    Solid State DeviceForm Factor:      2.5 inchesDevice is:        Not in smartctl database [for details use: -P showall]ATA Version is:   ACS-2 T13/2015-D revision 3SATA Version is:  SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)Local Time is:    Fri Jan 17 17:40:50 2020 CSTSMART support is: Available - device has SMART capability.SMART support is: Enabled=== START OF READ SMART DATA SECTION ===SMART overall-health self-assessment test result: PASSEDSMART Error Log Version: 1No Errors Logged

dell服务器查看磁盘的详细信息:

[root@localhost ~]# smartctl -a /dev/sda[root@localhost ~]# smartctl -A /dev/sda1 -d megaraid,0[root@localhost ~]# smartctl -a /dev/sda1 -d megaraid,0[root@localhost ~]# smartctl -a -d megaraid,0 /dev/sda -s on smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-862.el7.x86_64] (local build)Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org=== START OF INFORMATION SECTION ===Model Family:     Intel 730 and DC S35x0/3610/3700 Series SSDsDevice Model:     INTEL SSDSC2BB240G7Serial Number:    PHDV7234023C240AGNLU WWN Device Id: 5 5cd2e4 14e0aaaf5Firmware Version: N2010112User Capacity:    240,057,409,536 bytes [240 GB]Sector Sizes:     512 bytes logical, 4096 bytes physicalRotation Rate:    Solid State DeviceForm Factor:      2.5 inchesDevice is:        In smartctl database [for details use: -P show]ATA Version is:   ACS-3 T13/2161-D revision 5SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)Local Time is:    Fri Feb  7 17:24:40 2020 CSTSMART support is: Available - device has SMART capability.SMART support is: Enabled=== START OF ENABLE/DISABLE COMMANDS SECTION ===SMART Enabled.=== START OF READ SMART DATA SECTION ===SMART Status not supported: ATA return descriptor not supported by controller firmwareSMART overall-health self-assessment test result: PASSEDWarning: This result is based on an Attribute check.General SMART Values:Offline data collection status:  (0x00) Offline data collection activity                    was never started.                    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 collectioncapabilities:            (0x79) SMART execute Offline immediate.                    No Auto Offline data collection 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:    (   1) minutes.Extended self-test routinerecommended polling time:    (   2) minutes.Conveyance self-test routinerecommended polling time:    (   2) minutes.SCT capabilities:          (0x003d) SCT Status supported.                    SCT Error Recovery Control supported.                    SCT Feature Control supported.                    SCT Data Table supported.SMART Attributes Data Structure revision number: 1Vendor Specific SMART Attributes with Thresholds:ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE  5 Reallocated_Sector_Ct   0x0032   100   100   000    Old_age   Always       -       0  9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -       18907 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       16170 Available_Reservd_Space 0x0033   100   100   010    Pre-fail  Always       -       0171 Program_Fail_Count      0x0032   100   100   000    Old_age   Always       -       0172 Erase_Fail_Count        0x0032   100   100   000    Old_age   Always       -       0174 Unsafe_Shutdown_Count   0x0032   100   100   000    Old_age   Always       -       12175 Power_Loss_Cap_Test     0x0033   100   100   010    Pre-fail  Always       -       13590 (125 4176)183 SATA_Downshift_Count    0x0032   100   100   000    Old_age   Always       -       0184 End-to-End_Error        0x0033   100   100   090    Pre-fail  Always       -       0187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0190 Temperature_Case        0x0022   072   068   000    Old_age   Always       -       28 (Min/Max 19/32)192 Unsafe_Shutdown_Count   0x0032   100   100   000    Old_age   Always       -       12194 Temperature_Internal    0x0022   100   100   000    Old_age   Always       -       28197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       0199 CRC_Error_Count         0x003e   100   100   000    Old_age   Always       -       0225 Host_Writes_32MiB       0x0032   100   100   000    Old_age   Always       -       275286226 Workld_Media_Wear_Indic 0x0032   100   100   000    Old_age   Always       -       1638227 Workld_Host_Reads_Perc  0x0032   100   100   000    Old_age   Always       -       1228 Workload_Minutes        0x0032   100   100   000    Old_age   Always       -       1134456232 Available_Reservd_Space 0x0033   100   100   010    Pre-fail  Always       -       0233 Media_Wearout_Indicator 0x0032   099   099   000    Old_age   Always       -       0234 Thermal_Throttle        0x0032   100   100   000    Old_age   Always       -       0/0241 Host_Writes_32MiB       0x0032   100   100   000    Old_age   Always       -       275286242 Host_Reads_32MiB        0x0032   100   100   000    Old_age   Always       -       3597243 NAND_Writes_32MiB       0x0032   100   100   000    Old_age   Always       -       850447SMART Error Log Version: 1No Errors LoggedSMART Self-test log structure revision number 1No self-tests have been logged.  [To run self-tests, use: smartctl -t]SMART Selective self-test log data structure revision number 1 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS    1        0        0  Not_testing    2        0        0  Not_testing    3        0        0  Not_testing    4        0        0  Not_testing    5        0        0  Not_testingSelective self-test flags (0x0):  After scanning selected spans, do NOT read-scan remainder of disk.If Selective self-test is pending on power-up, resume after 0 minute delay.

HP硬盘:

smartctl -s on -d  cciss,0 /dev/cciss/c0d0 开启SMARTsmartctl  -a  -d cciss,0 -i /dev/cciss/c0d0  显示所有SMART信息smartctl  -l error  -d cciss,0 -i /dev/cciss/c0d0 查看磁盘错误日志

演示记录到此,方便工作中查阅

硬盘 设备 检测 类型 代表 日志 时间 服务器 服务 消耗 信息 后台 命令 磁盘 演示 前台 时间短 状态 健康 主板 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 怎全民奇迹技能数据库 小程序数据库地理查询 泰州高防服务器 浙江吹塑零件加工管理软件开发 医院信息网络安全监管记录分析 网络安全问题的问卷调查 软件开发公司测试团队的优势 10分钟服务器安全设置 我的世界离线服务器登录不了 某网站的数据库泄露 5evip选择服务器 二年级上册网络安全绘画 网络安全存在的问题案例分析 奇安信中国网络安全产业联盟 维护无线网络安全 江西网络安全审计工控整机价位 学生网络安全宣传作品大赛 长宁区辅助软件开发报价表 2018国家安全网络安全 魔兽世界多少个服务器 河南企业软件开发哪家好 信息管理与网络技术有关系吗 常州金刚网络技术有限公司 国家网络安全周易班 ecshop的数据库 大连服务器租用 2020网络安全厂家排名 开源数据库实施工程师 网络安全指南和安全评估文档 三级数据库技术证书有什么用
0