Apr 032013
 

Sata

SATA is the most common bus interface on desktops and on many servers, so it’s important that you know some basic concepts about it, from the always informative Wikipedia:

Serial ATA (SATA) is a computer bus interface that connects host bus adapters to mass storage devices such as hard disk drives and optical drives. Serial ATA replaces the older AT Attachment standard (ATA; later referred to as Parallel ATA or PATA), offering several advantages over the older interface: reduced cable size and cost (seven conductors instead of 40), native hot swapping, faster data transfer through higher signalling rates, and more efficient transfer through an (optional) I/O queuing protocol.

Revisions
Revision 1.0a was released on January 7, 2003. First-generation SATA interfaces, now known as SATA 1.5 Gbit/s, communicate at a rate of 1.5 Gbit/s, and do not support Native Command Queuing (NCQ).

Second generation SATA interfaces run with a native transfer rate of 3.0 Gbit/s, and taking 8b/10b encoding into account, the maximum uncoded transfer rate is 2.4 Gbit/s (300 MB/s). The theoretical burst throughput of SATA 3.0 Gbit/s is double that of SATA revision 1.0.

Serial ATA International Organization presented the draft specification of SATA 6 Gbit/s physical layer in July 2008 and ratified its physical layer specification on August 18, 2008. The full 3.0 standard was released on May 27, 2009. It runs with a native transfer rate of 6.0 Gbit/s, and taking 8b/10b encoding into account, the maximum uncoded transfer rate is 4.8 Gbit/s (600 MB/s).

In short they are usually referred as:

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

So which revision are you using on your computer ?



It’s really easy with Linux terminal to find the speed that you are really using on your devices, you just need to issue the command:

dmesg |grep -i sata
[    0.718552] ata1: SATA max UDMA/133 cmd 0xf0d0 ctl 0xf0c0 bmdma 0xf090 irq 19
[    0.718557] ata2: SATA max UDMA/133 cmd 0xf0b0 ctl 0xf0a0 bmdma 0xf098 irq 19
[    0.718864] ata3: SATA max UDMA/133 cmd 0xf070 ctl 0xf060 bmdma 0xf030 irq 19
[    0.718868] ata4: SATA max UDMA/133 cmd 0xf050 ctl 0xf040 bmdma 0xf038 irq 19
[    1.193335] ata4: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[    1.193448] ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[    2.219408] ata1.00: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[    2.219422] ata1.01: SATA link down (SStatus 0 SControl 0)
[    2.219552] ata2.00: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[    2.219568] ata2.01: SATA link down (SStatus 0 SControl 0)

Or if you want to see just the connected devices

dmesg |grep -i sata |grep up
[    1.193335] ata4: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[    1.193448] ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[    2.219408] ata1.00: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[    2.219552] ata2.00: SATA link up 1.5 Gbps (SStatus 113 SControl 300)

So from my output I can see that I’ve 4 SATA devices connected and ready (link up), 3 of these devices have a speed of 3.0 Gbps and 1 of them has a speed of 1.5 Gbps.
Now, I know my hardware and I think that the 3 devices at 3.0 Gbps are my 3 hard disks and the latter is my CD/DVD writer, but how can I verify this ?

Stackexchange has a nice and quick solution:

The /dev/sdY devices are created in the same order as the ataX identifiers are enumerated in the kern.log while ignoring non-disk devices (ATAPI) and not-connected links.

Thus, the following command displays the mapping:

grep 'Apr  3' /var/log/kern.log  |    grep 'ata[0-9]\+.[0-9][0-9]: ATA-' |    sed 's/^.*\] ata//' |    sort -n | sed 's/:.*//' |    awk ' { a="ata" $1; printf("%10s is /dev/sd%c\n", a, 96+NR); }'

The output for me is:

ata1.00 is /dev/sda
ata3.00 is /dev/sdb
ata4.00 is /dev/sdc

I am using /var/log/kern.log and not /var/log/kern.log.0 because on my desktop the boot messages are not already rotated.
I grep for Apr 3 because this was the last boot time and I want to ignore previous messages, if you use this script just change the date to the one of your last boot.

So this confirm my idea, the 3 devices at 3.0 Gbps are my 3 hard-disks.
But now I’ve one more question, is this the max speed of my hard disk or it’s the motherboard that is limiting them ?


To verify this I’ll use another great command hdparm.
hdparm provides a command line interface to various kernel interfaces supported by the Linux SATA/PATA/SAS “libata” subsystem and the older IDE driver subsystem.
To get the information that we are searching you can simply use the flag -I but this gives really a lot of information so I suggest to use the following command to get just the information about the speed:

mint-desktop #sudo hdparm -I /dev/sda |grep -E "Model|speed" 
	Model Number:       ST500DM002-1BD142                       
	   *	Gen1 signaling speed (1.5Gb/s)
	   *	Gen2 signaling speed (3.0Gb/s)
	   *	Gen3 signaling speed (6.0Gb/s)

Interesting my first disk can use the SATA Revision 3, so my MotherBoard is limiting this Harddisk.

mint-desktop #sudo hdparm -I /dev/sdb |grep -E "Model|speed"
	Model Number:       Hitachi HUA721050KLA330                 
	   *	Gen1 signaling speed (1.5Gb/s)
	   *	Gen2 signaling speed (3.0Gb/s)
 
mint-desktop #sudo hdparm -I /dev/sdc |grep -E "Model|speed"
	Model Number:       Hitachi HUA721050KLA330                 
	   *	Gen1 signaling speed (1.5Gb/s)
	   *	Gen2 signaling speed (3.0Gb/s)

The second and third hard disk are older (I use them in Raid 10) so I’m not surprised that they only support Sata Revision 2, and anyway with this MB it’s not so important.

So as you have seen in this article on the GNU/Linux terminal you can quickly discover what’s the speed of your devices, map the ATA devices to your SD hard disks and verify the real speed of the hard disks.

Popular Posts:

Flattr this!

  5 Responses to “How to measure the speed of SATA devices from the command line on Linux”

  1. You didn’t actually measure anything… Only checked interface speed.

  2. cat /sys/class/ata_link/link?/sata_spd

    Ufficio complicazioni affari semplici .
    https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-ata

  3. Haj is right, use dd to measure the speed. I think it is the -T flag, but can’t recall from here without consulting man dd or Google.
    It will give the buffered and unbuffered speed, based on an actual measurement, not just the theoretical maximum of the spec.

    • Or use hdparm -tT /dev/sdX

      hdparm -tT /dev/sda
      
      /dev/sda:
       Timing cached reads:   10074 MB in  2.00 seconds = 5039.77 MB/sec
       Timing buffered disk reads: 416 MB in  3.01 seconds = 138.32 MB/sec
      

Leave a Reply to linuxari Cancel reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

*