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.
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:
/dev/hda: 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 AdvancedPM=no 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:
/dev/hda: 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, =] ).
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 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).
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...
Remember to change /dev/hda to YOUR device and '8' to the MaxMultSect
supported by your hard disk as provided by 'hdparm -i The most simple of all. Simply type:
to set your DMA mode to ON. Your card must supportd the DMA mode.
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:
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:
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.
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:
N is the number of sectors for readahead.
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: piterpk@terra.com.br.
Problems with this translation can be sent to wzanatta@uol.com.br.
3.1. I/O Support
3.2. MultSect or Multcount
# hdparm -m 8 /dev/hda
3.3 Activating DMA
# hdparm -d 1
3.4 PIO and DMA modes
# hdparm -X34 /dev/hda // 32 + 2 (from mdma2)
# hdparm -X69 /dev/hda
3.5 Readahead
# hdparm -a N /dev/hda
4. Final comments
Copyright © 2002, Piter Punk.
Copying license http://www.linuxgazette.com/copying.html
Published in Issue 79 of Linux Gazette, June 2002