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

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_VALUE1 Raw_Read_Error_Rate     0x002f   100   100   051    Pre-fail  Always       -       62 Throughput_Performance  0x0027   252   252   000    Pre-fail  Always       -       03 Spin_Up_Time            0x0023   095   091   025    Pre-fail  Always       -       16514 Start_Stop_Count        0x0032   096   096   000    Old_age   Always       -       44785 Reallocated_Sector_Ct   0x0033   252   252   010    Pre-fail  Always       -       07 Seek_Error_Rate         0x002f   252   252   051    Pre-fail  Always       -       08 Seek_Time_Performance   0x0025   252   252   015    Pre-fail  Offline      -       09 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -       1228410 Spin_Retry_Count        0x0033   252   252   051    Pre-fail  Always       -       011 Calibration_Retry_Count 0x0032   100   100   000    Old_age   Always       -       17512 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 Temperature190 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.lryc.cn/news/449808.html

相关文章:

  • BBR 为什么没有替代 CUBIC 成为 Linux 内核缺省算法
  • Git忽略规则原理和.gitignore文件不生效的原因和解决办法
  • MySQL-数据库设计
  • Unity开发绘画板——04.笔刷大小调节
  • ./mnt/container_run_medium.sh
  • 数学建模研赛总结
  • 通信工程学习:什么是TCF技术控制设施
  • stm32 bootloader跳转程序设计
  • 科技赋能环保:静电与光解技术在油烟净化中的卓越应用
  • FCA-FineBI试卷答案
  • Spring - @Import注解
  • 新能源汽车储充机器人:能源高效与智能调度
  • 【Linux网络】详解TCP协议(2)
  • STM32DMA学习日记
  • 【高性能内存池】page cache 5
  • Vue 3 魔法揭秘:CSS 解析与 scoped 背后的奇幻之旅
  • 如何获取钉钉webhook
  • 网页WebRTC电话和软电话哪个好用?
  • MySQL Mail服务器集成:如何配置发送邮件?
  • 【Rockchip系列】官方函数:imcopy
  • Matlab实现鲸鱼优化算法优化回声状态网络模型 (WOA-ESN)(附源码)
  • 迈威通信闪耀工博会,以创新科技赋能工业自动化
  • C# DotNetty客户端
  • 4G模组SIM卡电路很简单,但也要注意这些坑
  • 常见电脑品牌BIOS设置与进入启动项快捷键
  • C语言中的日志机制:打造全面强大的日志系统
  • 局域网广域网,IP地址和端口号,TCP/IP 4层协议,协议的封装和分用
  • LabVIEW项目编码器选择
  • Spring Boot实现房产租赁业务逻辑
  • 汽车3d动画渲染选择哪个?选择最佳云渲染解决方案