Speed up your IDE/ATA hard drive with hdparm

Jack Wallen
Oct 7, 2009
Updated • Nov 28, 2012
Linux
|
2

The Linux operating system has a really nice tool for testing and optimizing your hard drive. This tool is called hdparm and can work with both IDE and ATA drives. NOTE: hdparm does NOT work with SATA drives. The hdparm tool is a command line only tool, and even though it should be only used by those who know their systems well, it's not terribly difficult to use.

But why would you want to speed up your drive when modern drives are already fast enough? Some Linux installations default to slower defaults which, effectively, slow down your drives. Of course using such a tool must come with a warning. WARNING: Using hdparm incorrectly could cause corruption of data.

You do not have to worry about installing hdparm as it should already be installed by default. The basic usage of hdparm is:

hdparm [OPTIONS] [DEVICE]

Of course, by DEVICE, I mean in the Linux vernacular which will be something like /dev/hda.

To get the basic information about your drive you would issue the command:

hdparm /dev/HDA

Where HDA is the actual name of the hard drive you want to work with.

When I run the command:

sudo hdparm /dev/hda

I see the following:

jlwallen@jlwallen-laptop:~$ sudo hdparm /dev/hda
[sudo] password for jlwallen:
/dev/hda:

multcount     =  8
using_dma     =  0
IO_support    =  0 (default)
readonly      =  0 (off)
readahead     = 256 (on)
geometry      = 19457/255/63, sectors = 312581808, start = 0

What is really important in the above output is the IO_Support line. It is set to 0 which is 16-bit. Modern drives support IO mode 1 which is 32-bit mode. By changing this you can nearly double the throughput of your hard drive. But how exactly do you set this? Patience. Before we make this change we want to test the speeds of our drive. To run a standard test issue the command:

sudo hdparm -Tt /dev/HDA

Where SDA is the actual location of your drive. The results should look something like:

/dev/hda:
Timing cached reads:   868 MB in  2.00 seconds = 434 MB/sec
Timing buffered disk reads:  68 MB in  3.01 seconds =  22.52 MB/sec

As you can see the speeds are so-so at best, so let's kick them up a notch. To do the following:

Enable DMA

Change the IO mode from 16-bit to 32-bit.

Change the maximum number of disk sectors to transfer in a single request.

issue the command:

sudo hdparm -d1 -c1 -m16 /dev/hda

Now when I issue the command:

sudo hdparm /dev/hda

I see:

jlwallen@jlwallen-laptop:~$ sudo hdparm /dev/hda
[sudo] password for jlwallen:
/dev/hda:

multcount     =  16 (on)
using_dma     =  1 (on)
IO_support    =  1 (32-bit)
readonly      =  0 (off)
readahead     = 256 (on)
geometry      = 19457/255/63, sectors = 312581808, start = 0

When the drive speeds are tested now, they should nearly be doubled.

What about SATA?

Naturally there is a tool for the same tricks, but for SATA drives. The sdparm tool is similar in use to the hdparm tool. The sdparm tool, however, is a bit more complex and not nearly as necessary as most SATA drives will give you pretty swift throughput. If you want to use sdparm you will notice that it is not installed by default. You can install sdparm with the command:

sudo apt-get install sdparm

I will dive into sdparm at a later date.

Final thoughts

If you are dealing with older, slower ATA/IDE drives you will probably notice a significant improvement when you use hdparm to speed up your throughput. Give this a go, but I suggest testing it on a non-production machine first.


Advertisement

Previous Post: «
Next Post: «

Comments

  1. Mark Lord said on October 10, 2009 at 7:23 pm
    Reply

    hdparm *DOES* work with SATA drives.
    Rather well, actually.

    Some uses there are different than with IDE drives, but most of the functionality is common to all kinds.

    Please correct your very misleading article.

    -Mark

  2. Sheridan Hutchinson said on October 9, 2009 at 8:43 am
    Reply

    This article needs amending.

    If you have a distro like Ubunto that uses libata as its IDE driver, then configuration with hdparm is unnecessary.

    Also, the linux kernel’s SATA driver was built from the ground up to have performance options in hardware managed automatically, therefore you cannot use sdparm to tune for more performance!

    A really poor article.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.