Tuesday, 30 June 2009

Tuning the hard drive

Ever thought why your disk takes ages to move that all important film your private folder? May be Linux utility hdparm can help you. hdparm is a utility which allows you to view and change certain hard disk parameters whether it be SATA or PATA. Here are some useful commands which you can use to probe the status of your drive and find tune it.

Viewing hard drive information
* hdparm -I /dev/sda

Viewing hard drive performance
* hdparm -Tt /dev/sda

Syntax explanation
* Options
-T = Checks the how quickly data can be passed between the processor, memory, and disk cache
-t = Reads continuously from the hard disk without reading previously cached data. This gives an indication of the speed at which Linux can read sequential data from the disk

Tuning the drive
* hdparm -W1 /dev/sda (Turns write cache on. Use -W0 to set it to off)
* hdparm -A1 /dev/sda (Turns read ahead cache on. Use -A0 to set it to off)
* hdparm -a[n] /dev/sda (Turns read ahead cache on with n KB read ahead)
* hdparm -d1 [mode-option] /dev/sda (Turns DMA on with specified mode)

mode mode-option

pio0 -X08 Programmed I/O
pio1 -X09
pio2 -X10
pio3 -X11
pio4 -X12
mdma0 -X32 Multiword DMA
mdma1 -X33
mdma2 -X34
udma0 -X64 Ultra DMA
udma1 -X65
udma2 -X66
udma3 -X67
udma4 -X68
udma5 -X69
* hdparm -m[n] /dev/sda (Turns on mulisector I/O mode in which more than one sector can be transferred within one interrupt. n is the number of sectors. Typical 8,16 etc.)

Try experiment with these options and then measure disk performance with every change. You may be surprised with some improvements. But remember some setting may be too aggressive to your hard-drive. So think twice if you are setting too aggressive values to increase the performance.

Making things permanent

These changes will only be available in the current session. Modify /etc/hdparm.conf with these options to make the changes permanent across reboots.

No comments: