Monday, April 20, 2015

Linux Command To Find SATA Link Speed Such as 1.5 / 3.0 / 6.0 Gbps [ Hard Disk ]

http://www.cyberciti.biz/faq/linux-command-to-find-sata-harddisk-link-speed

How do I find out my SATA link speed? How do I make sure my sata hard disk is working at 6Gbps speed and how do I verify this on a Linux server running on HP or IBM amd64 hardware?

You need to go through the dmesg command output or a log file called /var/log/messages. You can also use smartctl command to find out information about hard disk and current link speed on Linux based system.
Tutorial details
DifficultyEasy (rss)
Root privilegesYes
RequirementsNone
Estimated completion time2m

A note about SATA revision

  • SATA REVISION => SPEED ({Gbit|MB}/s)
  • SATA revision 1.0 => 1.5 Gbit/s, 150 MB/s
  • SATA revision 2.0 => 3 Gbit/s, 300 MB/s
  • SATA revision 3.0 => 6 Gbit/s, 600 MB/s
  • SATA revision 3.2 => 16 Gbit/s, 1969 MB/s

dmesg command examples

Open the Terminal or login using ssh command and than type the following command:
 
dmesg | grep -i sata | grep 'link up'
 
Sample outputs:
[   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)
Here is another example:
 
dmesg | grep -i --color ahci
dmesg | grep -i  ahci | grep -i --color Gbps
 
Sample outputs:
[    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
You can find same info using /var/log/messages:
# grep -i SATA /var/log/messages | grep --color -i 'link up'
Sample outputs:
Sep  2 14:56:50 wks01 kernel: [25518.962661] ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
Sep  2 14:56:50 wks01 kernel: [25520.158303] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
Sep  2 14:56:50 wks01 kernel: [25521.117722] ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
Sep  2 22:09:06 wks01 kernel: [    3.451270] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
Sep  2 22:09:06 wks01 kernel: [    3.823019] ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
Sep  2 22:09:06 wks01 kernel: [    4.154815] ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
Sep  3 04:14:11 wks01 kernel: [    3.486897] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
Sep  3 04:14:11 wks01 kernel: [    3.858745] ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
Sep  3 04:14:11 wks01 kernel: [    4.186682] ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
Sep  3 09:17:10 wks01 kernel: [    3.538938] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
Sep  3 09:17:10 wks01 kernel: [    3.906824] ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
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)

smartctl command example

Type the following command as root user:
 
smartctl -a /dev/DEVICE-NAME-HERE
smartctl -a /dev/sda | grep "^SATA"
smartctl -a /dev/sda
 
Sample outputs:
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

Putting it all together

Gif 01: Linux commands to find out SATA link speed
Gif 01: Linux commands to find out SATA link speed

hdparm command demo

To get SATA hard disk link speed, type:
 
sudo hdparm -I /dev/DEVICE-NAME-HERE | egrep "Model|speed"
sudo hdparm -I /dev/sda | egrep "Model|speed|Transport"
 
Sample outputs:
	Model Number:       WDC WD1600BEVS-08VAT2
	Transport:          Serial, SATA 1.0a, SATA II Extensions, SATA Rev 2.5
	   *	Gen1 signaling speed (1.5Gb/s)

A shell script to find out the same info

#/bin/sh
# findstatlink.sh : This script is contributed by Shawn Hicks at
# http://www.cyberciti.biz/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 $1/gie' | echo "    " Device `strings` | cut -f 1-3
done
 
Sample outputs:
./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

No comments:

Post a Comment