Linux命令查看SATA硬盘链接的速度

时间:2020-01-09 10:41:21  来源:igfitidea点击:

如何查看我的SATA硬盘的速度?如何确定sata硬盘的工作速度为6Gbps,如何在HP或IBM amd64硬件上运行的Linux服务器上进行验证?

说明:您需要浏览dmesg命令输出或名为/var/log/messages/var/log/syslog的日志文件。您还可以使用smartctl命令查找有关基于Linux的系统上的硬盘和当前链接速度的信息。

关于SATA版本的说明

  • SATA REVISION - SPEED({Gbit | MB}/s)`
  • SATA版本1.0 - 1.5 Gbit/s,150 MB/s
  • SATA 2.0版- 3 Gbit/s,300 MB/s
  • SATA 3.0版- 6 Gbit/s,600 MB/s
  • SATA版本3.2 - 16 Gbit/s,1969 MB/s

Linux命令以查找SATA链接速度,例如1.5/3.0/6.0/16.0 Gbps

您需要使用以下命令:

  • dmesg命令显示Linux内核环形缓冲区。
  • smartctl命令用于控制和监视SMART硬盘或SSD的命令。

让我们详细查看所有示例。

dmesg命令示例

打开终端或使用ssh命令登录,然后执行以下命令:

dmesg | grep -i sata | grep 'link up'

输出示例:

[   18.120000] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl F300)
[   39.530000] ata2: SATA link up 3.0 Gbps (SStatus 123 SControl F300)

这是另一个示例:

dmesg | grep -i --color ahci
dmesg | grep -i  ahci | grep -i --color Gbps

输出示例:

[    1.161418] ahci 0000:00:11.0: version 3.0
[    1.161713] ahci 0000:00:11.0: irq 72 for MSI/MSI-X
[    1.161776] ahci 0000:00:11.0: AHCI 0001.0300 32 slots 1 ports 6 Gbps 0x1 impl SATA mode
[    1.161783] ahci 0000:00:11.0: flags: 64bit ncq sntf ilck pm led clo pmp fbs pio slum part 
[    1.162116] scsi0 : ahci

您可以使用/var/log/messages找到相同的信息:

# grep -i SATA /var/log/messages | grep --color -i 'link up'

输出示例:

Sep  3 09:17:10 wks01 kernel: [    4.234739] ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
Sep  4 04:13:33 wks01 kernel: [    3.510810] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
Sep  4 04:13:33 wks01 kernel: [    3.878764] ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
Sep  4 04:13:33 wks01 kernel: [    4.206646] ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300)

请注意,在现代Linux发行版上,/var/log/messages可能被/var/log/syslog代替:

# grep -i SATA /var/log/syslog | grep --color -i 'link up'

使用smartctl命令找出Linux上的SATA速度信息

以root用户身份执行以下命令:

sudo smartctl -a /dev/DEVICE-NAME-HERE
sudo smartctl -i /dev/DEVICE-NAME-HERE
sudo smartctl -a /dev/sda | grep "^SATA"
sudo smartctl -i /dev/sdb | grep "^SATA"
sudo smartctl -a /dev/sda
sudo smartctl -i /dev/sdb

输出示例:

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.11.10-301.fc20.x86_64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Hitachi/HGST Travelstar Z7K500
Device Model:     HGST HTS725050A7E630
Serial Number:    REMOVED
LU WWN Device Id: 5 000cca 77edc5bc0
Firmware Version: GH2ZB550
User Capacity:    500,107,862,016 bytes [500 GB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    7200 rpm
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ATA8-ACS T13/1699-D revision 6
SATA Version is:  SATA 2.6, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Sat May 31 02:49:23 2014 IST
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

使用hdparm命令查找Linux SATA链接速度

要获得SATA硬盘链接速度,请执行:

sudo hdparm -I /dev/DEVICE-NAME-HERE | egrep "Model|speed"
sudo hdparm -I /dev/sda | egrep "Model|speed|Transport"

输出示例:

Model Number:       WDC WD1600BEVS-08VAT2                   
	Transport:          Serial, SATA 1.0a, SATA II Extensions, SATA Rev 2.5
	   *	Gen1 signaling speed (1.5Gb/s)

一个shell脚本,用于查找Linux stata端口速度信息

#/bin/sh
# findstatlink.sh : This script is contributed by Shawn Hicks at
# https://www.theitroad.local/faq/linux-command-to-find-sata-harddisk-link-speed/#comment-114440
# -----
for i in `grep -l Gbps /sys/class/ata_link/*/sata_spd`; do
echo Link "${i%/*}" Speed `cat $i`
cat "${i%/*}"/device/dev*/ata_device/dev*/id | perl -nE 's/([0-9a-f]{2})/print chr hex /gie' | echo "    " Device `strings` | cut -f 1-3
done

输出示例:

./findstatlink.sh
Link /sys/class/ata_link/link2 Speed 3.0 Gbps
     Device 9WM0xxxx CC12 ST32000641AS )4k} Ac4i
Link /sys/class/ata_link/link3 Speed 3.0 Gbps
     Device 9WM0yyyy CC12 ST32000641AS )4k} Ac4i
Link /sys/class/ata_link/link4 Speed 3.0 Gbps
     Device 9WM0zzzz CC12 ST32000641AS )4k} Ac4i
Link /sys/class/ata_link/link5 Speed 3.0 Gbps
     Device S1E0bbbb CC24 ST2000DM001-1CH164 )4k} Ac4i Ac@
Link /sys/class/ata_link/link6 Speed 3.0 Gbps
     Device 9WM0cccc CC12 ST32000641AS )4k} Ac4i