How to speed up your hard drive on Linux

Tags: , , , , ,

Linux servers usually use conservative default IDE driver settings that could be significantly slowing down your system. By default they are set to most safe settings guaranteed to work.

To get faster 32-bit file transfer on your hard drive, you can use HDPARM command. It provides a command line interface to various hard disk ioctls supported by the stock Linux ATA/IDE device driver subsystem. Some  options may work correctly only with the latest kernels.  For best results, compile hdparm with the include files from the latest kernel source code.

You can add the following line to your Linux bootup script:

Edit /etc/init.d/boot.local and insert:

hdparm -c3 /dev/hdX*

Where,
* X is your HDD number
* c3 is I/O support set to 3 - turn on 32bit transfers

Personally I did a quick test:

1. Create a new 1G IDE partition on my SLES10 VMware guest my VMware Workstation
2. Login and create a dummy file(around 882m) using ‘dd‘ command:

#dd if=/dev/zero of=/backup/yourfilename bs=1024 count=902400

3. Format IDE hard drive as ext3 partition and mount as /test
4. Copy /backup/yourfilename to /test and it took 1 minit and 26 seconds
5. Insert hdparm -c3 /dev/hda1 into /etc/init.d/boot.local and reboot
6. Copy /backup/yourfilename to /test folder and it took 26 seconds only

For meaningful test performance use:, this operation should be repeated 2-3 times on an otherwise inactive system.
Here is for loop to run test 3 time in a row:

for i in 1 2 3; do hdparm -tT /dev/hda; done
/dev/hda:
Timing cached reads:   2888 MB in  2.00 seconds = 1447.10 MB/sec
Timing buffered disk reads:  36 MB in  3.12 seconds =  11.15 MB/sec

/dev/hda:
Timing cached reads:   2864 MB in  2.00 seconds = 1434.04 MB/sec
Timing buffered disk reads:  56 MB in  3.09 seconds =  18.12 MB/sec

/dev/hda:
Timing cached reads:   2960 MB in  2.00 seconds = 1482.61 MB/sec
Timing buffered disk reads:  66 MB in  3.05 seconds =  21.65 MB/sec

Where,
* -t :perform device read timings
* -T : perform cache read timings
* /dev/hda : Hard disk device file

Conclusion:
This enables a 32-bit transfer on your hard drive and can improve performance up to 75%.

Others Option:

Display the identification info that  was  obtained from the drive at boot time, if available. This is a feature of modern IDE drives, and may not
be supported  by older devices.

#hdparm -i /dev/hda

/dev/hda:
Model=VMware Virtual IDE Drive, FwRev=00000001, SerialNo=00000000000000000001
Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGapReq}
RawCHS=2080/16/63, TrkSize=0, SectSize=0, ECCbytes=0
BuffType=unknown, BuffSize=32kB, MaxMultSect=64, MultSect=64
CurCHS=2080/16/63, CurSects=2096640, LBA=yes, LBAsects=2097152
IORDY=on/off, tPIO={min:160,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes:  pio0 pio1 pio2 pio3 pio4
DMA modes:  mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 *udma2
AdvancedPM=yes: mode=0xFE (254)
Drive conforms to: ATA/ATAPI-4 T13 1153D revision 17:  1 2 3 4

Display all setting
#hdparm -v /dev/hda

/dev/hda:
multicount   =  64 (on)
IO_support   =  0 (default 16-bit)
unmaskirq    =  0 (off)
using_dma    =  1 (on)
keepsettings =  0 (off)
readonly     =  1 (on)
readahead    = 1024 (on)
geometry     = 2080/16/63, sectors = 2097152, start = 0

Warning:
Be aware that, on some systems, modifying the hard drive settings can result in data corruption.

Possibly Related Posts:


One Response to “How to speed up your hard drive on Linux”

  1. Tutorials Room Says:

    Hi , your tutorial was chosen for the main page of http://www.tutorialsroom.com and under Linux/Unix tutorials. Please feel free to submit more of your good tutorials using this link: http://www.tutorialsroom.com/tutorials/submit_tutorials.html

Leave a Reply