Monday, January 30, 2006

Linux - Tune your IDE Hard Disk

hdparm is a tool for altering various parameters associated with IDE drives. This involves things like the block prefetch, the DMA/PIO modes, and a number of other things.

hdparm --help

shows a list of all available options. To get more information about your hard disk, run

hdparm -i /dev/hda

This will look like:

/dev/hda:

Model=ST94019A, FwRev=5.11, SerialNo=3KW5V2FK
Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
BuffType=unknown, BuffSize=2048kB, MaxMultSect=16, MultSect=16
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=78140160
IORDY=on/off, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio1 pio2 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5
AdvancedPM=yes: unknown setting WriteCache=enabled
Drive conforms to: ATA/ATAPI-6 T13 1410D revision 2:

* signifies the current active mode

To see how fast your hard disk currently is execute

hdparm -tT /dev/hda

Output:

/dev/hda:
Timing buffer-cache reads: 1496 MB in 2.00 seconds = 748.00 MB/sec
Timing buffered disk reads: 62 MB in 3.23 seconds = 19.20 MB/sec
[root@mybox jabber]#

Now you can run

hdparm -c1 -d1 -X 66 /dev/hda ---- (I choose 90, instead of 60)

to tune your hard disk. The X flag stands for the transfer mode (PIO: 8; DMA: 32; U-DMA: 64) + the number of the mode (2 for udma2: 64 + 2 = 66).

Now run

hdparm -tT /dev/hda

again, and if you're lucky, your hard disk should have become "faster".

Now My output is :

[root@mybox jabber]# hdparm -tT /dev/hda

/dev/hda:
Timing buffer-cache reads: 1516 MB in 2.00 seconds = 758.00 MB/sec
Timing buffered disk reads: 76 MB in 3.00 seconds = 25.33 MB/sec
[root@mybox jabber]#

You can see difference in performance now.


TO verify that DMA in enabled for your Harddisk :

[root@localhost ~]# hdparm -d /dev/hda

/dev/hda:
using_dma = 1 (on)


If DMA is not enabled, enable it by issuing the following command:
hdparm –d 1 /dev/hda

To verify 32 bit Transfers are enabled :
[root@localhost ~]# hdparm -c /dev/hda

/dev/hda:
IO_support = 0 (default 16-bit)

To Enable 32 bit Transfers :

[root@localhost ~]# hdparm -c 1 /dev/hda

/dev/hda:
setting 32-bit IO_support flag to 1
IO_support = 1 (32-bit)

Disk Read Test :

[root@localhost ~]# hdparm -T -t /dev/hda

/dev/hda:
Timing cached reads: 1816 MB in 2.00 seconds = 906.78 MB/sec
Timing buffered disk reads: 42 MB in 3.14 seconds = 13.38 MB/sec
[root@localhost ~]#


Note : 1 - To Enable , 0 - To Disable

No comments: