Open Source

Speed up your hard drive with hdparm

This tip tells you how to use the hdparm tool to customize your IDE hard drive device for better performance.

This tip is from TechRepublic's free Linux NetNote newsletter. Sign up instantly to begin receiving the Linux NetNote in your inbox.

These days, most hard drives are of the ATA100 or ATA133 specification. The theoretical transfer rate of an ATA100 drive is 100 MBps; an ATA133 drive's theoretical transfer rate is 133 MBps. Of course, these are theoretical rates.

Many Linux systems use conservative defaults that could be slowing down your system. At the very least, these defaults could be preventing your system from reaching the maximum speeds that your hardware allows.

Like most parts of a Linux system, how Linux interacts with your IDE hard drives is configurable. You can accomplish this using the hdparm tool, which allows you to customize many aspects of any given IDE hard drive device.

Of course, using hdparm requires caution because your drive could end up corrupting data or failing if you configure it incorrectly.

To get the information of your device, execute the following:

hdparm /dev/hda

To get more extended information, use the following:

hdparm -i /dev/hda

Replace /dev/hda with the IDE device name of the drive you wish to report on. (hda is the first drive on the first IDE bus.)

Look for the multcount, IO_support, and using_dma fields. These fields help you determine if your drive is using its full capabilities.

Let's assume that the device in question is an ATA100 or ATA133 drive using an 80-wire cable. To determine the speed of the drive, execute the following:

# hdparm -Tt /dev/hda

 Timing buffer-cache reads:  968 MB in  2.00 seconds = 484.00 MB/sec
 Timing buffered disk reads:  88 MB in  3.05 seconds = 28.85 MB/sec

The results show that the drive is operating at a fairly decent speed. If your drive is an ATA100 or ATA133 drive and you're getting speeds of 1 to 2 MBps, then your drive isn't using DMA mode, which you can tell from the hdparm information noted above. You can also tell this by looking for the using_dma keyword. (It should have a value of 1 for on.)

To tweak the speed, execute the following:

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

This turns on DMA mode, specifies the maximum number of disk sectors to transfer in a single request (older drives should use -m8), and enables 32-bit transfers to the ATA controller. Using hdparm /dev/hda should reveal (among other things) the following lines:

 multcount    = 16 (on)
 IO_support   =  1 (32-bit)
 using_dma    =  1 (on)

Some new drives don't enable these settings on their own, so you'll need to use hdparm to achieve the maximum speed your drive will permit.

About Vincent Danen

Vincent Danen works on the Red Hat Security Response Team and lives in Canada. He has been writing about and developing on Linux for over 10 years and is a veteran Mac user.

Editor's Picks

Free Newsletters, In your Inbox