PDA

View Full Version : Tweaking your HDD in Linux



JohnD
29-06-2002, 08:39 PM
Hard disk performance of RedHat Linux out of the box is not that great! Follow these steps carefully to improve the situation. Be very sure that you realize that a wrong move can corrupt the data on your drive in a flick of the eyelid!!

1.Back up your data - check that it is a good backup
2.Check that you have a 80 wire IDE cable connected to your drive - you will not get peak performance from the old 40 wire cable (performance is limited due to electrical interference).
3.Study up on the Linux utility called hdparm - read the manual and any web references to make sure you know what you are doing. Two web references I have used are:

linux.oreillynet.com/pub/a/linux/2000/06/29/hdparm.html
dunedin.lug.net.nz/docs/ldp/LDP/LG/issue79/punk.html

4.Check your drive parameters using hdparm -i /dev/hda (replacing hda with your drive if necessary). The results for my drive are as below. Setting parameters to those not supported by your drive will no doubt cause problems!!

/dev/hda:

Model=ST310212A, FwRev=3.02, SerialNo=7EG1TRSC
Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
BuffType=unknown, BuffSize=512kB, MaxMultSect=32, MultSect=off
CurCHS=16383/16/63, CurSects=-66060037, LBA=yes, LBAsects=20005650
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 udma0 udma1 udma2 udma3 *udma4

5.Check your base settings using hdparm /dev/hda. Mine came out as below:

/dev/hda:
multcount = 0 (off)
I/O support = 0 (default 16-bit)
unmaskirq = 0 (off)
using_dma = 0 (off)
keepsettings = 0 (off)
nowerr = 0 (off)
readonly = 0 (off)
readahead = 8 (on)
geometry = 1245/255/63, sectors = 20005650, start = 0

6.Check your base performance using hdparm -tT /dev/hda. Mine came out as below:

/dev/hda:
Timing buffer-cache reads: 128 MB in 0.93 seconds =137.63 MB/sec
Timing buffered disk reads: 64 MB in 38.07 seconds = 1.68 MB/sec

7.Next I set the multcount (multiple sector count) to 32 (got from the data in section 4 above) and set the operating mode to 32 bits. Use the command hdparm -c 1 -m 32 /dev/hda. The result of this was:

dev/hda:
Timing buffer-cache reads: 128 MB in 0.92 seconds =139.13 MB/sec
Timing buffered disk reads: 64 MB in 26.74 seconds = 2.39 MB/sec

8.Finally I set DMA on with hdparm -d 1 /dev/hda. The result of this was:
/dev/hda:
Timing buffer-cache reads: 128 MB in 0.96 seconds =133.33 MB/sec
Timing buffered disk reads: 64 MB in 2.85 seconds = 22.46 MB/sec

Settings for all the changes result in:
dev/hda:
multcount = 32 (on)
I/O support = 1 (32-bit)
unmaskirq = 0 (off)
using_dma = 1 (on)
keepsettings = 0 (off)
nowerr = 0 (off)
readonly = 0 (off)
readahead = 8 (on)
geometry = 1245/255/63, sectors = 20005650, start = 0

This was as far as I was game to go on my home machine with all my data and setup on! I have had success on another PC by turning the unmask irq on. I have tried setting the hard disk for particular DMA modes but got no improvement over just turning DMA on. I have also tried other settings (forgotten what) on another PC that resulted in a trashed file system and a complete reinstall - so BE CAREFUL.

So in summary the throughput went from 1.68MB/s to 22.46MB/s - a improvement of about 13.4 times! Unfortunately this does not translate into the same improvement in the real world. My system took 47 seconds to load OpenOffice 1.0 before the changes and 18 seconds after - an improvement of 2.6 (well worth it).

bmason
30-06-2002, 12:29 AM
On mandrake (and probably redhat etc) you can edit /etc/sysconfig/harddisks and it will set the options at boot.

JohnD
30-06-2002, 11:25 PM
You are right - I tried this but the trouble is that it applies the changes to all IDE and SCSI disks. Linux treats a parallel Zip as a SCSI disk and it did not like 32 bit file access at all. If this is not a problem, then editing /etc/syscon/harddisks is fine.

If you use my method you can still make the changes at boot by adding the your final hdparm parameters to the end of oyur /etc/rc.d/rc.local file.

bmason
01-07-2002, 01:36 AM
I just checked in /etc/rc.d/rc.sysinit and you can do individual drives by making a copy of /etc/sysconfig/harddisks and naming it harddiskhda, harddiskhdb etc.

JohnD
01-07-2002, 08:24 PM
Didn't know that one - thanks.

JohnD
01-07-2002, 08:25 PM
Didn't know that one - thanks.

JohnD
02-07-2002, 09:42 PM
I recently had to do a reinstall of RH 7.0 on my daughter's P100. What I cannot understand is that the default transfer rate on my Duron 850 with a 10G drive was 1.68Mbytes/sec and I had to tweak it to get 22Mbytes/sec while the old dunger with a 1.7G drive had a default transfer speed of about 24Mbytes/sec???

Any ideas why?

bmason
02-07-2002, 11:25 PM
DMA and other optimisations are turned on by default on some chipsets (eg 440BX), my guess is it would be one of them.

Although 24MB/s is quite high, my 8gb drive only gets 13.39MB/s.

You can see the current mode when you run "hdparm -I /dev/hda", it puts a * to the left of the current mode, eg

R/W multiple sector transfer: Max = 16 Current = 16
DMA: sdma0 sdma1 sdma2 *mdma0 mdma1 mdma2 udma0 udma1 *udma2 (?)
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=120ns IORDY flow control=120ns

ctonks
18-07-2002, 04:33 PM
Nice tips.
you have to be very careful though - you can quite easily destroy a disk this way.

thanks to Multicount and UDMA though my seagate baracuda runs at its optimal level of 40MB/Sec under linux :-)

still performance has nothing on a decent SCSI drive which doesnt use system resources.