Tuning Hard Disk Drives


In addition to managing running processes and using PowerTweak, you should also consider tuning the performance of the hard disk drive in your SUSE Linux system. Input/output operations on the hard drive represent some of the most time-intensive operations your Linux kernel will have to complete as it goes about its business. Because of these, hard disk operations can become a significant bottleneck in your system.

The slow speed of hard disk operations are because hard disk drives themselves are inherently slow when compared to other storage devices such as RAM or SRAM cache. A hard disk drive is composed of mechanical devices motors, platters, and actuator arms that require a certain amount of time to complete their tasks.

However, there are some things you can do improve the performance of the drives in your system. The first aspect you need to consider is the type of drive you use in your computer. Let's talk about this topic next.

Choosing the Best Hardware

Not all hard disk drives are the same. The quality of the drive you choose can make a big difference in the overall performance of your system. When selecting a drive, you should keep the following points in mind:

  • Drive Interface Most desktop systems sold today use Integrated Drive Electronics (IDE) hard drives. (The newer generation of IDE drives are called Advanced Technology Attachment [ATA] drives.) These drives are inexpensive to manufacture and can store a large amount of data, hence their popularity.

    Unfortunately, IDE/ATA drives have some serious shortcomings that you should keep in mind. First, the IDE controller on the master drive requires a lot of CPU time to read or write data. Although IDE drives may have a high data-transfer rate, the CPU is going to have to do a lot of work to make it happen.

    Second, remember that each IDE channel on your system (the primary and the secondary channels) can each have two IDE devices connected to it, resulting in a total of four drives in a typical system. Keep in mind that many different types of IDE drives have been manufactured over the years. Early IDE drives transmitted data at around only 15MBps. Later-generation IDE drives can transfer data at speeds up to 133MBps. If you connect an older, slower drive to an IDE channel with a newer drive, the newer drive will slow down to the speed of the old drive. The entire channel will operate at the speed of the slowed device connected to it.

    Finally, attaching two devices to the same IDE/ATA channel can slow things down because a single drive controller must manage two devices. If you choose to use IDE/ATA, you will get the best performance if you install a single device on each channel.

    If you want the best performance possible from your disk subsystem, you should consider using either a Serial ATA (SATA) or Small Computer System Interface (SCSI) disk controller and drive. Both of these systems address many of the shortcomings of IDE and provide better performance.

  • Data Transfer Rate Over the years, many types of hard disk interfaces have been manufactured. Some interfaces are faster than others with respect to the amount of data they can transfer. If you choose to use an IDE/ATA disk interface, be sure to select either an ATA100 or ATA133 system.

    If you choose SCSI, you might find your choices a little more complicated. Over the years, a variety of SCSI standards have been implemented, including SCSI I, SCSI II, and SCSI III. Within the SCSI II and III standards, you can choose from Fast, Wide, and Fast/Wide options. Although the variations can get confusing, you'll get the best performance from a SCSI III Fast/Wide adapter and hard disk combination.

    If you go with SATA, you can choose between SATA150, which transfers data at 150MBps, and SATA300, which transfers data at 300MBps. As with the other disk options, the faster the drive and controller, the faster the performance of your system.

  • Disk Rotation Speed Remember that hard disks are mechanical devices. The speed at which data can be read or written is heavily dependent on how fast the platters inside the disk rotate. The faster the rotation speed, the faster data can be read or written. Low-end, inexpensive drives rotate at around 3500 RPMs. Midrange disks rotate at around 5000 RPMs. Fast disks rotate at 7200 or even 10000 RPMs. The faster the rotation, the better your system performance will be.

After you've selected the best drive for your system, you can then tune your drive for its best performance. Let's talk about how to do this next.

Tuning Hard Drive Parameters at Boot

One way to tune your hard drive involves adjusting the settings in your BIOS. Every BIOS seems different, and in any case is not Linux, so consult your motherboard manual before proceeding. Take every precaution, and make sure the BIOS sees all your drives. Change one setting at a time.

Linux does offer a limited means to interact with BIOS settings during the boot period (mostly to override them).

Other options include these commands, which can be used to force IDE controllers and drives to be optimally configured. Your mileage may vary, but they have worked for some. You can get more information in the Bootprompt HOWTO at the Linux Documentation Project. Consider the following:

idex=dma This will force DMA support to be turned on for the primary IDE bus, where x=0, or the secondary bus, where x=1.

idex=autotune This command will attempt to tune the interface for optimal performance.

idex=ata66 If you have ATA66 drives and controllers, this command will enable support for them.

hdx=ide-scsi This command will enable SCSI emulation of an IDE drive. This is required for some CD-RW drives to work properly in Write mode, and it might provide some performance improvements for regular CD-R drives as well.

idebus=xx This can be any number from 20 66; autodetection is attempted, but this can set it manually if dmesg says that it isn't autodetected correctly, or if you have it set in the BIOS to a different value (overclocked). Most PCI controllers will be happy with 33.

pci=biosirq Some motherboards might cause Linux to generate an error message saying that you should use this. Look in dmesg for it; if you do not see it, you don't need to use it.

These options can be sent to the kernel at startup by pressing F2 at the GRUB menu and entering them in the Boot Options Field. You can also use the YaST Bootloader module to insert these parameters into /boot/grub/menu.lst. To do this, complete the following:

1.

Run YaST and navigate to System, bootloader.

2.

In the Section Management tab, select the menu item you want to add these options to.

