Hdparm, using

From DSL Wiki


Hdparm is a tool which is used to maximize the performance of your hard drive. After using hdparm, most hard drives show a 2x increase in throughput, or in some cases a 6-10x increase.

Your Linux system comes with its hard drives reconfigured in the most basic possible setup. The hard drive configuration your system is installed with will work from the slowest 386, so if you have a newer hard drive, none of its new features are used.

Before you start tweaking with your disks, be warned that data corruption can occur if you push them too far, so be warned and if you have sensitive data make a backup.

If you are using current hardware (current meaning within the last 4 years), then there shouldn't be too large a risk, but if you have a quite old drive then be cautious when trying new settings.


hdparm -Tt /dev/hda

at the console. If you are optimizing /dev/hdb or another drive, use the corresponding command. This command will show your drive's current speed. If you then type:

hdparm /dev/hda

you will see what settings Linux is using for your hard disks. A typical output would be:

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 = 1870/255/63, sectors = 30043440, start = 0

The settings are nice and safe, but not necessarily optimal. Here's an explanation of some of the various options you can change for your drive:

multicount: This is the multiple sector count, which controls how many sectors are retrieved from the disk in a single I/O interrupt. All most all modern hard drives support this. This setting, when optimized, can increase hard drive throughput anywhere from 5% to 50%.

I/O support: This is the setting that will make a significant change to your system. Nearly all modern chipsets support 32-bit mode, and changing I/O support to this will almost certainly produce a twofold increase in speed.

using_dma: DMA can be tricky to use on older hardware. If you can get your hard drive to use DMA, then do it. But systems can hang if the hard drive doesn't support this setting.

Now we know what the main options do, shut down X and go into the console as root to ensure minimal chances of data loss. Here is a generally safe command you can use on your hard drive:

hdparm -m16 -c3 /dev/hda

When you check the hard drive throughput, it should practically have doubled.

There are some more dangerous options you can add:

hdparm -m16 -c3 -d1 -u1 -X34 /dev/hda

You can also try using the -X69 option.

With some of the riskier options, you should notice a large increase in your hard drive performance. Now edit your startup scripts so that hdparm runs at boot, because the settings have to be changed every time your system starts up - you can add your command to the end of /etc/init.d/knoppix-autoconfig. You can also set the -k1 option to keep your settings if you're satisfied that they are perfectly safe.

Small tweaks

noatime - Whenever a file is accessed in Linux, the current time and date are recorded. This is not usually needed, and you can gain a small amount of speed (which won't show up using hdparm -Tt) by disabling this option. This is done by editing your /etc/fstab file, and where on your hard drive line it says defaults, change it to defaults,noatime.

Original posting at FeatherLinux forums by Rob - http://featherlinux.berlios.de/phpBB2/viewtopic.php?t=436