Created with The GIMP


2007 CHLUGger of the Year!
Mailing List
Help Open Source
Question of the Day

About Us

Directions to Meetings
Contact Us
Guest Speaker Info
Acceptable Use
Link To Us!

CHLUG Exclusives

Open Office 3.0- New and Enhanced Features New!
Linux Hacking and the Law New!
VOIP with Asterisk
Assessing OSS
Knoppix Ubiquitous Computing
Filesystem Hierarchy
Virtual Hosting
Emacs Talk Notes
Home Sweet ~
Top 100 CLIs
Device Drivers
Real Time Linux
Network Considerations Part II
Network Considerations Part I
Amanda Presentation
GNU/Linux Calculators Configuring Rio
Linux Sound
Samba notes
Network time protocol
C programming in Linux
Boot, startup and shutdown
hdparm HOWTO

Friends of CHLUG

Ubuntu NJ LoCo
Cherry Hill Library
LUG in Princeton
Useful Links

Loads of Linux Links
Art of UNIX Programming
More Links


Contact Congress
Why We Use Linux
Companies Using Linux
Linux in Business

Get Linux!

Get Firefox!


Created with The GIMP

Website Designer-

hdparm: Tweaking Hard Drive Performance

(Paul Agin Jan 26, 2001  Tested using Red Hat 7.0. Examples are hardware


[root@aboo /sbin]# hdparm

hdparm - get/set hard disk parameters - version v3.9

Usage:  hdparm  [options] [device] ..

 -a get/set fs readahead
 -A set drive read-lookahead flag (0/1)
 -c get/set IDE 32-bit IO setting
 -C check IDE power mode status
 -d get/set using_dma flag
 -D enable/disable drive defect-mgmt
 -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 read drive identification directly from drive
 -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 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
 -r get/set 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 unmaskirq flag (0/1)
 -U un-register an IDE interface (DANGEROUS)
 -v default; same as -acdgkmnru (-gr for SCSI, -adgr for XT)
 -V display program version and exit immediately
 -W set drive write-caching flag (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


Identify the drive to be tweaked. In this case, /dev/hda will be

 [root@aboo /bin]# df
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/hda7              3281088   1499864   1614552  49% /
/dev/hda5               711508    576700     98664  86% /RPMS
/dev/hda1                15522      3070     11651  21% /boot
/dev/hdb                638866    638866         0 100% /mnt/cdrom
/dev/sda4                98078     88170      9908  90% /mnt/zip


Get detailed information about the drive. Notice MaxMultSect=16, but
MultSect=off. Also, the drive supports UltraDMA mode 2.

[root@aboo /sbin]# hdparm -i /dev/hda


 Model=WDC AC24300L, FwRev=20.03W20, SerialNo=WD-WT4860264812
 Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs
 RawCHS=8912/15/63, TrkSize=57600, SectSize=600, ECCbytes=22
 BuffType=DualPortCache, BuffSize=256kB, MaxMultSect=16, MultSect=off
 CurCHS=8912/15/63, CurSects=-2117074816, LBA=yes, LBAsects=8421840
 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 udma0 udma1 *udma2


Test drive performance before tweaking.

[root@aboo /sbin]# hdparm -t /dev/hda

 Timing buffered disk reads:  64 MB in 22.36 seconds = 2.86 MB/sec


Check the current drive settings.

[root@aboo /sbin]# hdparm /dev/hda
 multcount = 0 (off)
 I/O support = 0 (default 16-bit)
 unmaskirq = 0 (off)
 using_dma = 0 (off)
 keepsettings = 0 (off)
 nowerr = 0 (off)
 readonly = 0 (off)
 readahead = 8 (on)
 geometry     = 524/255/63, sectors = 8421840, start = 0


Tweak the drive. Test all settings individually first, then they can be
combined into one command string. A zero usually disables an
option. Example, -d0 disables DMA.

 -c   get/set IDE 32-bit IO setting
 -d   get/set using_dma flag
 -m   get/set multiple sector count
 -k   get/set keep_settings_over_reset flag (0/1)

[root@aboo /sbin]# hdparm -c3 -d1 -m16 -k1 /dev/hda

 setting 32-bit I/O support flag to 3
 setting multcount to 16
 setting using_dma to 1 (on)
 setting keep_settings to 1 (on)
 multcount = 16 (on)
 I/O support = 3 (32-bit w/sync)
 using_dma = 1 (on)
 keepsettings = 1 (on)


Drive performance after tweaking.

[root@aboo /sbin]# hdparm -t /dev/hda

 Timing buffered disk reads:  64 MB in 8.70 seconds = 7.36 MB/sec


Run the numbers...

7.36 MB/sec - 2.86 MB/sec = 4.5 MB/sec

4.5 MB/sec
----------- x 100% = 157% increase in speed
2.86 MB/sec


Here are a couple more tests:

 Timing buffered disk reads:  64 MB in 24.37 seconds =  2.63 MB/sec
 Timing buffered disk reads:  64 MB in  7.02 seconds =  9.12 MB/sec
246% increase in speed.

 Timing buffered disk reads:  64 MB in 22.64 seconds =  2.83 MB/sec
 Timing buffered disk reads:  64 MB in  6.95 seconds =  9.21 MB/sec
225% increase in speed.


If you want the changes to be made at boot, uncomment the selected
options in /etc/sysconfig/harddisks (This file is read by
/etc/rc.d/rc.sysinit) Another way is to add the command
/sbin/hdparm -c3 -d1 -m16 -k1 /dev/hda
to any startup script, such as /etc/rc.d/rc.local


Another use for hdparm is drive power management. The following
can be issued manually, or an option can be used to set an automatic
timeout. See the hdparm man page for more details.

[root@aboo /sbin]# hdparm -y /dev/hda

 issuing standby command

[root@aboo /sbin]# hdparm -Y /dev/hda
 issuing sleep command