Speeding up Linux Using hdparm


Recommended Posts

Speeding up Linux Using hdparm
by Rob Flickenger
06/29/2000 
Are you running an Intel Linux system with at least one (E)IDE hard drive?

Wouldn't it be neat if there were a magical command to instantly double the I/O performance of your disks? Or, in some cases, show 6 to 10 times your existing throughput?

Did you ever just wonder how to tell what kind of performance you're getting on your "tricked-out" Linux box?

Don't overlook hdparm(8). If you've never heard of it, don't worry. Most people I've talked to haven't either. But if you're running an IDE/Linux system (as many folks are,) you'll wonder how you ever got this far without it. I know I did.

What's the big deal?
So, you've got your brand-new UltraATA/66 EIDE drive with a screaming brand-new controller chipset that supports multiple PIO modes and DMA and the leather seat option and extra chrome... But is your system actually taking advantage of these snazzy features? The hdparm(8) command will not only tell you how your drives are performing, but will let you tweak them out to your heart's content.

Now before you get too excited, it is worth pointing out that under some circumstances, these commands CAN CAUSE UNEXPECTED DATA CORRUPTION! Use them at your own risk! At the very least, back up your box and bring it down to single-user mode before proceeding.

With the usual disclaimer out of the way, I'd like to point out that if you are using current hardware (i.e. your drive AND controller AND motherboard were manufactured in the last two or three years), you are at considerably lower risk. I've used these commands on several boxes with various hardware configurations, and the worst I've seen happen is the occasional hang, with no data problems on reboot. And no matter how much you might whine at me and the world in general for your personal misfortune, we all know who is ultimately responsible for the well-being of YOUR box: YOU ARE. Caveat Fair Reader.

Now, then. If I haven't scared you away yet, try this (as root, preferably in single-user mode):

hdparm -Tt /dev/hda
You'll see something like:

/dev/hda:
 Timing buffer-cache reads:   128 MB in  1.34 seconds =95.52 MB/sec
 Timing buffered disk reads:  64 MB in 17.86 seconds = 3.58 MB/sec
What does this tell us? The -T means to test the cache system (i.e., the memory, CPU, and buffer cache). The -t means to report stats on the disk in question, reading data not in the cache. The two together, run a couple of times in a row in single-user mode, will give you an idea of the performance of your disk I/O system. (These are actual numbers from a PII/350 / 128M Ram / newish EIDE HD; your numbers will vary.)

But even with varying numbers, 3.58 MB/sec is PATHETIC for the above hardware. I thought the ad for the HD said something about 66MB per second!!?!? What gives?

Well, let's find out more about how Linux is addressing your drive:

hdparm /dev/hda

/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     = 1870/255/63, sectors = 30043440, start = 0
These are the defaults. Nice, safe, but not necessarily optimal. What's all this about 16-bit mode? I thought that went out with the 386! And why are most of the other options turned off?

Well, it's generally considered a good idea for any self-respecting distribution to install itself in the kewlest, slickest, but SAFEST way it possibly can. The above settings are virtually guaranteed to work on any hardware you might throw at it. But since we know we're throwing something more than a dusty, 8-year-old, 16-bit multi-IO card at it, let's talk about the interesting options:

multcount: Short for multiple sector count. This controls how many sectors are fetched from the disk in a single I/O interrupt. Almost all modern IDE drives support this. The man page claims: 


When this feature is enabled, it typically reduces operating system overhead for disk I/O by 30-50%. On many systems, it also provides increased data throughput of anywhere from 5% to 50%.
I/O support: This is a big one. This flag controls how data is passed from the PCI bus to the controller. Almost all modern controller chipsets support mode 3, or 32-bit mode w/sync. Some even support 32-bit async. Turning this on will almost certainly double your throughput (see below.) 


unmaskirq: Turning this on will allow Linux to unmask other interrupts while processing a disk interrupt. What does that mean? It lets Linux attend to other interrupt-related tasks (i.e., network traffic) while waiting for your disk to return with the data it asked for. It should improve overall system response time, but be warned: Not all hardware configurations will be able to handle it. See the manpage. 


