home   articles   archive   forum   masthead  
Published at 28.12.2001
Author: Sascha Kloss
Translator: Sascha Kloss
Languages: de
Printer printer-version
Support Us!
 

ATA, UDMA and hdparm

Have you bought a modern and fast IDE-based system and are wondering why Linux can't handle it? Speed up Linux by setting the correct parameters for the IDE-bus.

Speed vs. Compatibility

Please read the liability disclaimer!

Nearly all Linux distributions prefer compatibility and stability over speed. They want the installation to be as easy as possible and that's fine, but slowing down the PC to achive this? Users want stability, compatibility with their latest hardware and, of course, speed. Most users configure Linux so it must not boot Apache (WWW-Server) nor ProFTPD (FTP-Server) nor Squid (Proxy) because they don't need them. These services only increase the boot-up time and are not needed by the average user.
Althought fast hard disc drives are the main aspect in speed, an operating system being able to handle them is required. And, be honest, you thought Linux can handle your hardware.
Here's the system used in this tuning-process:

reference system

Mainboard: ABIT KT7-Raid (UDMA-66)
Southbridge: VIA vt82c686a
Northbridge: IBM DTLA-307030 (UDMA-100)
IDE-Cable: Standard ATA-100 cable (Length: 45cm!)


Please make sure your hardware is set up correctly. Otherwise, Linux will slow down in order to prevent errors. Windows can handle bad installations of hardware but a wrong installation in Linux results in many CRC-errors and perhaps lock-ups. So please verify your hardware setup according to the following:

Setting up your hardware

If your PC is home-built, be sure to correct even minor errors. Most high-end low-cost pc's are also full off small errors which block the use of UDMA in Linux. First, take a look at the IDE-connection cable and the HDD.
The IDE-cable should apply the specifications of the ATA-66 standard.;

Cable

Length: NOT exceeding a limit of 55 cm!
Wires: 80


And watch out, the cable must not be set up twisted!


The HDD should NOT be mounted near the power supply due to fan issues. The fan in the supply causes the HDD to misinterpret CRC-checksums and produces CRC-errors. Also, high-speed CD drives should not be near the HDD. See below for two examples:

Samples
setup causes interferences distance from the power supply


The left picture shows the umounted hdd outside the PC. If you run your PC with this setup you'll get many CRC-Errors because the cable is twisted.
The red area in the right image is to indicate the connector cable. As you can see, it's not twisted and is connected properly. Looking further, you'll also recognize the hdd is not near the power supply nor to the CD-drives. Running with this setup is recommended and would result in fast and functional CRC-checking.

How to configure Linux?

As always, a special program can help us do the job and this magic program is called hdparm.
This neat GNU program allows you to configure your ide-controller while the system is running!
The syntax is kind of strange, so here's a short table to show you what parameters you have to pass to the program:

Parameters
Param. sense example
-dx Turns DMA on(x=1) or off(x=0) hdparm -d1 /dev/hda

-cx Sets transmission mode for PCI-ID E-Cards
x=1=16Bit;
x=2=32Bit;
x=3=32Bit w/Sync
hdparm -c3 /dev/hda

-t Tests the performance of the hdd and controller hdparm -t /dev/hda

-Kx Saves the settings over a ide reset. So even there are errors these will be used --> data issues
x=1=save x=0=temporary
hdparm -K1 /dev/hda

-Xxx Force the drive and chipset to use the given speedrate. For instructions see the manual of hdparm (Command: man hdparm) hdparm -X34 /dev/hda

-i Displays the current setting in detail. hdparm -i /dev/hda

If you're looking for further information, type: man hdparm


These are the common parameters of hdparm. Let's go testing and configuring.

testing and configuring

As you'd guess, you should know what your hardware can handle. Please take a look at the user's manual of your hard disk drive and your mainboard/IDE-card.
If you collected all the required information, you can continue. First, we'll need to open two terminals (xterm) and log in as root on both (command: su). The first terminal is used to run commands and the 2nd is used to keep track of the syslogs.
Run this command on the second terminal to start tracking:

>> tail -f /var/log/messages


The other terminal is mainly intended to run hdparm with various parameters. To see how Linux behaves after the test, take a look at the second terminal. Please test with caution - don't push the frontier of your hardware limits! So let's start:
HDPARM's first issue prints the current settings:

>> hdparm -v -i /dev/hda

All we need to know is now on your screen; what parameters are currently in use and what your hdd is capable. A line similar to this one

DMA modes: mdma0 mdma1 mdma2 udma0 udma1 udma2 *udma3 udma4 udma5

is directly read from your hard disk. The asterisk marks the currently transfer mode. In this example it's UDMA3 (Ultra DMA mode 3 (ATA33)). Stay on the first terminal and try:

>> hdparm -d1 -Xzz -i -v -t /dev/hda

with zz replaced by appropiate parameters.
Please note to set the switch -d1 always because this switch enables DMA. The timing switch (-t) will measure your current speed after setting up the new configuration. The higher the zz variable the faster you system will be and the more error are to be expected. So keep tracking on the second terminal to prevent too many CRC errors.
If you notice errors like these slow down:

  hda: dma_intr: status=0x51 { DriveReady SeekComplete Error }
  hda: dma_intr: error=0x84 { DriveStatusError BadCRC }
  

reboot

If you ever reboot your PC (or switch it off) Linux must set the parameters again to reach proper speed. You must tell Linux which drive to tune (in the example it's /dev/hda) and pass the parameters. Copy the command line into the start-up file "/etc/rc.sysinit" and save it. Of course, you need root access to do this. On every reboot, Linux will tweak your hardware and you'll enjoy the speed benefit.

Misc stuff

After the installation of Mandrake Linux 8.1, the system ran in the mdma1-mode (MultiWord-DMA mode1) and a throughput of 10.76 MB/sec. After this tuning process, it runs stable and fast in the uDMA4-mode (Ultra-DMA mode4 (ATA66)) with a throughput of 51.20 MB/sec. The throughput was increased by a factor of almost 5!


The program "hdparm" may force your system to use higher values than avaible on your hardware. Therefor there's a risk in using this program. The use can cause data corruption and damage your hardware! So be sure to back up all your data and think twice before issuing any co mmand! Use extreme caution! WE TAKE NO RESPONSIBILITY FOR DAMAGED HARDWARE OR CORRUPTED DATA!




Talkback Area




Enter Own Comment