Section 8.5. My Hard Drive Is Too Slow

8.5. My Hard Drive Is Too Slow

The defaults associated with the latest Linux distributions do not take full advantage of the latest improvements in IDE/ATA (Integrated Drive Electronics/Advanced Technology Attachment) hard drives. For example, Linux is normally set to communicate with IDE/ATA hard drives in 16-bit mode. While this may seem irrational in current 32- and 64-bit environments, it helps Linux retain its reputation for extending the life of older hardware. If you don't have an older hard drive, you can modify the Linux defaults to take full advantage of its data-transfer capabilities.

Before running any of the commands in this annoyance, I strongly suggest that you back up the data on your hard drive. The commands described in this annoyance may stress your hard drive beyond its capabilities. For best results during the backup, set your computer to single-user mode (init 1), which reduces the load from most services and network connections.

In this annoyance, we focus on the hdparm command, based on a Freshmeat project of the same name ( If you can't find this command, install an hdparm package native to your distribution; it's available for at least Red Hat/Fedora, SUSE, and Debian.

For SCSI hard drives, there is no command to adjust hard drive parameters the way hdparm does for IDE hard drives. But given the way SCSI hard drives communicate with controllers, it is less important for these drives.

8.5.1. Hard Drive Defaults

Before adjusting any device, you should establish a baseline by figuring out the default settings and checking its performance. To that end, the following command tests the speed at which Linux can read data from your hard drive, directly (-t) and through a buffer (-T):

 # hdparm -Tt /dev/hda /dev/hda: Timing buffer-cache reads:   384 MB in  2.01 seconds = 191.04 MB/sec Timing buffered disk reads:   66 MB in  3.06 seconds =  21.57 MB/sec 

You may want to run this command more than once, to make sure that you have consistent baseline readings. I find small variations, under 20 percent, to be fairly common.

Next, find the baseline settings for communication between Linux and your hard drive:

 # hdparm /dev/hda /dev/hda:  multicount   = 16 (on)  IO_support   = 0 (default 16-bit)  unmaskirq    = 0 (off)  using_dma    = 1 (on)  keepsettings = 0 (off)  readonly     = 0 (off)  readahead    = 8 (on)  geometry     = 1940/240/63, sectors = 29336832, start = 0 

Make a record of your hdparm parameters. If after making changes, you encounter problems, you can then return to your original parameters. Here is a description of the parameters:


Every time a process or program looks for data, it sends an I/O interrupt request. The multicount option is associated with IDE Block Mode, where several disk sectors are transferred per interrupt. Modern Linux distributions are generally set to a multicount of 16 or higher. While your system may be able to handle higher multicount settings, do so at your own risk. Failures can corrupt your filesystem and cause the loss of all data on that hard drive. Some Western Digital hard drives can only handle smaller multicount values (4 or 8), due to small (32KB) buffers. This parameter can be controlled by the hdparm -m command.


This option determines how data is transferred between the PCI bus and the hard drive interface card. There are three possible values: 0 disables 32-bit transfers; 1 enables 32-bit data transfers; and 3 supports 32-bit synchronous data transfers. (There is no value 2.) An IO_support of 3 is supported by most hard drives. This parameter can be controlled by the hdparm -c command.


If enabled, this allows other interrupts while data is read from a hard drive. This parameter can be controlled by the hdparm -u command.


Modern hard drives almost always use a Direct Memory Access (DMA) channel to bypass the CPU. The ability to perform DMA is often detected and set on the latest versions of SUSE, Red Hat/Fedora, and Debian. However, this is not supported by all hard drives. This parameter can be controlled by the hdparm -d command.


Activate only if you want to retain drive settings after soft resets associated with errors. I don't recommend that you use this option except possibly when you're trying to diagnose a hard drive hardware problem. Otherwise, you could lose data.


Set for a read-only drive, such as a CD/DVD drive. This parameter can be controlled by the hdparm -r command.


The number of sectors that are read when Linux accesses a hard drive. Most Linux distributions generally set a readahead of 8 sectors. This parameter can be controlled by the hdparm -a command.


Documents what Linux sees about your hard drive. It should match your hard drive documentation, as well as what you see in your BIOS menu. If it does not match, do not use the hdparm command to alter any geometry settings, because it would cause Linux to misinterpret the drive and its use could cause you to lose all of the data on that drive.

There are a substantial number of additional hdparm options, listed on the associated manpage.

8.5.2. Adjusting Hard Drive Parameters

With the right hdparm command, you may be able to increase the effective speed of your hard drive. Given the number of settings, some trial and error is required. In other words, test the throughput of each change with the hdparm -Tt command.

I'll now detail some of the more common changes that you can make to IDE/ATA hard drive parameters. See the associated manpage for details.

Sometimes, hdparm will tell you if your hardware or distribution can't handle a setting associated with faster data transfer. For example, when I try to configure a multicount of 32 on three of my systems, I get the following result:

 # hdparm -m32 /dev/hda /dev/hda:  setting multicount to 32  HDIO_SET_MULTICOUNT: Invalid argument  multicount   = 16 (on) 

No problem, time to try something else. When I try to configure 32-bit I/O support on my computers, I see the following:

 # hdparm -c3 /dev/hda /dev/hda:  setting 32-bit IO_support flag to 3  IO_support   = 3 (32-bit w/sync) 

Now that you've changed the setting, it's time to test the result. Run the hdparm -Tt command again. It's OK to run this command more than once, to see if the change is significant. If so, make a note of the change. You'll want to make sure Linux implements this change the next time you boot that computer.

You can set up commands such as hdparm -c3 in the appropriate configuration file, which varies by distribution: Debian uses /etc/hdparm.conf; SUSE uses settings in /etc/sysconfig/ide based on variables in /etc/init.d/boot.idedma; Red Hat Enterprise Linux uses /etc/sysconfig/harddisks. Starting with Fedora Core 5, Red Hat has deprecated the use of such configuration files; these settings can be added to /etc/rc.local.

Linux Annoyances for Geeks
Linux Annoyances for Geeks: Getting the Most Flexible System in the World Just the Way You Want It
ISBN: 0596008015
EAN: 2147483647
Year: 2004
Pages: 144
Authors: Michael Jang

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: