Testing and Optimizing Disk Performance under Linux
# /sbin/hdparm -Tt /dev/hdb
In order to get reliable results, you should perform these tests on a system that’s otherwise not doing much, and especially not performing any disk-intensive tasks.
What’s poor performance? This depends on the disk. You should be able to find detailed specifications for your disk on the manufacturer’s website. You need to find the specification for sustained transfer speeds to and from the disk’s media.
If you believe your disk speed is deficient, you should search for a reason for the problem. In the case of ATA disks, the -v parameter to hdparm produces a summary of disk settings:
# /sbin/hdparm -v /dev/hdb
The most important setting displayed by this output is the using_dma item. This setting reveals whether the controller is using direct memory access (DMA) mode, in which the controller directly transfers data between the disk and the computer’s memory. The alternative is programmed input/output (PIO) mode, in which the computer’s CPU mediates all transfers. DMA mode is generally faster than PIO mode, and DMA transfers impose a lower CPU load, so disk accesses should not slow down CPU-intensive programs as much.
If Linux isn’t running your disks in an optimal mode, you can use hdparm to adjust its settings. In some cases, you can apply driver-specific options to your ATA driver. Finally, one issue of disk performance doesn’t relate to speed, but it is important to laptop users: energy use. You can configure the disks to spin down when they haven’t been accessed for some time, thereby saving energy.
Normally, a computer’s hard disks spin whenever the computer is turned on. This feature makes disk access swift, because there’s no need to begin spinning the disk to access a file; however, it consumes a fair amount of power. Therefore, spinning down a disk when it’s not in use is helpful. Doing so is particularly helpful on laptop computers, on which a spinning hard disk can greatly reduce battery life. hdparm supports the -S option to set this feature.
Value Meaning
0 Power-saving mode disabled; disk never goes into low-power mode.
1–240 Time in 5-second multiples; for instance, 12 means 60 seconds.
241-251 Units of 30 minutes (241), 60 minutes (242), and so on through 5.5 hours (251).
252 21 minutes.
253 Drive-specific timeout value.
255 21 minutes and 15 seconds.
For instance, to set the disk to power down after ten minutes of inactivity, you could type the following command:
# hdparm -S120 /dev/hda
Linux Commands/Tools Tips
iEntry 10th Anniversary
LinuxHaxor
WH
MH
