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

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?

Introduction: You need to go through the dmesg command output or a log file called /var/log/messages or /var/log/syslog. You can also use smartctl command to find out information about hard disk and current link speed on Linux based system. [donotprint]
Tutorial details
Difficulty Easy (rss)
Root privileges Yes
Requirements None
Time 2m
[/donotprint]

ADVERTISEMENTS

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

Linux Command To Find SATA Link Speed Such as 1.5 / 3.0 / 6.0 / 16.0 Gbps

You need to use the following commands:

  1. dmesg command – Display the Linux kernel ring buffer.
  2. smartctl command – Control and monitor command for SMART hard disks or SSDs.

Let us see all examples in details.

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)

Please note that on modern Linux distro /var/log/messages may be replaced with /var/log/syslog:
# grep -i SATA /var/log/syslog | grep --color -i 'link up'

Use smartctl command to find out SATA speed info on Linux

Type the following command as root user:

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

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

Find Linux SATA link speed with hdparm command

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 Linux stata port speed info

#/bin/sh
# findstatlink.sh : This script is contributed by Shawn Hicks at
# https://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

Here is outputs from all of above commands:
Linux Command To Find SATA Link Speed for Hard Disk and SSD

Conclusion

And there you have it; now you know how to find out your SATA link speed on Linux. The higher disk speed means a smoother experience for you on the desktop or a better server response for your web apps.

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
15 comments… add one
  • ashwani Sep 5, 2012 @ 0:35

    Hi,

    How to know speed of my external usb HDD is there any specific command?

    thanks

  • Balachander Ganesan Sep 5, 2012 @ 6:05

    Ashwani the most reliable method is to copy a big file say 4GB or so.
    From your system to external HDD and check iostat.
    However, your internal HDD should be fast enough and system shouldn’t be loaded.
    I trust this method :)

  • Petrinko Philippe Sep 5, 2012 @ 8:50

    Interesting, but then, I would like to know more:
    – How to you toggle to higher bit rate when/if possible?
    – How do you link these message to your drives? For instance, you have here “ata3” link, how does this links to any /dev/sd.. ?
    TIA,
    — P

    • 🐧 nixCraft Sep 6, 2012 @ 0:02

      How to you toggle to higher bit rate when/if possible?

      You need to pass boot time kernel parameters using grub. Search libata.force using this doc. Example to force 1.5G and 3.0G: libata.force=1:3.0G,2:1.5G

      How do you link these message to your drives? For instance, you have here β€œata3β€³ link, how does this links to any /dev/sd.. ?

      You need to go through /sys/class/ata_link. Search for sata_spd file. Use lsscsi command to map ids.

      cat /sys/devices/pci0000:00/0000:00:1f.2/ata3/link3/ata_link/link3/sata_spd
      

      Also

      dmesg | grep -i --color ahci 
      dmesg | grep -i  ahci | grep -i --color Gbps
      
  • Philippe Petrinko Sep 6, 2012 @ 8:53

    Thanks Vivek.

    By the way, on my Debian squeeze 6.0.5, /sys/class does not contain /ata_link but it contains:

    • scsi_device
    • scsi_disk
    • scsi_generic
    • scsi_host

    I tried to find clues, such as in /sys/class/scsi_device/2\:0\:0\:0/device/, but then I cannot make a link to ata3 or alikes. No sata_spd found yet.

    I have used lsscsi, either, and I have just watched your video and your lsscsi topic.

    I am still unable to link “ata3” to an exact drive, “dmesg|grep” commands didn’t tell much, but thanks to you, I learned some new stuff. :-))

    — Philippe

  • 🐧 nixCraft Sep 6, 2012 @ 11:31

    Philippe,

    Commands discussed here depends upon your bios, hd firmware, motherboard and kernel driver. You need libata driver loaded. Linux ship with various ata driver located in /lib/modules/$(uname -r)/kernel/drivers/ata. Linux will load the correct driver at boot time as per your hardware. The examples output is taken from kernel v3.2.0 running on Debian Linux 6.0.5. For testing purpose try loading backported kernel v3.2.0.

    HTH

    • Philippe Petrinko Sep 6, 2012 @ 13:28

      Thanks again.

      FYI, on my plain debian 6.0.5, Linux uses following modules tree:
      ata_generic => libata => scsi_mod
      So kernel v3.2.0 does not seem mandatory for libata
      Linux runs on a Thinkpad T400 laptop (exact model 64741AG).

      –P

  • george Sep 14, 2012 @ 10:10

    To measure the actual speed of an external USB disk:
    I use dd command from dev/null to a file on that USB disk, using block size parameter set to 1MB, and count set to 1000. This creates a 1 GB file, so averages disk speed, and eliminates buffering.
    The above is for write speed
    from a 1 GB file on the USB disk to /dev/null, you can test read speed

  • Dhaval Sep 14, 2012 @ 18:06

    Hi Guys,

    My SATA link shows 1.5 GB
    [ 1.204017] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
    However when I check the read write speed I get
    /dev/sda1:
    Timing cached reads: 412 MB in 2.01 seconds = 205.47 MB/sec
    Timing buffered disk reads: 166 MB in 3.03 seconds = 54.80 MB/sec

    And when I copy a file over a 1 Gbps network connection I get around 30 to 40 mbps. What could be the bottle neck as I believe the network file transfer speeds should be able to reach over 105-110 Mbps.

  • Alex Jan 26, 2014 @ 22:02

    The problem with relying on dmesg is that the message may have dissapeared on systems with a long uptime.

    This can be an alternative:
    $ smartctl -a /dev/sda|grep ^SATA
    SATA Version is: SATA 3.0, 6.0 Gb/s (current: 3.0 Gb/s)

    (on my SATA 1 disk, this line does not appear)

  • Shawn Hicks Jan 29, 2014 @ 4:08

    Your post (and some of the comments) inspired me to write this, it prints all ata_link speeds and devices:

    #!/bin/sh
    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
    
    • Ankur Mar 29, 2014 @ 12:25

      Thanks for this script. It clearly printed the hard drive name and speed.

  • Amal Jun 2, 2014 @ 4:18

    Instead of using
    smartctl -a
    you can use
    smartctl -i for a more compact output. :) For example:

    amal-desktop ~ # smartctl -i /dev/sda
    smartctl 6.2 2013-04-20 r3812 [x86_64-linux-3.11.0-12-generic] (local build)
    Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
    
    === START OF INFORMATION SECTION ===
    Model Family:     Hitachi Deskstar T7K250
    Device Model:     HDT722516DLA380
    Serial Number:    VDNE1BTCEB01HV
    LU WWN Device Id: 5 000cca 205e12f45
    Firmware Version: V43OA96A
    User Capacity:    164,696,555,520 bytes [164 GB]
    Sector Size:      512 bytes logical/physical
    Device is:        In smartctl database [for details use: -P show]
    ATA Version is:   ATA/ATAPI-7 T13/1532D revision 1
    Local Time is:    Mon Jun  2 09:46:49 2014 IST
    SMART support is: Available - device has SMART capability.
    SMART support is: Enabled
    ==========
    
  • Aman Sep 28, 2020 @ 2:13

    Hi. I want to remove my optical drive and replace it with a ssd.
    Here is output of above commands

    sudo hdparm -I /dev/sda | egrep “Model|speed|Transport”
    Model Number: TOSHIBA MQ01ABF050
    Transport: Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
    * Gen1 signaling speed (1.5Gb/s)
    * Gen2 signaling speed (3.0Gb/s)
    * Gen3 signaling speed (6.0Gb/s)
    * SMART Command Transport (SCT) feature set

    sudo smartctl -a /dev/sda | grep “^SATA”
    SATA Version is: SATA 3.0, 6.0 Gb/s (current: 6.0 Gb/s)

    does this mean i m goot with sata3???

    • 🐧 Vivek Gite Sep 28, 2020 @ 8:30

      yes, current: 6.0 Gb/s indicate that your hard drive named /dev/sda ( TOSHIBA MQ01ABF050 ) is running at sata3.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.