科美工业存储论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1136|回复: 1

Linux操作系统下抓取smart信息的方法

[复制链接]

35

主题

44

帖子

334

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
334
发表于 2022-7-11 14:03:36 | 显示全部楼层 |阅读模式
我们经常会遇到Linux操作系统,比如Ubuntu,CentOS,Redhat以及麒麟、UOS统信等。在Linux下,如何检查固态硬盘的SMART信息和其他有用的信息呢?

在这里我们就要用到一个工具smartmontools


1、 安装命令:# yum install smartmontools

2、相关语法:
# smartctl [options] device

2、 查看固态硬盘的信息(是否支持smart)
smartctl -i /dev/sda

3、开启硬盘smart支持

smartctl --smart=on --offlineauto=on --saveauto=on

4、查看固态硬盘的健康状况
smartctl -H /dev/sda

5、显示设备SMART属性和值
显示全部厂商自定义属性和值:smartctl -A /dev/sda
显示全部属性和值:smartctl -a /dev/sda

6、显示硬盘错误信息
smartctl -l error /dev/sda

/、 相关参数
============================================ SHOW INFORMATION OPTIONS =====
  -h, --help, --usage
         Display this help and exit
  -V, --version, --copyright, --license
         Print license, copyright, and version information and exit
  -i, --info
         Show identity information for device
  --identify[=[w][nvb]]
         Show words and bits from IDENTIFY DEVICE data                (ATA)
  -g NAME, --get=NAME
        Get device setting: all, aam, apm, dsn, lookahead, security,
        wcache, rcache, wcreorder, wcache-sct
  -a, --all
         Show all SMART information for device
  -x, --xall
         Show all information for device
  --scan
         Scan for devices
  --scan-open
         Scan for devices and try to open each device
================================== SMARTCTL RUN-TIME BEHAVIOR OPTIONS =====
  -j, --json[=[cgiosuv]]
         Print output in JSON format
  -q TYPE, --quietmode=TYPE                                           (ATA)
         Set smartctl quiet mode to one of: errorsonly, silent, noserial
  -d TYPE, --device=TYPE
         Specify device type to one of:
         ata, scsi[+TYPE], nvme[,NSID], sat[,auto][,N][+TYPE], usbcypress[,X], usbjmicron[,p][,x][,N], usbprolific, usbsunplus, sntjmicron[,NSID], intelliprop,N[+TYPE], marvell, areca,N/E, 3ware,N, hpt,L/M/N, megaraid,N, aacraid,H,L,ID, cciss,N, auto, test
  -T TYPE, --tolerance=TYPE                                           (ATA)
         Tolerance: normal, conservative, permissive, verypermissive
  -b TYPE, --badsum=TYPE                                              (ATA)
         Set action on bad checksum to one of: warn, exit, ignore
  -r TYPE, --report=TYPE
         Report transactions (see man page)
  -n MODE[,STATUS], --nocheck=MODE[,STATUS]                           (ATA)
         No check if: never, sleep, standby, idle (see man page)
============================== DEVICE FEATURE ENABLE/DISABLE COMMANDS =====
  -s VALUE, --smart=VALUE
        Enable/disable SMART on device (on/off)
  -o VALUE, --offlineauto=VALUE                                       (ATA)
        Enable/disable automatic offline testing on device (on/off)
  -S VALUE, --saveauto=VALUE                                          (ATA)
        Enable/disable Attribute autosave on device (on/off)
  -s NAME[,VALUE], --set=NAME[,VALUE]
        Enable/disable/change device setting: aam,[N|off], apm,[N|off],
        dsn,[on|off], lookahead,[on|off], security-freeze,
        standby,[N|off|now], wcache,[on|off], rcache,[on|off],
        wcreorder,[on|off[,p]], wcache-sct,[ata|on|off[,p]]
======================================= READ AND DISPLAY DATA OPTIONS =====
  -H, --health
        Show device SMART health status
  -c, --capabilities                                            (ATA, NVMe)
        Show device SMART capabilities
  -A, --attributes
        Show device SMART vendor-specific Attributes and values
  -f FORMAT, --format=FORMAT                                          (ATA)
        Set output format for attributes: old, brief, hex[,id|val]
  -l TYPE, --log=TYPE
        Show device log. TYPE: error, selftest, selective, directory[,g|s],
        xerror[,N][,error], xselftest[,N][,selftest], background,
        sasphy[,reset], sataphy[,reset], scttemp[sts,hist],
        scttempint,N[,p], scterc[,N,M], devstat[,N], defects[,N], ssd,
        gplog,N[,RANGE], smartlog,N[,RANGE], nvmelog,N,SIZE
  -v N,OPTION , --vendorattribute=N,OPTION                            (ATA)
        Set display OPTION for vendor Attribute N (see man page)
  -F TYPE, --firmwarebug=TYPE                                         (ATA)
        Use firmware bug workaround:
        none, nologdir, samsung, samsung2, samsung3, xerrorlba, swapid
  -P TYPE, --presets=TYPE                                             (ATA)
        Drive-specific presets: use, ignore, show, showall
  -B [+]FILE, --drivedb=[+]FILE                                       (ATA)
        Read and replace [add] drive database from FILE
        [default is +/etc/smartmontools/smart_drivedb.h
         and then    /usr/share/smartmontools/drivedb.h]
============================================ DEVICE SELF-TEST OPTIONS =====
  -t TEST, --test=TEST
        Run test. TEST: offline, short, long, conveyance, force, vendor,N,
                        select,M-N, pending,N, afterselect,[on|off]
  -C, --captive
        Do test in captive mode (along with -t)
  -X, --abort
        Abort any non-captive test on device
=================================================== SMARTCTL EXAMPLES =====
  smartctl --all /dev/sda                    (Prints all SMART information)
  smartctl --smart=on --offlineauto=on --saveauto=on /dev/sda
                                              (Enables SMART on first disk)
  smartctl --test=long /dev/sda          (Executes extended disk self-test)
  smartctl --attributes --log=selftest --quietmode=errorsonly /dev/sda
                                      (Prints Self-Test & Attribute errors)
  smartctl --all --device=3ware,2 /dev/sda
  smartctl --all --device=3ware,2 /dev/twe0
  smartctl --all --device=3ware,2 /dev/twa0
  smartctl --all --device=3ware,2 /dev/twl0
          (Prints all SMART info for 3rd ATA disk on 3ware RAID controller)
  smartctl --all --device=hpt,1/1/3 /dev/sda
          (Prints all SMART info for the SATA disk attached to the 3rd PMPort
           of the 1st channel on the 1st HighPoint RAID controller)
  smartctl --all --device=areca,3/1 /dev/sg2
          (Prints all SMART info for 3rd ATA disk of the 1st enclosure
           on Areca RAID controller)

回复

使用道具 举报

11

主题

16

帖子

91

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
91
发表于 2023-5-30 17:02:50 | 显示全部楼层
2022-02-281.3 MB
2022-02-2870 Bytes

9
2022-02-28801 Bytes

2
2022-02-2858 Bytes

2
2022-02-28801 Bytes

1
2022-02-281.7 MB

632
2022-02-2859 Bytes

3
2022-02-28801 Bytes

7
2022-02-281.0 MB
Totals: 9 Items 4.0 MB
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|科美工业存储论坛

GMT+8, 2024-4-28 13:06 , Processed in 0.087330 second(s), 32 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表