using_dma: DMA can be a tricky business. If you can get your controller and drive using a DMA mode, do it. But I have seen more than one machine hang while playing with this option. Again, see the manpage (and the example on the next page)! 






Turbocharged
So, since we have our system in single-user mode like a good little admin, let's try out some turbo settings:

hdparm -c3 -m16 /dev/hda

/dev/hda:
 setting 32-bit I/O support flag to 3
 setting multcount to 16
 multcount    =  16 (on)
 I/O support  =  3 (32-bit w/sync)

Great! 32-bit sounds nice. And some multi-reads might work. Let's re-run the benchmark:

hdparm -tT /dev/hda


/dev/hda:
 Timing buffer-cache reads:   128 MB in  1.41 seconds =90.78 MB/sec
 Timing buffered disk reads:  64 MB in  9.84 seconds = 6.50 MB/sec
WOW! Almost double the disk throughput without really trying! Incredible.

But wait, there's more: We're still not unmasking interrupts, using DMA, or even a using decent PIO mode! Of course, enabling these gets riskier. (Why is it always a trade-off between freedom and security?) The man page mentions trying Multiword DMA mode2, so:

hdparm -X34 -d1 -u1 /dev/hda
...Unfortunately this seems to be unsupported on this particular box (it hung like an NT box running a Java app.) So, after rebooting it (again in single-user mode), I went with this:

hdparm -X66 -d1 -u1 -m16 -c3 /dev/hda

/dev/hda:
 setting 32-bit I/O support flag to 3
 setting multcount to 16
 setting unmaskirq to 1 (on)
 setting using_dma to 1 (on)
 setting xfermode to 66 (UltraDMA mode2)
 multcount    = 16 (on)
 I/O support  =  3 (32-bit w/sync)
 unmaskirq    =  1 (on)
 using_dma    =  1 (on)
And then checked:

hdparm -tT /dev/hda

/dev/hda:
 Timing buffer-cache reads:   128 MB in  1.43 seconds =89.51 MB/sec
 Timing buffered disk reads:  64 MB in  3.18 seconds =20.13 MB/sec

20.13 MB/sec. A far cry from the miniscule 3.58 we started with...

By the way, notice how we specified the -m16 and -c3 switch again? That's because it doesn't remember your hdparm settings between reboots. Be sure to add the above line to your /etc/rc.d/* scripts once you're sure the system is stable (and preferably after your fsck runs; having an extensive fs check run with your controller in a flaky mode may be a good way to generate vast quantities of entropy, but it's no way to administer a system. At least not with a straight face...)

Now, after running the benchmark a few more times, reboot in multi-user mode and fire up X. Load Netscape. And try not to fall out of your chair.

In conclusion
This is one of those interesting little tidbits that escapes many "seasoned" Linux veterans, especially since one never sees any indication that the system isn't using the most optimal settings. (Gee, all my kernel messages have looked fine....) And using hdparm isn't completely without risk, but is well worth investigating.

And it doesn't stop at performance: hdparm lets you adjust various power saving modes as well. See the hdparm(8) for the final word.

Many thanks to Mark Lord for putting together this nifty utility. If your particular distribution doesn't include hdparm (usually in /sbin or /usr/sbin), get it from the source at http://metalab.unc.edu/pub/Linux/system/hardware/

Happy hacking!

Rob Flickenger is the author of three O'Reilly books: Building Wireless Community Networks, 2nd Edition, Linux Server Hacks, and Wireless Hacks. 


--------------------------------------------------------------------------------

Discuss this article in the O'Reilly Network Linux Forum.

Return to the Linux DevCenter.



oreillynet.com Copyright ? 2003 O'Reilly & Associates, Inc.

Link to comment
https://www.neowin.net/forum/topic/137915-speeding-up-linux-using-hdparm/
Share on other sites

  • 1 year later...
  • 2 months later...

:o

Oh no. He didn't just say that, did he? :rofl:

I used to moderate here, until I found that too much of my free time was spent cleaning up, and looking for rule violations and mis-placed threads. I became obsessive-compulsive about being available to keep things in proper order.

Now I just let the staff do it (and those guys really put a LOT of effort into making Neowin a great place, I know!) and I am much happier. The kids get to see more of daddy, too, and I spend more time pitching them baseballs and such. :)

  • 4 weeks later...

Pretty cool

The correct dma modes are usually set by default either way

my hitachi eide laptop drive was missing -m16 -u1 -c3 although I didn't see any performance increase, at least I know I have it set up correctly now

both my optorite cd/dvd drives on my laptop/pc were missing -c3

I have added these settings to my /etc/rc.local (ubuntu/debian)

hdparm can't acces my SATA drive but I would guess it is optimally configured by default

It also might be worth settings -A1 (enable drive lookahead feature) and -W1 (enable write caching feature) on the HDD

Edited by Z3r0

thanks for that information daPhoenix, I downloaded sdparm via apt

sdparm is for scsi drives and works with the sata drives too

lots of information via sdparm --enquire --all /dev/sda and sdparm --all /dev/sda to see valid options

try this too sdparm --enumerate --page ca to see the caching options page, sdparm --page=ca to see the value of WCE if WCE=1 then write caching is enabled

can't see much else to play with though

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Google Chrome 149.0.7827.103 (offline installer) by Razvan Serea The web browser is arguably the most important piece of software on your computer. You spend much of your time online inside a browser: when you search, chat, email, shop, bank, read the news, and watch videos online, you often do all this using a browser. Google Chrome is a browser that combines a minimal design with sophisticated technology to make the web faster, safer, and easier. Use one box for everything--type in the address bar and get suggestions for both search and Web pages. Thumbnails of your top sites let you access your favorite pages instantly with lightning speed from any new tab. Desktop shortcuts allow you to launch your favorite Web apps straight from your desktop. Chrome has many useful features built in, including automatic full-page translation and access to thousands of apps, extensions, and themes from the Chrome Web Store. Google Chrome is one of the best solutions for Internet browsing giving you high level of security, speed and great features. Important to know! The offline installer links do not include the automatic update feature. Download web installer: Google Chrome Web 32-bit | Google Chrome 64-bit | Freeware Download: Google Chrome Offline Installer 64-bit | Direct Link | 131.0 MB Download: Google Chrome Offline Installer 32-bit | Direct Link | 119.0 MB Download page: Google Chrome Portable Download: Chrome ARM64 | Direct Link View: Chrome Website | Release Notes Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Apple would rather delay Siri AI than open iOS to rival assistants in the EU by Pradeep Viswanathan At WWDC 2026, Apple today announced a revamped Siri AI experience for iOS and iPadOS users. However, this new Siri AI experience will not be available on iPhones and iPads in the European Union when iOS 27 and iPadOS 27 launch later this year. In a detailed press release, Apple blamed the Siri delay on the EU’s Digital Markets Act, highlighting that EU regulators did not accept its proposed solutions for bringing Siri AI to the region. Consequently, there is currently no timeline for Siri AI’s availability on iOS and iPadOS in the EU. Here is what EU users will be missing due to this delay: Siri AI, Apple’s next-generation assistant powered by Apple Intelligence A new dedicated Siri app for revisiting conversations Expanded Visual Intelligence features Integrated AI-assisted writing tools Siri mode in Camera on iOS Other system-level AI features Since the new Siri experience on watchOS 27 is dependent on an iOS 27 device, EU users will also miss out on Siri AI on watchOS 27. The most frustrating part is that even developers based in the EU will not be able to test or use the new Siri AI features for their apps on iOS 27, iPadOS 27, and watchOS 27. In its press release, Apple mentioned that making Siri AI available in the EU would require the company to give other AI assistants (like ChatGPT, Claude, and Gemini) broad access to private user data and the ability to control installed apps. Essentially, the EU wants competing AI systems to be able to read and send messages, make purchases, access files, and perform actions across apps. To address these concerns, Apple proposed an intermediary system called Trusted System Agent. This system would have allowed other virtual assistants to access the same features as Siri AI in a safer way. However, the European Commission rejected Apple's proposals, and it is currently unclear why. The good news is that Apple stated it will continue working with EU regulators to bring Siri AI to the region. For now, however, iPhone and iPad users in the EU will have to wait. If platform gatekeepers such as Apple and Google reserve deep operating system capabilities only for their own AI assistants, rival services such as ChatGPT, Claude, Perplexity, and others will be at a major disadvantage. Modern AI assistants are no longer simple chatbots. They require access to core OS-level capabilities such as reading on-screen context, interacting with installed apps, sending messages, creating calendar events, managing files, and completing user-approved actions across the device. If only Siri on iOS or Gemini on Android can access these capabilities, competing AI services will struggle to offer the same level of convenience, even if their underlying models are better. This is exactly what the European Union's DMA is trying to address. Apple and Google should be allowed to protect user privacy and security, but they should not be permitted to use those concerns as a blanket excuse to block rival AI assistants from getting fair access to core platform features. A secure permission-based framework could allow users to choose their preferred AI assistant without giving any company unrestricted access to personal data.
    • Firefox 151.0.4 by Razvan Serea Firefox is a fast, full-featured Web browser. It offers great security, privacy, and protection against viruses, spyware, malware, and it can also easily block pop-up windows. The key features that have made Firefox so popular are the simple and effective UI, browser speed and strong security capabilities. Firefox has complete features for browsing the Internet. It is very reliable and flexible due to its implemented security features, along with customization options. Firefox includes pop-up blocking, tab-browsing, integrated Google search, simplified privacy controls, a streamlined browser window that shows you more of the page than any other browser and a number of additional features that work with you to help you get the most out of your time online. Firefox key features Enhanced Tracking Protection (ETP) – Blocks trackers, cookies, cryptominers, and fingerprinters by default. Private Browsing Mode – Deletes history, cookies, and temporary files when closed. Lightweight & Fast Performance – Optimized memory usage with efficient page loading. Cross-Platform Sync – Sync bookmarks, passwords, history, and open tabs across devices. Customizable Interface – Toolbars, themes, and extensions can be tailored to user needs. Strong Privacy Controls – Options to manage cookies, permissions, and site data easily. Reader Mode – Strips away clutter for distraction-free reading. Pocket Integration – Save and read articles offline with Pocket built into Firefox. Picture-in-Picture (PiP) – Watch videos in a floating window while multitasking. Extensions & Add-ons – Vast library for productivity, security, and personalization. Built-in PDF Viewer – No need for external software to view PDFs. Firefox Monitor – Alerts users if their email is part of a known data breach. Multi-Account Containers – Isolate browsing sessions (e.g., work, personal, shopping). Performance & Resource Efficiency – Uses fewer system resources than some competitors. Open Source & Community-Driven – Transparent development with global contributions. Download: Firefox 64-bit | Firefox 32-bit | ARM64 | ~70.0 MB (Freeware) Download: Firefox for MacOS | 145.0 MB View: Firefox Home Page | Release Notes Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • When I was a teen, I actually believed that the government used to be always be the bad guy. However as an adult, someone who has actually seen the Law work (though not perfect). I now think everyone cries a river. In this specific case, the so called freedom has consequences to society. Anyone who has seen how child are indeed affected, and I don't mean only extreme things like getting drugs or hate crimen , but no one can deny society as a whole has gone down a rabbit hole due to exesive use of internet. Before anyone calls out that it's the parents responsibility. Yes that's true, but the reality your family/kids might be good people. There are 99% out there who are not and have been brain dead by many things on the internet.
  • Recent Achievements

    • Very Popular
      Captain_Eric earned a badge
      Very Popular
    • One Month Later
      amusc earned a badge
      One Month Later
    • One Month Later
      DJC50PLUS earned a badge
      One Month Later
    • Week One Done
      DJC50PLUS earned a badge
      Week One Done
    • Proficient
      Eric Biran went up a rank
      Proficient
  • Popular Contributors

    1. 1
      +primortal
      509
    2. 2
      PsYcHoKiLLa
      222
    3. 3
      ATLien_0
      92
    4. 4
      +Edouard
      86
    5. 5
      Steven P.
      81
  • Tell a friend

    Love Neowin? Tell a friend!