Optimizing Hard Disk Settings


The hard disk is one of the key elements in the modern PC. Because most of your PC's data must travel to and from it, speeding up your hard disk means that your entire PC will be faster.

SUSE Linux provides a powerful command-line tool that you can use to control every aspect of your hard disk: hdparm. This is a power-user's tool. Not only must you switch to root to use it, but you also must be careful not to mistype the commands. All changes are made instantly, so if you make a mistake, your system may crash, or at least suffer from serious problems. There's even the risk of data loss, although this is minimized by making sure that you have no other programs running at the same time you run hdparm.

The good news is that changes made via hdparm will last for only the current session, so there's no risk of permanent damage (any changes that are beneficial can be made permanent later).

In the context of optimization, hdparm lets you both benchmark the disk, as well as change various technical settings, such as the DMA access mode. These adjustments can bring speed boosts.

Note 

The changes described here are designed to work with IDE hard disks only. This is the standard type of hard disk used in the majority of desktop PCs. If your computer is one of the small minority that uses SCSI hard disks, you should skip this section, because it does not apply to SCSI.

Benchmarking Your Hard Disk

Because experimenting with hdparm can cause crashes, and because its benchmarking feature needs almost exclusive access to the hard disk, hdparm is best run with as few as possible additional programs up and running. Therefore, first switching to run level 3 so that the GUI is deactivated is a good idea. Open a command-line shell prompt, switch to root, and type the following:

init 3

You'll then need to log in again, so do so (as an ordinary user). Once logged in, switch to root user again.

Note 

Technically speaking, switching to run level 1 is an even better idea, because this will deactivate all unnecessary services. Run level 1 is akin to the Windows Safe Mode, except without the GUI. However, you want realistic benchmark results to test the changes you make via hdparm, and it's debatable whether the restricted confines of run level 1 will provide this.

Let's start by benchmarking your hard disk to see its performance based on the current settings. Type the following (assuming SUSE Linux is installed on the first hard disk in your system; if it's on the second hard disk, change /dev/hda to /dev/hdb):

hdparm –tT /dev/hda

This will benchmark your disk in two ways. The first tests the PC's memory throughput, measuring the data rate of the memory, CPU, and cache. The second actually tests the disk's data rate. The second test affects the outcome of the first, which is why the two are used together. Between them, these two methods of benchmarking present the standard way your disk is used on a day-to-day basis. Figure 31-3 shows an example of running these tests.

image from book
Figure 31-3. Benchmarking your hard disk will let you see the results of any tweaks you make later.

Make a note of the figures so that you can compare them to the results of these tests after you change hard disk settings.

Changing Hard Disk Settings

You can use hdparm to view your current hard disk settings by entering the following at the command prompt:

hdparm /dev/hda

On my test PC, these are the results I got:

/dev/hda:  multcount    = 16 (on)  IO_support   =  1 (32-bit)   unmaskirq    =  1 (on)   using_dma    =  1 (on)   keepsettings =  0 (off)   readonly     =  0 (off)   readahead    = 256 (on)   geometry     = 65535/16/63, sectors = 160086528, start = 0

Let's take a look at what these settings mean.

The Multcount Setting

The first, multcount, refers to how many sectors can be read from the hard disk at any one time. The theory is that the highest possible value here is best. Most modern hard drives support a value of 16, but some drives may support 32. You can find out by issuing the following command:

hdparm -i /dev/hda

Look in the line headed BuffType and at the value MultSect. On my test PC, the value is 16.

Ironically, although higher values are thought best, sometimes a lower value can speed up hard disk access. You can experiment with the multcount setting on your hard disk by using the -m hdparm command option:

hdparm -m8 /dev/hda

You can then follow this by another benchmark to see if there is an improvement:

hdparm -tT /dev/hda

On my test PC, a lower value does indeed bring dividends. With a multcount value of 16, the buffer-cache read value was 606 MB/sec. With a value of 8, it rises to 633 MB/sec!

The IO Support Setting

The IO_support line refers to the input/output (I/O) mode used by the hard disk controller. There are four possible settings: 0, to disable 32-bit support; 1 to enable 32-bit support; and 3 to enable 32-bit support with a special sync signal.

You can change the IO_support setting with the -c hdparm command option:

hdparm -m8 -c3 /dev/hda

Notice that this includes the previous multcount change. This is because testing a tweak in isolation could produce erroneous results. Any changes you make and intend to keep must be used alongside tweaks you've previously used.

After a benchmark to test the changes, my test PC shows that this tweak slows down disk access, although your PC might be different.

The Unmaskirq Setting

The third setting, umaskirq, allows SUSE Linux to attend to other tasks while waiting for your hard disk to return data. This won't affect hard disk performance very much, and generally it's a good idea for the health of your system to have it turned on, as it is by default.

The Using_dma Setting

The fourth setting refers to whether Direct Memory Access (DMA) is in use. Hard disks are sold on the basis of their DMA modes, such as UltraDMA Burst 2 and the like. DMA is considered an indicator as to the speed of a hard disk, but the truth is that, like any specification, it is only a guide.

You can tweak the DMA mode using a variety of options. The first, and most necessary, is the -d1 option, which actually activates DMA. After this, you can use the -X command option. On most modern PCs, this isn't necessary because the computer's BIOS defaults to the fastest DMA mode. However, specifying that DMA should be used is necessary.

Here's a chain of hdparm commands that, on my test PC, produced a marked improvement in hard disk access speed:

hdparm -d1 -m8 /dev/hda

All of the command options for hdparm are explained succinctly in its man page, and this is well worth reading if you would like to learn more.

Other Settings

The last three settings, above the summary of the geometry and sector information of the disk, are those you shouldn't change. The readahead setting controls how many hard disk blocks are loaded in advance. It doesn't affect the performance of modern IDE-based hard disks, because the drive electronics contain buffers that perform this task themselves.

The keepsettings setting refers to the ability of the drive to remember hdparm settings over a reboot. The readonly setting sets whether or not the hard disk is read-only (so that no data can be written to it). Changes to these settings are not advisable!

Making Your Disk Optimizations Permanent

When the PC is rebooted, any changes you've made with hdparm are lost. To make this command run during bootup, you can create a custom service and add it to the current run level. This sounds more complicated than it actually is.

The first thing to do is enter the changes into a simple text file. For example, you could use vi. Simply type the command (for example, hdparm -d1 -m8 /dev/hda) in the editor window, and then save the file with a name along the lines of disk_optimize. (Make sure you add a carriage return after the line when entering it in vi.)

The next step is to make the text file an executable file, which can be done with the following command:

chmod a+x disk_optimize

This effectively turns the file into a run-level script.

The next step is to save the file with all the other run-level scripts in the /etc/init.d/ folder:

cp disk_optimize /etc/init.d/ 

Finally, the script must be symbolically linked to the current run level, using the following command:

ln -s /etc/init.d/disk_optimize /etc/init.d/rc5.d/S99disk_optimize

This also changes the filename of the symbolically linked file to tell SUSE Linux when it should be run during bootup. A value of S99 means it will be run at the very end of the boot procedure. Any hard disk performance tweaking must take place as near as possible to the end of booting, because the changes it makes can negatively affect the startup of other services.




Beginning SUSE Linux from Novice to Professional
Beginning SUSE Linux: From Novice to Professional
ISBN: 1590594584
EAN: 2147483647
Year: 2005
Pages: 293
Authors: Keir Thomas

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net