硬盘管理工具介绍:smartctl

一、安装命令

[[email protected] scripts]# smartctl --all /dev/sda
-bash: smartctl: 未找到命令

[[email protected] scripts]# yum search smartctl -y
已加载插件:fastestmirror
Loading 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

[[email protected] 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类型的所有设备:

[[email protected] 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

[[email protected] 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.org

Smartctl open device: /dev/sda1 failed: DELL or MegaRaid controller, please try adding ‘-d megaraid,N‘

由于演示的服务器是dell的,同时事先给这个机器的2块ssd硬盘做了raid0的
[[email protected] 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-0
Size                : 223.0 GB
State               : Optimal
Strip Size          : 64 KB
Number Of Drives    : 1
--
Virtual Drive Information:
Virtual Drive: 1 (Target Id: 1)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 223.0 GB
State               : Optimal
Strip Size          : 64 KB
Number Of Drives    : 1

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

[[email protected] scripts]#  smartctl -i /dev/sda1  -d megaraid,0
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 SSDs
Device Model:     INTEL SSDSC2BB240G7
Serial Number:    PHDV7234023C240AGN
LU WWN Device Id: 5 5cd2e4 14e0aaaf5
Firmware Version: N2010112
User Capacity:    240,057,409,536 bytes [240 GB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    Solid State Device
Form Factor:      2.5 inches
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-3 T13/2161-D revision 5
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Fri Jan 17 17:13:49 2020 CST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

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

[[email protected] ~]# 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 SD8SBAT256G1122
Serial Number:    161855404280
LU WWN Device Id: 5 001b44 4a4b8c6ca
Firmware Version: Z2333000
User Capacity:    256,060,514,304 bytes [256 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Form Factor:      2.5 inches
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ACS-2 T13/2015-D revision 3
SATA Version is:  SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Fri Jan 17 17:35:09 2020 CST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

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

[[email protected] ~]# 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 SD8SBAT256G1122
Serial Number:    161855404280
LU WWN Device Id: 5 001b44 4a4b8c6ca
Firmware Version: Z2333000
User Capacity:    256,060,514,304 bytes [256 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Form Factor:      2.5 inches
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ACS-2 T13/2015-D revision 3
SATA Version is:  SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Fri Jan 17 17:40:50 2020 CST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

SMART Error Log Version: 1
No Errors Logged

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


[[email protected] ~]# smartctl -a /dev/sda
[[email protected] ~]# smartctl -A /dev/sda1 -d megaraid,0
[[email protected] ~]# smartctl -a /dev/sda1 -d megaraid,0
[[email protected] ~]# 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 SSDs
Device Model:     INTEL SSDSC2BB240G7
Serial Number:    PHDV7234023C240AGN
LU WWN Device Id: 5 5cd2e4 14e0aaaf5
Firmware Version: N2010112
User Capacity:    240,057,409,536 bytes [240 GB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    Solid State Device
Form Factor:      2.5 inches
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-3 T13/2161-D revision 5
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Fri Feb  7 17:24:40 2020 CST
SMART 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 firmware
SMART overall-health self-assessment test result: PASSED
Warning: 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 collection
capabilities:            (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 routine
recommended polling time:    (   2) minutes.
Conveyance self-test routine
recommended 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: 1
Vendor 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       -       16
170 Available_Reservd_Space 0x0033   100   100   010    Pre-fail  Always       -       0
171 Program_Fail_Count      0x0032   100   100   000    Old_age   Always       -       0
172 Erase_Fail_Count        0x0032   100   100   000    Old_age   Always       -       0
174 Unsafe_Shutdown_Count   0x0032   100   100   000    Old_age   Always       -       12
175 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       -       0
184 End-to-End_Error        0x0033   100   100   090    Pre-fail  Always       -       0
187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0
190 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       -       12
194 Temperature_Internal    0x0022   100   100   000    Old_age   Always       -       28
197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       0
199 CRC_Error_Count         0x003e   100   100   000    Old_age   Always       -       0
225 Host_Writes_32MiB       0x0032   100   100   000    Old_age   Always       -       275286
226 Workld_Media_Wear_Indic 0x0032   100   100   000    Old_age   Always       -       1638
227 Workld_Host_Reads_Perc  0x0032   100   100   000    Old_age   Always       -       1
228 Workload_Minutes        0x0032   100   100   000    Old_age   Always       -       1134456
232 Available_Reservd_Space 0x0033   100   100   010    Pre-fail  Always       -       0
233 Media_Wearout_Indicator 0x0032   099   099   000    Old_age   Always       -       0
234 Thermal_Throttle        0x0032   100   100   000    Old_age   Always       -       0/0
241 Host_Writes_32MiB       0x0032   100   100   000    Old_age   Always       -       275286
242 Host_Reads_32MiB        0x0032   100   100   000    Old_age   Always       -       3597
243 NAND_Writes_32MiB       0x0032   100   100   000    Old_age   Always       -       850447

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No 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_testing
Selective 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 开启SMART
smartctl  -a  -d cciss,0 -i /dev/cciss/c0d0  显示所有SMART信息
smartctl  -l error  -d cciss,0 -i /dev/cciss/c0d0 查看磁盘错误日志

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

原文地址:https://blog.51cto.com/wujianwei/2469687

时间: 2024-10-17 11:36:46

硬盘管理工具介绍:smartctl的相关文章

pstree,ps,top,htop,vmastp,pmap,glances,dstat进程管理工具介绍

htop,glances,dstat进程管理工具介绍 1.htop 工具 htop常用交互命令 M:以memory排序 P:以cpu占用比排序 T:以cpu占用时长排序 u:过滤仅显示选定用户的进程: s:跟踪选定的进程所发起的系统调用: l:显示指定进程打开的文件 t:显示进程树格式 a:将选定的进程绑定在指定的CPU上 2.glances: glances[-bdehmnrsvyz1] [-B bind] [-c server] [-C conffile] [-p port] [-P pas

logstash+elastic+kibana日志管理工具介绍及安装

logstash+elastic+kibana日志管理工具介绍及安装 一. Logstash 安装 1.1 前置条件,安装了官方java 7或更新版本 查看 [ldx@1511-min ~]$ java -version openjdk version "1.8.0_71" OpenJDK Runtime Environment (build 1.8.0_71-b15) OpenJDK 64-Bit Server VM (build 25.71-b15, mixed mode) 1.2

[CoreOS]CoreOS 实战:CoreOS 及管理工具介绍

转载:http://www.infoq.com/cn/articles/what-is-coreos [编者按]CoreOS是一个基于Docker的轻量级容器化Linux发行版,专为大型数据中心而设计,旨在通过轻量的系统架构和灵活的应用程序部署能力简化数据中心的维护成本和复杂度.CoreOS作为Docker生态圈中的重要一员,日益得到各大云服务商的重视,目前已经完成了A轮融资,发展风头正劲.InfoQ希望<CoreOS实战>系列文章能够帮助读者了解CoreOS以及相关的使用方法.如果说Dock

Linux环境:fdisk 及parted磁盘分区管理工具介绍

1. fdisk分区工具及实质 2.查看磁盘分区信息 3.查看磁盘分区cat /proc/partitions ll /dev/sd* 4.parted 磁盘分区管理工具介绍 原文地址:https://blog.51cto.com/14298876/2381948

ASP.NET 网站管理工具介绍

有没有感觉对 web.config 的操作很烦呢? 老是手动来编辑 web.config 确实挺麻烦的, 不过自 ASP.NET 2.0 起便有了 ASP.NET 网站管理工具, 这个工具呢,其实就是一个操作 web.config 的 GUI , 您在这个 ASP.NET 网站管理工具中的一些设置 基本上都会反映会 web.config 中, 所以在这里便顺着道介绍一下, 首先,您要设置 web.config 那是针对一个项目的, 所以您也必须针对一个项目来调出 ASP.NET 网站管理工具,

OSI七层模型和TCP/IP五层模型、iproute家族命令、管理工具介绍

1.简述osi七层模型和TCP/IP五层模型网络协议通常分不同层次进行开发,每一层分别负责不同的通行功能. 1.1 OSI七层模型OSI:Open System Internetconnection(开放系统互联),由ISO国际标准化组织定义:目的是规范网络环境,实现软硬件兼容:自上而下共分为七层,分别为:应用层,表示层,会话层,传输层,网络层,数据链路层,物理层. 应用层:各种应用程序及接口 表示层:对数据进行转换,加密.压缩 会话层:维持不同应用程序的数据分离 传输层:提供可靠的端到端的报文

docker图像管理工具介绍

docker集群管理工具包括:Kubernetes.Mesos,Rancher,Swarm,其中图形管理工具包含Kubernetes.Mesos,Rancher.swarm暂时不提供web界面. Kubernetes是google开源的多主机容器管理工具, 简称:k8s,它带有人性化图形管理界面, 它在开源社区很受欢迎github上已经有了20000+的收藏,和7000+的fork. https://github.com/kubernetes/kubernetes Mesos是Apache下的开

Python包管理工具介绍

常见的包管理工具及关系 setuptools -->distribute easy_install-->pip 1.distribute distribute是对标准库disutils模块的增强,我们知道disutils主要是用来更加容易的打包和分发包,特别是对其他的包有依赖的包.distribute被创建是因为setuptools包不再维护了. 主页:https://pypi.python.org/pypi/distribute 安装及使用 wget https://pypi.python.

Linux的包管理工具介绍

程序包管理: 将编译好的应用程序的各组成文件打包一个或几个程序包文件,从而方便快捷地实现程序包的安装.卸载.查询.升级和校验等管理操作: 获取程序包的途径 (1)系统发版的光盘或官方的服务器: CentOS镜像: http://mirrors.aliyun.com http://mirrors.sohu.com http://mirrors.163.com (2) 项目官方站点 (3) 第三方组织: Fedora-EPEL 搜索引擎: http://pkgs.org http://rpmfind