Valid HTML 4.0!

GNU/Linux

version CatalanaEn Catalŕ
Versión CastellanaEn Castellano
Sinner from the Prairy's Web Page

Home
What's in a name
Why Sinner from the Prairy
Sound from the Prairy
The Music in my Life
Videoconference
Let's get in touch!
Links and Search
New Sinner's WebPage with Google Search.
Steel Panthers
Battlefield Survival Guide (by Wild Bill Raider and Marc "Bayonet" Bellizzi)
Linux in action
e-mail
Do you want to tell me anything?
PGP Key
My public key.

Hard disk acceleration: hdparm

Warning! Hard disk acceleration can destroy your data!

No kidding here

Even though it works on most of the computers (for example, it works in my computer), in same cases, it is known that it has corrupted some data from a hard disk. So, before starting disk optimization, I recommend you to, first, verify that your Kernel supports the chipset on your computer; second, verify that your chipset is supported in the kernel (not as a module); third, backup your data; forth, use this acceleration under your responsability.

Hard Discs in Linux

First, it will ve good to know our hard disk specifications. Check that you have hdparm installed in your system (try running it as root, alone, with no parameters at all.) Just to have it all clear, let's start with Linux naming convention for hard disks.

On Linux, hard disks are not nammed "C:" ni "D:" ni .... On Linux, they are named hda, hdb, hdc... (this is for IDE hard disks; SCSI disks have different names). I only have used hdparm with IDE disks, so I cannot give advice on how to work with SCSI disks. To know the proper Linux name for a given hard disks, use this table:

ID Unit Linux Name
Master Unit, IDE Channel 0 hda
Slave Unit, IDE Channel 0 hdb
Master Unit, IDE Channel 1 hdc
Slave Unit, IDE Channel 2 hdd

Speed Tests

You can use the following commands in order to get knowledge from our hard disks and CD-ROM units. Use them as root . Replace the X by the letter that corresponds with your unit, as shown in the previous table.

[root@sal10000 root]#hdparm /dev/hdX
[root@sal10000 root]#hdaprm -i /dev/hdX

The first command will inform you of the status (active or non-active) of hdparm's each and every option. Whenever you get a zero, the option is not active. Whenever you get an one, the option is active. With the first command, in my computer, I get the following:

[root@sal10000 root]#

/dev/hda:
multcount = 32 (on)
I/O support = 3 (32-bit w/sync)
unmaskirq = 0 (off)
using_dma = 1 (on)
keepsettings = 0 (off)
nowerr = 0 (off)
readonly = 0 (off)
readahead = 8 (on)
geometry = 1046/255/63, sectors = 16809660, start = 0

The second command tells you the specifications of your hard disk drive. It will show you the kind of LBA type supported by your drive, the "Cylinders/Heads/Sectors", "PIO Modes", "DMA Modes"... available for your disk. This way, you can know what performance level can be achieved by your drive. With the second command, in my computer, I get the following:

[root@sal10000 root]# hdparm -i /dev/hda

/dev/hda:

Model=ST38641A, FwRev=3.15, SerialNo=GR576255
Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
BuffType=unknown, BuffSize=128kB, MaxMultSect=32, MultSect=32
CurCHS=16676/16/63, CurSects=16809408, LBA=yes, LBAsects=16809660
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

To discover your drive's transference speed, close all aplications, servers... that you might have active on your system (even the graphical mode; exit your window environment, go to a virtual console with Ctrl+Alt+F1, login as root and issue the command telinit 3). Then, issue the command (as root and changing X by the letter that applies to your drive, as explained before with the Linux name table). Do it at least 5 times. Discard the higheest and lowest results, and your speed will be the average of the other values.

hdparm -t /dev/hdX

(Top)

Parameters

There's a whole bunch of adjustable parameters. To know about all of them, issue the command hdparm -? . The values that affect the most your drive's speed are:

  • -c3
    Sets the 32-bit input/output, with synchronization
  • -c1
    Sets the 32-bit input/output, a little faster, but also a little less reliable.
  • -d1
    Sets DMA mode, and automaticaly selects the optimum speed.
  • -p3
    Sets PIO3 mode. You can change the '3' for the desired PIO mode supported by your drive.
  • -a
    Sets "Read Ahead" mode. This means that the system will read from the drive more than just what we asked for, anticipating our (or our system's) probable next request.

Small guide to testing:

  1. First, identify your drive speed (hdparm -t /dev/hda).
  2. Then, check what options are active (hdparm /dev/hda).
  3. Then, change just one option (hdparm -c3 /dev/hda for example)
  4. Check again (and several times) the drive's speed to know how this change affected your system. (hdparm -t /dev/hda).

Maybe you will discover that your drive is already optimized (as happens with some of the most modern and "user friendly" Linux distributions) and you do not need to modify anything.

(Top)

Save the Configuration

If you decide to use, let's say, -c1 -d1 /dev/hda and you want to avoid typing this each and every time that you boot up your computer, you will need to insert the command in some boot script. In my Linux, it is: /etc/rc.d/rc.local (it is distribution-dependent. Check your documentation). So, edit that file (as root) and add a line in the end that says hdparm -c1 -d1 /dev/hda.

(Top)




Bravenet.com