暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Windows 如何获取硬盘 smart 信息

生有可恋 2024-04-24
584

硬盘的 S.M.A.R.T. 信息(Self-Monitoring Analysis and Reporting Technology,自我监测分析与报告技术)是一种用于监控硬盘健康状况的技术。它可以检测硬盘的潜在故障,以便用户及时备份数据并更换硬盘。

一般使用第三方工具检测硬盘 smart 信息,比如:

  • smartmontools

  • DiskGenius

  • hdtune


其中 smartmontools 是命令行工具,windows 、linux 都支持。DiskGenius 是国产工具,hdtune 是国外工具,它俩都有免费版。

先看下 DiskGenius 显示的 smart 信息:

其中有用数据有:

    ------------------------------------
    TOSHIBA Q300. 240.0 GB
    ------------------------------------
    序列号: 46JB3210KC9U
    通电时间: 10904 小时
    通电次数: 441
    温度: 32 ℃
    复制

    使用 smartmontools 工具也可以获得类似的信息:

      C:\> smartctl -a dev/sda


      smartctl 7.4 2023-08-01 r5530 [x86_64-w64-mingw32-w10-22H2] (sf-7.4-1)
      Copyright (C) 2002-23, Bruce Allen, Christian Franke, www.smartmontools.org


      === START OF INFORMATION SECTION ===
      Device Model: TOSHIBA Q300.
      Serial Number: 46JB3210KC9U
      LU WWN Device Id: 5 00080d c004475e1
      Firmware Version: SAFM12.3
      User Capacity: 240,057,409,536 bytes [240 GB]
      Sector Size: 512 bytes logical/physical
      Rotation Rate: Solid State Device
      Form Factor: 2.5 inches
      TRIM Command: Available, deterministic, zeroed
      Device is: Not in smartctl database 7.3/5528
      ATA Version is: ACS-2 (minor revision not indicated)
      SATA Version is: SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
      Local Time is: Tue Apr 23 17:10:59 2024
      SMART support is: Available - device has SMART capability.
      SMART support is: Enabled


      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
      9 Power_On_Hours 0x0012 100 100 000 Old_age Always - 10904
      12 Power_Cycle_Count 0x0012 100 100 000 Old_age Always - 441
      167 Unknown_Attribute 0x0022 100 100 000 Old_age Always - 0
      168 Unknown_Attribute 0x0012 100 100 000 Old_age Always - 0
      169 Unknown_Attribute 0x0003 100 100 010 Pre-fail Always - 0
      173 Unknown_Attribute 0x0012 199 199 000 Old_age Always - 0
      192 Power-Off_Retract_Count 0x0012 100 100 000 Old_age Always - 69
      194 Temperature_Celsius 0x0023 068 054 020 Pre-fail Always - 32 (Min/Max 8/46)
      复制

      smartmontools 获取地址:

        https://www.smartmontools.org/
        复制

        另外有一个 python 库对 smartmontools 的数据做了处理,可以单独获取指定值:

          C:\> pip install pySMART
          复制
            from pySMART import Device, DeviceList


            # 获取所有硬盘的列表
            devices = DeviceList()


            # 打印每个硬盘的SMART信息
            for device in devices:
            print("Device:", device.name)
            print("Model:", device.model)
            print("Serial:", device.serial)
            print("Size:", device.size_raw)
            print("SMART attributes:")
            for attribute in device.attributes:
            if attribute and attribute.name != 'Unknown_Attribute':
            print(" {}: {}".format(attribute.name, attribute.raw))
            复制

            Python 脚本运行效果为:

              d:\>python getSmart.py
              Device: sda
              Model: TOSHIBA Q300.
              Serial: 46JB3210KC9U
              Size: 240 GB
              SMART attributes:
              Power_On_Hours: 10904
              Power_Cycle_Count: 441
              Power-Off_Retract_Count: 69
              Temperature_Celsius: 31 (Min/Max 8/46)
              复制

              硬盘 smart 信息里没有硬盘出厂日期, 硬盘出厂日期只能通过硬盘外部的贴纸获取,也可以基于序列号在硬盘品牌的官网查询。通过 smart 信息可以估算出硬盘的使用频率,比如通电时长、启停次数、异常断电次数。

              全文完。

              如果转发本文,文末务必注明:“转自微信公众号:生有可恋”。

              文章转载自生有可恋,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

              评论