[ Prev ][ Table of Contents ][ Front Page ][ Talkback ][ FAQ ][ Next ]

"Linux Gazette...making Linux just a little more fun!"

Improving Hard Disk Performance with hdparam

By Piter Punk
Translated from the Portuguese by William N. Zanatta

Nowadays the IDE devices already have a high transfer rate (by UltraDMA technology), but there are still other ways to improve your hard-disks performance and we'll show how to do it with the hdparm utility.

1. Introduction

hdparm is an utility which provides us a powerful tunning control over HDs (HD PARaMeters) and this is what we'll be discussing in this document. Sometimes your HD is set not to use its maximum power as it could and that's why you may get anoyed with its performance. With hdparm we can magically change this to reach its maximum performance using all of its features.

2. Looking the hard disk

The first thing to do, is to gather all information about your hard drive and the current settings. These information will be used as a base for us while configuring the hard disks. Be extremely careful in all the steps you take because any misconfiguration may damage your disk partially (data) or entirely (hardware).

By now, lets assume /dev/hda as our disk. Take the command:

      darkstar:~$ hdparm -i /dev/hda

You should get some info like:


    Model=QUANTUM FIREBALLlct20 20, FwRev=APL.0900, SerialNo=552114732078
    Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs } 
    RawCHS=16383/16/63, TrkSize=32256, SectSize=21298, ECCbytes=4 
    BuffType=DualPortCache, BuffSize=418kB, MaxMultSect=8, MultSect=off
    CurCHS=16383/16/63, CurSects=-66060037, LBA=yes, LBAsects=39876480
    IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120} 
    PIO modes: pio0 pio1 pio2 pio3 pio4 
    DMA modes: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5 
    Drive Supports : ATA/ATAPI-5 T13 1321D revision 1 : ATA-1 ATA-2 ATA-3
    ATA-4 ATA-5

But, you may ask yourself "What the hell is this?". Heah, don't be afraid this information will make you happy soon. Here we have many important and useful information...let's look at some:

Another command issued to get other information is:

      darkstar:~$ hdparm /dev/hda

This one brings:

     multcount = 0 (on) 
     I/O support = 0 (16-bit) 
     unmaskirq = 0 (off) 
     using_dma = 0 (off) 
     keepsettings = 0 (off) 
     nowerr = 0 (off) 
     readonly = 0 (off) 
     readahead = 8 (on) 
     geometry = 2482/255/63, sectors = 39876480, start = 0

In a brief description...

If you didn't understand some of these don't get bored, you are not a dumb, and we will discuss them as you read this document. Some of these parameters are related to your hard drive hardware physically and not logically, soh you cannot change them unless you change the hardware (and if you do it, you will probably cry for damaging your hard disk and destroy all your data, =] ).

3. Device setup

And now...the show! We are going to setup our HD. REMEMBER: Mistakes during the setup process may damage your hard disk and all of its data. The information provided by 'hdparm -i ' now, is your driver. Follow them and you must not get any problems.

3.1. I/O Support

Well, unless you have a (E)ISA IDE interface card, the rest (PCI/VLB), all support 32bits mode. If your box is newer than a 486, probably you have a PCI IDE controller. If it's not, check for it...

The mode '3' only is needed for some chipsets. People often use mode '1' for best performance. We didn't find any info about mode '2' (supposed to be 16-bit sychronized).

3.2. MultSect or Multcount

This one is simple. Check your HD's MaxMultSect info for what you can do. We set our MultSect to 8 since our HD supports that, so...

	# hdparm -m 8 /dev/hda

Remember to change /dev/hda to YOUR device and '8' to the MaxMultSect supported by your hard disk as provided by 'hdparm -i '.

3.3 Activating DMA

The most simple of all. Simply type:

	# hdparm -d 1 

to set your DMA mode to ON. Your card must supportd the DMA mode.

3.4 PIO and DMA modes

You can set both of these using the same flag '-X'. This one, if not used with EXTREME care may eject your hard drive (BELIEVE IT!) and make it the first HD to arrive the Moon by itself. Set just the modes supported by your hard disk.

Hmm, it works like this...for normal DMA modes (multiword DMA or mdma), use -X32 + (DMA identifier number). For mdma2 it would be:

	# hdparm -X34 /dev/hda  // 32 + 2 (from mdma2)

For the PIO and UltraDMA modes the process is almost the same. The difference is that the base number for the PIO modes is 8 and for the UltraDMA modes it is 64. The hard disk used while writing this document supports ATA100, so it was put in udma5 mode using:

	# hdparm -X69 /dev/hda

Keep in mind that the highest DMA modes are available just for some chipsets.

The ATA66 and ATA100 modes requires a 80-way IDE cable. Think that put you disk in ATA100 without these cables will not work.

3.5 Readahead

The option readahead IS NOT the same as multcount. The multcount refers to the possibility of the hardware to read more than one sector at a time while the readahead option is the number of sectors ahead your computer should read. The readahead feature is great when reading big-size files but it brings down the performance for short-size files. A good idea is to leave the value of readahead the same as the multcount so it will not be needed to make more than an access per time to read more sectors ahead.

If you are going to access big files you can set the readahead to a greater value. The default value is 8 sectors/read access (something like 4kb).

Now the syntax:

	# hdparm -a N /dev/hda 

N is the number of sectors for readahead.

4. Final comments

There are many other features you can set using hdparm. Most of them are covered in the hdparm manpage. These ones we covered are just the most common.

The configuration will be reset when you reboot your machine (the keep settings will not work as it covers just soft reboots). Put the commands in your rc.local (maybe, for large configuration, it would be a good idead to have a rc.hdparm or something like this).

Any doubts on this documents can be sent to:

Problems with this translation can be sent to

Copyright © 2002, Piter Punk.
Copying license
Published in Issue 79 of Linux Gazette, June 2002

[ Prev ][ Table of Contents ][ Front Page ][ Talkback ][ FAQ ][ Next ]