当前位置: 首页 > article >正文

smartctl 命令:查看硬盘健康状态

一、命令简介

smartctl​ 命令用于获取硬盘的 SMART 信息。

介绍硬盘SMART

硬盘的 SMART (Self-Monitoring, Analysis, and Reporting Technology) 技术用于监控硬盘的健康状态,并能提供一些潜在故障的预警信息。通过查看 SMART 数据,用户可以了解硬盘的各种属性和状态,如错误率、温度、使用寿命等。

安装smartctl

sudo install smartmontools

检查硬盘的 SMART 状态

sudo smartctl -a /dev/sda

更详细的用例请参考后继章节

与硬盘相关命令

  • gdisk、fdisk 命令,磁盘分区管理。
  • mkfs 命令,格式化。
  • mdadm 命令,管理软 RAID。
  • lsblk 命令,列出块设备(包含磁盘)信息。
  • df 命令,磁盘余量
  • smartctl 命令,读取磁盘 SMART 信息

二、命令参数

格式

smartctl 选项 硬盘

需要sudo权限运行。

选项

  • -a, --all​:显示所有 SMART 信息。
  • -H, --health​:显示硬盘的健康状态。
  • -i, --info​:显示硬盘的基本信息。
  • -l selftest​:显示自检结果。
  • -t <test>​:启动自检,如 short​(短自检)或 long​(长自检)。
  • -c, --capabilities​:显示硬盘的 SMART 能力。
  • -x, --xall​:显示扩展 SMART 信息。
  • -l error​:显示错误日志。
  • -A, --attributes​:显示 SMART 属性。
  • -s, --smart=on|off​:启用或禁用 SMART 功能。
  • -d, --device=TYPE​:指定硬盘的接口类型,如 ata​, scsi​, sat​, nvme​ 等。

参数

  • /dev/sdX​:指定要检查的硬盘设备路径,如 /dev/sda​。
  • test​:自检类型,如 short​, long​。
  • TYPE​:硬盘接口类型,如 ata​, scsi​, sat​, nvme​。

三、命令示例

显示硬盘的基本信息

sudo smartctl -i /dev/sdX

输出
image

显示硬盘的 SMART 属性

sudo smartctl -A /dev/sdX

输出

soulio@k455l:~$ sudo smartctl -A /dev/sdb
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-6.5.0-35-generic] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

=== 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     0x002f   100   100   051    Pre-fail  Always       -       6
  2 Throughput_Performance  0x0027   252   252   000    Pre-fail  Always       -       0
  3 Spin_Up_Time            0x0023   095   091   025    Pre-fail  Always       -       1651
  4 Start_Stop_Count        0x0032   096   096   000    Old_age   Always       -       4478
  5 Reallocated_Sector_Ct   0x0033   252   252   010    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x002f   252   252   051    Pre-fail  Always       -       0
  8 Seek_Time_Performance   0x0025   252   252   015    Pre-fail  Offline      -       0
  9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -       12284
 10 Spin_Retry_Count        0x0033   252   252   051    Pre-fail  Always       -       0
 11 Calibration_Retry_Count 0x0032   100   100   000    Old_age   Always       -       175
 12 Power_Cycle_Count       0x0032   097   097   000    Old_age   Always       -       3057
181 Program_Fail_Cnt_Total  0x0022   100   100   000    Old_age   Always       -       9022488
183 Runtime_Bad_Block       0x0032   252   252   010    Old_age   Always       -       0
184 End-to-End_Error        0x0033   252   252   048    Pre-fail  Always       -       0
186 Unknown_Attribute       0x0032   252   252   000    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   252   252   000    Old_age   Always       -       0
188 Command_Timeout         0x0032   252   252   000    Old_age   Always       -       0
190 Airflow_Temperature_Cel 0x0002   066   050   040    Old_age   Always       -       34 (Min/Max 8/50)
191 G-Sense_Error_Rate      0x0022   100   100   000    Old_age   Always       -       77
192 Power-Off_Retract_Count 0x0022   100   100   000    Old_age   Always       -       79
193 Load_Cycle_Count        0x0032   001   001   000    Old_age   Always       -       1103480
194 Temperature_Celsius     0x0002   064   050   000    Old_age   Always       -       34 (Min/Max 8/50)
195 Hardware_ECC_Recovered  0x003a   100   100   000    Old_age   Always       -       0
196 Reallocated_Event_Count 0x0032   252   252   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   252   252   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   252   252   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0036   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x002a   100   100   000    Old_age   Always       -       1663

启动短自检

sudo smartctl -t short /dev/sdX

输出

soulio@k455l:~$ sudo smartctl -t /dev/sdb
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-6.5.0-35-generic] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

=======> INVALID ARGUMENT TO -t: /dev/sdb
=======> VALID ARGUMENTS ARE: offline, short, long, conveyance, force, vendor,N, select,M-N, pending,N, afterselect,[on|off] <=======

Use smartctl -h to get a usage summary

获取硬盘温度

sudo smartctl -a /dev/sdX | grep Temperature

输出
image

启用 SMART 功能

sudo smartctl -s on /dev/sdX

默认就是打开的。

指明硬盘类型

有时我们使用 USB 外挂的硬盘,使用 smartctl 命令可能会提示“无法识别磁盘类型”。需要使用 -d​ 参数手动指明硬盘类型,比如 sat​ 类型。

$ sudo smartctl -d sat -a /dev/sdc | grep Temperature

190 Airflow_Temperature_Cel 0x0022   058   047   045    Old_age   Always       -       42 (Min/Max 18/42)
194 Temperature_Celsius     0x0022   042   053   000    Old_age   Always       -       42 (0 4 0 0 0)


http://www.kler.cn/news/326880.html

相关文章:

  • 【低功耗防山火在线监测装置】
  • nginx相关操作
  • selenium模块入门
  • 【Rust练习】16.方法和关联函数
  • helm部署ingress-nginx
  • Docker-2.如何保存数据退出
  • 什么是文件完整性监控(FIM)
  • ComfyUI新版本快捷键大全,快速提升效率,建议收藏
  • CMake教程(八):添加定制命令和生成的文件
  • 如何使用ssm实现白云会议管理系统+vue
  • mysql学习教程,从入门到精通,SQL 修改表(ALTER TABLE 语句)(29)
  • AI驱动TDSQL-C Serverless 数据库技术实战营-与AI的碰撞
  • Android 属性contentDescription详解
  • 斩获亚马逊“商采转型之星”奖 ,益而益(ELEGRP)品牌出海正当时
  • fatfs API使用手册
  • 《深度学习》卷积神经网络CNN 实现手写数字识别
  • 【C++打怪之路Lv4】-- 类和对象(中)
  • 方法 WebDriverWait
  • Java应用文件上传超出默认大小
  • 【888题竞赛篇】第十二题,2024ICPC网络赛第二场-游戏(Game)
  • 【容器云】容器云设计方案
  • Linux编译部署PHP环境
  • 冒泡排序-C语言
  • 程序员如何提升核心竞争力——深度耕耘与软技能的培养》
  • HTML元素居中
  • 一款好用的远程连接工具:MobaXterm
  • Xcdoe快速更新安装的小Tips
  • 工业制造场景中的设备管理深度解析
  • QT-文件创建时间修改器
  • 安全运营 -- GPO审计