zl程序教程

您现在的位置是:首页 >  工具

当前栏目

smartctl命令详解_smartmontools

命令 详解 smartctl
2023-06-13 09:14:59 时间

安装smartctl

ubuntu系统安装方法。

root@gucloud:~# apt install smartmontools  
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  gsmartcontrol smart-notifier mailx | mailutils
The following NEW packages will be installed:
  smartmontools
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 525 kB of archives.
After this operation, 2,087 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 smartmontools amd64 7.1-1build1 [525 kB]
Fetched 525 kB in 4s (130 kB/s)        
Selecting previously unselected package smartmontools.
(Reading database ... 147536 files and directories currently installed.)
Preparing to unpack .../smartmontools_7.1-1build1_amd64.deb ...
Unpacking smartmontools (7.1-1build1) ...
Setting up smartmontools (7.1-1build1) ...
Created symlink /etc/systemd/system/smartd.service → /lib/systemd/system/smartmontools.service.
Created symlink /etc/systemd/system/multi-user.target.wants/smartmontools.service → /lib/systemd/system/smartmontools.service.
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for systemd (245.4-4ubuntu3.4) ...
root@gucloud:~# smartctl --version  //查看版本
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.4.0-65-generic] (local build)

如果是centos7以上系统可以使用 #yum -y install smartmontools

smartctl简单用法

-a //查看全部信息

root@gucloud:~# smartctl -a /dev/sda  //查看sda所有信息
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.4.0-65-generic] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     Qunion P20A 128G   //设备名称
Serial Number:    XSRQ2020011574   //SN码
LU WWN Device Id: 0 000000 000000000
Firmware Version: 1.00
User Capacity:    128,035,676,160 bytes [128 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-4 (minor revision not indicated)
SATA Version is:  SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s) 
Local Time is:    Thu Feb 18 06:43:20 2021 UTC
SMART support is: Available - device has SMART capability.
SMART support is: Enabled  //已开启smart

=== START OF READ SMART DATA SECTION ===

-H //查看硬盘健康状态

root@gucloud:~# smartctl -H /dev/sda 
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.4.0-65-generic] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED  //提示passed成功,Failure失败

-i 简要显示硬盘信息

root@gucloud:~# smartctl -i /dev/sda
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.4.0-65-generic] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     Qunion P20A 128G
Serial Number:    XSRQ2020011574
LU WWN Device Id: 0 000000 000000000
Firmware Version: 1.00
User Capacity:    128,035,676,160 bytes [128 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-4 (minor revision not indicated)
SATA Version is:  SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Thu Feb 18 06:56:49 2021 UTC
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

使用hdparm测试

hdparm参数介绍

a<快取分区> 设定读取文件时,预先存入块区的分区数,若不加上<快取分区>选项,则显示目前的设定。

-A<0或1> 启动或关闭读取文件时的快取功能。

-c<I/O模式> 设定IDE32位I/O模式。

-C 检测IDE硬盘的电源管理模式。-d<0或1> 设定磁盘的DMA模式。

-f 将内存缓冲区的数据写入硬盘,并清楚缓冲区。

-g 显示硬盘的磁轨,磁头,磁区等参数。

-h 显示帮助。

-i 显示硬盘的硬件规格信息,这些信息是在开机时由硬盘本身所提供。

-I 直接读取硬盘所提供的硬件规格信息。

-k<0或1> 重设硬盘时,保留-dmu参数的设定。

-K<0或1> 重设硬盘时,保留-APSWXZ参数的设定。

-m<磁区数> 设定硬盘多重分区存取的分区数。

-n<0或1> 忽略硬盘写入时所发生的错误。

-p<PIO模式> 设定硬盘的PIO模式。

-P<磁区数> 设定硬盘内部快取的分区数。

-q 在执行后续的参数时,不在屏幕上显示任何信息。

-r<0或1> 设定硬盘的读写模式。

-S<时间> 设定硬盘进入省电模式前的等待时间。

-t 评估硬盘的读取效率。

-T 评估硬盘快取的读取效率。

-u<0或1> 在硬盘存取时,允许其他中断要求同时执行。

-v 显示硬盘的相关设定。

-W<0或1> 设定硬盘的写入快取。

-X<传输模式> 设定硬盘的传输模式。

-y 使IDE硬盘进入省电模式。

-Y 使IDE硬盘进入睡眠模式。

-Z 关闭某些Seagate硬盘的自动省电功能。

测试单个硬盘的读写速度。

root@gucloud:~# hdparm -tT /dev/sda

/dev/sda:
 Timing cached reads:   26504 MB in  2.00 seconds = 13267.32 MB/sec
 Timing buffered disk reads: 1214 MB in  3.00 seconds = 404.10 MB/sec

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/184729.html原文链接:https://javaforall.cn