3.

Select Edit.

4.

In the Other Kernel Parameters field, enter the option you want to include.

5.

Select OK.

6.

Select Finish.

You can also use the hdparm utility to tune your drive. Let's talk about how to do that next.

The hdparm Command

The hdparmutility can be used by the SuperUser to set and tune the settings for IDE hard drives. You would do this to tune the drives for optimal performance.

Once a kernel patch and associated support program, hdparm is now included with SUSE Linux. You should only experiment with the drives mounted read-only because some settings can damage some file systems when used improperly. Evidence of this can be seen when typing the hdparm command without any arguments. This displays the program's help; look at all the options marked DANGEROUS:

hdparm - get/set hard disk parameters - version v5.9 Usage:  hdparm  [options] [device] .. Options:  -a   get/set fs readahead  -A   set drive read-lookahead flag (0/1)  -b   get/set bus state (0 == off, 1 == on, 2 == tristate)  -B   set Advanced Power Management setting (1-255)  -c   get/set IDE 32-bit IO setting  -C   check IDE power mode status  -d   get/set using_dma flag (0/1)  --direct  use O_DIRECT to bypass page cache for timings  -D   enable/disable drive defect management  -E   set cd-rom drive speed  -f   flush buffer cache for device on exit  -g   display drive geometry  -h   display terse usage information  -i   display drive identification  -I   detailed/current information directly from drive  --Istdin  reads identify data from stdin as ASCII hex  --Istdout writes identify data to stdout as ASCII hex  -k   get/set keep_settings_over_reset flag (0/1)  -K   set drive keep_features_over_reset flag (0/1)  -L   set drive doorlock (0/1) (removable harddisks only)  -M   get/set acoustic management (0-254, 128: quiet, 254: fast) (EXPERIMENTAL)  -m   get/set multiple sector count  -n   get/set ignore-write-errors flag (0/1)  -p   set PIO mode on IDE interface chipset (0,1,2,3,4,...)  -P   set drive prefetch count  -q   change next setting quietly  -Q   get/set DMA tagged-queuing depth (if supported)  -r   get/set device  readonly flag (DANGEROUS to set)  -R   register an IDE interface (DANGEROUS)  -S   set standby (spindown) timeout  -t   perform device read timings  -T   perform cache read timings  -u   get/set unmaskinq flag (0/1) 

Note

Setting the -u option to 1 can result in a significant boost in the performance of the system. However, some IDE drives don't support this parameter.


 -U   un-register an IDE interface (DANGEROUS)  -v   defaults; same as -mcudkrag for IDE drives  -V   display program version and exit immediately  -w   perform device reset (DANGEROUS)  -W   set drive write-caching flag (0/1) (DANGEROUS)  -x   tristate device for hotswap (0/1) (DANGEROUS)  -X   set IDE xfer mode (DANGEROUS)  -y   put IDE drive in standby mode  -Y   put IDE drive to sleep  -Z   disable Seagate auto-powersaving mode  -z   re-read partition table 

As you can see, the general format of the command is this:

hdparm <option> <device> 

This tests an IDE hard drive:

hdparm -tT /dev/hda 

Be sure to replace /dev/hda with the mount point of your hard drive (usually with a number added, such as dev/hda1). hdparm will then run two tests cached reads and buffered disk reads. A good IDE hard drive should be getting 400 500MB/sec for the first test and 20 30MB/sec for the second. Note your scores, and then try this command:

hdparm -a16 -d1 -u1 -c1 /dev/hda 

After you've made these changes (take another look at the help to see what you're doing), test the drive again. The numbers should increase. If so, run this command:

hdparm -a16 -d1 -u1 -c1 -k1 /dev/hda 

The -k1 option saves the settings, and uses them on subsequent boots.

Read over the man page for more information about the multitude of options previously listed. Be aware that the SUSE engineers do their best to optimize all the settings before shipping the distribution. Because they cannot anticipate every configuration, however, it's worth a try to see what you can get on your own, if you're so inclined.

You can also increase performance by disabling file access time. Let's look at how to do that next.

Disabling File Access Time

Whenever Linux reads a file, it changes the last access time known as the atime. This is also true for your web server. If you are getting hit by 50 requests per second, your hard drive will be updating the atime 50 times a second. If you don't really need to know when a file was last accessed, you can disable atime by modifying /etc/fstab to include the noatime attribute for the file system.

With an ext2/ext3 file system, you can also use the chattr (change attribute) command to turn off atime changes by directory with this command:

chattr -R +A <directory_path> 

The -R switch makes the command operate recursively through the subdirectories of the specified directory.

With this in mind, let's now discuss how to spread out the disk load on your system.

Spreading Out the Load

With a Linux system, certain directories and partitions are used more heavily than others. These include the swap partition, /var, /tmp, and /home. Placing all these on the same hard disk can slow down performance.

To increase performance, they should be spread across multiple hard disk drives. If possible, the performance can be increased by installing multiple hard drives in your system and creating separate partitions for /var, /tmp, and /home, distributing them (along with the swap partition) across the drives.

Note

In an ideal world, you would place each of these partitions on a separate hard drive to achieve the maximum level of performance.


Doing this distributes the read/write load across multiple drives, allowing multiple operations to occur simultaneously.



SUSE Linux 10 Unleashed
SUSE Linux 10.0 Unleashed
ISBN: 0672327260
EAN: 2147483647
Year: 2003
Pages: 332

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