{"id":360,"date":"2011-09-16T16:37:03","date_gmt":"2011-09-16T14:37:03","guid":{"rendered":"http:\/\/joernhees.de\/blog\/?p=360"},"modified":"2016-09-28T23:27:54","modified_gmt":"2016-09-28T21:27:54","slug":"mac-os-x-harddisk-high-load-cycle-counts","status":"publish","type":"post","link":"https:\/\/joernhees.de\/blog\/2011\/09\/16\/mac-os-x-harddisk-high-load-cycle-counts\/","title":{"rendered":"Mac OS X Harddisk high Load Cycle Counts"},"content":{"rendered":"<p>Short summary: Mac OS X&#8217;s default power management settings might wear your hard drive down unnecessarily. This post provides a lot of background information and how to change these settings.<!--more--><\/p>\n<p>I recently got a new MacBook Pro and one interesting thing i noticed was light &#8220;click&#8221; (a clicking noise) from it whenever it was idle for a few seconds. I pay attention to such things since I heard about <a title=\"e.g. this bugreport\" href=\"https:\/\/bugs.launchpad.net\/ubuntu\/+source\/acpi-support\/+bug\/59695\" target=\"_blank\">problems with power management settings under Ubuntu<\/a>, which could quickly wear down a hard drive. I experienced this myself, where one of my old hard drives started to sound like a frog :-\/. So I installed smartmontools (either use <a href=\"http:\/\/www.macports.org\/\" target=\"_blank\">MacPorts<\/a>, <a href=\"http:\/\/www.finkproject.org\/\" target=\"_blank\">fink<\/a> or <a href=\"http:\/\/brew.sh\/\" target=\"_blank\">Homebrew<\/a>) and checked:<\/p>\n<pre><code class=\"bash\">smartctl -a \/dev\/disk0\nsmartctl 5.40 2010-10-16 r3189 [x86_64-apple-darwin10.7.3] (local build)\n...\n=== START OF INFORMATION SECTION ===\nDevice Model:     Hitachi HTS725050A9A362\n...\nUser Capacity:    500,107,862,016 bytes\n...\nID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE\n1 Raw_Read_Error_Rate     0x000b   100   100   062    Pre-fail  Always       -       0\n2 Throughput_Performance  0x0005   100   100   040    Pre-fail  Offline      -       0\n3 Spin_Up_Time            0x0007   164   164   033    Pre-fail  Always       -       2\n4 Start_Stop_Count        0x0012   100   100   000    Old_age   Always       -       421\n5 Reallocated_Sector_Ct   0x0033   100   100   005    Pre-fail  Always       -       0\n7 Seek_Error_Rate         0x000b   100   100   067    Pre-fail  Always       -       0\n8 Seek_Time_Performance   0x0005   100   100   040    Pre-fail  Offline      -       0\n9 Power_On_Hours          0x0012   100   100   000    Old_age   Always       -       351\n10 Spin_Retry_Count        0x0013   100   100   060    Pre-fail  Always       -       0\n12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       220\n160 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       0\n191 G-Sense_Error_Rate      0x000a   100   100   000    Old_age   Always       -       21474836480\n192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       30064771073\n193 Load_Cycle_Count        0x0012   097   097   000    Old_age   Always       -       36492\n194 Temperature_Celsius     0x0002   148   148   000    Old_age   Always       -       37 (Min\/Max 18\/42)\n195 Hardware_ECC_Recovered  0x000a   100   100   000    Old_age   Always       -       0\n196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0\n197 Current_Pending_Sector  0x0022   100   100   000    Old_age   Always       -       0\n198 Offline_Uncorrectable   0x0008   100   100   000    Old_age   Offline      -       0\n199 UDMA_CRC_Error_Count    0x000a   200   200   000    Old_age   Always       -       0\n223 Load_Retry_Count        0x000a   100   100   000    Old_age   Always       -       0\n254 Free_Fall_Sensor        0x0032   100   100   000    Old_age   Always       -       66\n...\n<\/code><\/pre>\n<p>As you can see I have a Hitachi 500GB 7200rpm drive. The puzzling fact here is the Load_Cycle_Count. You can see a value of 36,492 load cycle counts in 351 hours the HD was powered on, so approx. 100 per hour.<br \/>\nPut easily the load cycle count is how often your HD decided to park its heads. Depending on the manufacturer and HD model this can mean several things. In my case it means the number of times the HD&#8217;s heads are moved to a ramp next to the platters. The advantage of this is that being in this &#8220;parked&#8221; position the drive can shut down some energy consuming parts and it is much harder to damage the drive when the heads are parked (nothing there for a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Head_crash\">Head crash<\/a>).<br \/>\n<div id=\"attachment_396\" style=\"width: 483px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.hitachigst.com\/tech\/techlib.nsf\/techdocs\/9076679E3EE4003E86256FAB005825FB\/$file\/LoadUnload_white_paper_FINAL.pdf\"><img aria-describedby=\"caption-attachment-396\" loading=\"lazy\" src=\"https:\/\/joernhees.de\/blog\/wp-content\/uploads\/2011\/09\/RampLoadUnloadDynamics.png\" alt=\"\" title=\"RampLoadUnloadDynamics\" width=\"473\" height=\"339\" class=\"size-full wp-image-396\" srcset=\"https:\/\/joernhees.de\/blog\/wp-content\/uploads\/2011\/09\/RampLoadUnloadDynamics.png 473w, https:\/\/joernhees.de\/blog\/wp-content\/uploads\/2011\/09\/RampLoadUnloadDynamics-300x215.png 300w\" sizes=\"(max-width: 473px) 100vw, 473px\" \/><\/a><p id=\"caption-attachment-396\" class=\"wp-caption-text\">Ramp Load\/Unload Dynamics (c) Hitachi<\/p><\/div><br \/>\nThe downside of parking the heads is that HDs are usually not designed to do this every few seconds. Typical limits range from 300,000 to 600,000 (<a href=\"http:\/\/en.wikipedia.org\/wiki\/S.M.A.R.T.\" target=\"_blank\">link<\/a>) load cycle counts. (This doesn&#8217;t mean your HD will break if it does it more often, just that it&#8217;s more likely to fail if worn down like that.)<\/p>\n<p>To observe the development of your Load_Cycle_Count you can use the terminal with this small one-liner:<\/p>\n<pre><code class=\"bash\">while True ; do s=\"$(date) $(smartctl -a \/dev\/disk0 | grep 'Load_Cycle_Count')\" ; echo $s | tee -a hddLoadCounts.log ; sleep 60 ; done\nDi 17 Mai 2011 14:43:20 CEST 193 Load_Cycle_Count 0x0012 097 097 000 Old_age Always - 36492\n...\n<\/code><\/pre>\n<p>The script will log the load cycle count to your terminal and a file called <code>hddLoadCounts.log<\/code> in the current directory every minute.<\/p>\n<p>You might notice that when doing nothing but browsing this count increases by 2-8 every minute. Playing music with iTunes seems to stop this, as the HD keeps busy reading your music. Doing the maths you&#8217;ll find that it&#8217;s not unlikely that your drive will have over 300,000 load cycle counts withing the first half year (lucky music listeners, yours will last much longer \ud83d\ude42 ).<\/p>\n<p>As I had a bad feeling about this, i went on to have a look into <a href=\"http:\/\/www.hitachigst.com\/tech\/techlib.nsf\/products\/Travelstar_7k500\" target=\"_blank\">Hitachi&#8217;s technical specs for my HD<\/a>. <a href=\"http:\/\/www.hitachigst.com\/tech\/techlib.nsf\/techdocs\/3FDCAB792901CF4B862575D8005AB39B\/$file\/TS7K500_DS.pdf\" target=\"_blank\">Here<\/a> you can find that my HD is designed for up to 600,000 load cycles (page 2), meaning approx. 6000 hours at the 100 cycles per hour rate. In the <a href=\"http:\/\/www.hitachigst.com\/tech\/techlib.nsf\/techdocs\/C9CA0F26B56D6DC5862576320081F434\/$file\/TS7K500_OEM_Specification_R14.pdf\" target=\"_blank\">specs<\/a> on page 135 you can find that if Advanced Power Management is enabled, the deepest reachable power saving is depending on the Power Management level. In general the Advanced Power Management Level is between 1 (power saving) and 254 (performance). If the Level is 0 or 255 no power saving is done, if the level is 1-127 it&#8217;s &#8220;Standby&#8221;, if the level is 128-191 it&#8217;s &#8220;Low Power Idle&#8221; and if it&#8217;s 192-254 it&#8217;s &#8220;Active Idle&#8221;.<\/p>\n<p>As we&#8217;ll find out in a second, the default value (which Mac OS X sometimes seems to reset) seems to be 128, so &#8220;Low Power Idle&#8221; mode. The three power saving levels are explained in Section 12.6 &#8220;Advanced Power Management (Adaptive Battery Life Extender 3) Feature&#8221; of the specs. In short: &#8220;Active Idle&#8221; mode cuts down power consumption by 45-55%, the heads are parked near the mid-diameter of the disk, recovering takes about 20ms. In &#8220;Low Power Idle&#8221; mode power is cut down by 60-65%, the heads are unloaded to the ramp (this is the &#8220;parked&#8221; counted by Load_Cycle_Count), recovering takes 300ms. Transition into these modes is magically done internally by the HD (it observes what&#8217;s going on and decides what to do next), taking into account the Advanced Power Management Level. (&#8220;Standby&#8221; mode isn&#8217;t mentioned here, but it sure unloads the heads to the ramp, as it spins down the HD&#8230; recovery will take long, but unimportant, as we&#8217;re having a problem with &#8220;Low Power Idle&#8221; mode.)<\/p>\n<p>So how do we find out which Advanced Power Management (APM) Level our HDD uses?<br \/>\nThis doesn&#8217;t seem to be very easy in Mac OS X as there&#8217;s nothing like the <code>hdparm<\/code> on Linux.<br \/>\nThere is the hdapm tool, but it can&#8217;t read the value, you can just set it. We&#8217;ll learn why this tool is necessary in a moment, but first let&#8217;s find out what the current value is.<br \/>\nThe easiest way to accomplish this was to throw in a Linux Boot CD (Knoppix, Ubuntu, whatever you like), reboot, boot from CD (hold down the &#8220;c&#8221;-key), then fire up some terminal, become root (<code>sudo -i<\/code> and check the current APM value:<\/p>\n<pre><code class=\"bash\">hdparm -B \/dev\/sda\n<\/code><\/pre>\n<p>For me it was 128.<br \/>\nYou can check the immediate effect from within the Live CD: you can use <code>smartctl -a \/dev\/sda<\/code>. As before this kept increasing.<\/p>\n<p>As I always handle my laptop with care and can live with 10 % more power consumption of my HD, I decided to change the default. WARNING: This might not be suitable for you, it&#8217;s your decision.<\/p>\n<p>To stop this rapid growth of the load cycles, I first tried to set the value to 191, but i could still observe a rapid increase.<br \/>\nAfter setting the value to 192, it immediately stopped:<\/p>\n<pre><code class=\"bash\">hdparm -B192 \/dev\/sda\n<\/code><\/pre>\n<p>Afterwards i rebooted, the Load_Cycle_Count increased by 1 over the reboot and no more after a couple of hours runtime (without iTunes keeping my HD busy, draining my battery). To my surprise the next day my logs showed that the load cycle count was increasing rapidly again, i rebooted back into linux and found the value was reset to 128. Weird. I reset it, rebooted, the count didn&#8217;t increase anymore, but at some point i again found it increasing rapidly. Based on this I assume Mac OS X or something else (like Windows run via bootcamp) sometimes resets that value to 128. My first guess was that maybe it is reset after resuming from sleep, but I couldn&#8217;t reproduce it by this. If someone finds out let us know in the comments.<\/p>\n<p>To overcome this problem it seems sufficient to have a tool which explicitly resets the APM level once during system startup to something meaningful. That&#8217;s where we remember the <a href=\"http:\/\/mckinlay.net.nz\/hdapm\/\">hdapm<\/a> tool: You can download it from the given page and install it as described in the <a href=\"http:\/\/mckinlay.net.nz\/hdapm\/usage.html\">user guide<\/a>.<br \/>\nAfterwards edit <code>\/Library\/LaunchDaemons\/hdapm.plist<\/code> to set the correct APM value. As a reference my file looks like this:<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;!DOCTYPE plist PUBLIC \"-\/\/Apple\/\/DTD PLIST 1.0\/\/EN\" \"http:\/\/www.apple.com\/DTDs\/PropertyList-1.0.dtd\"&gt;\n&lt;plist version=\"1.0\"&gt;\n&lt;dict&gt;\n        &lt;key&gt;Label&lt;\/key&gt;\n        &lt;string&gt;hdapm&lt;\/string&gt;\n        &lt;key&gt;Disabled&lt;\/key&gt;\n        &lt;false\/&gt;\n        &lt;key&gt;ProgramArguments&lt;\/key&gt;\n        &lt;array&gt;\n                &lt;string&gt;\/usr\/local\/bin\/hdapm&lt;\/string&gt;\n                &lt;string&gt;disk0&lt;\/string&gt;\n                &lt;string&gt;192&lt;\/string&gt;\n        &lt;\/array&gt;\n        &lt;key&gt;ServiceDescription&lt;\/key&gt;\n        &lt;string&gt;Set ATA Advanced Power Management level&lt;\/string&gt;\n        &lt;key&gt;RunAtLoad&lt;\/key&gt;\n        &lt;true\/&gt;\n        &lt;key&gt;LaunchOnlyOnce&lt;\/key&gt;\n        &lt;true\/&gt;\n&lt;\/dict&gt;\n&lt;\/plist&gt;\n<\/code><\/pre>\n<p>Notice that for other drives, especially other manufacturers the 192 might not be the right value. If you found the correct values for other drives, be welcome to share them (preferably with links to tech specs) in the comments.<\/p>\n<p>Now, after four months since discovering the problem went by, my load cycle count only increased by about 500 (which is about the number of times i sent the mac to standby). Isn&#8217;t that a figure compared to the 36500 within the first month? \ud83d\ude42<\/p>\n<p>Edit (Sep. 22, 2011): Revised my guess about sleep causing the reset. Thx to Sam.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mac OS X&#8217;s default power management settings might wear your hard drive down unnecessarily. This post provides a lot of background information and how to change these settings.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[1],"tags":[4,10,23,59,60,61,62,63,68,92,94,95,96,104,149,152,189],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pYA5n-5O","jetpack-related-posts":[{"id":526,"url":"https:\/\/joernhees.de\/blog\/2013\/06\/08\/mac-os-x-10-8-scientific-python-with-homebrew\/","url_meta":{"origin":360,"position":0},"title":"Scientific Python on Mac OS X 10.8 with homebrew","date":"2013-06-08","format":false,"excerpt":"(newer version of this guide) A step-by-step installation guide to setup a scientific python environment based on Mac OS X and homebrew. Needless to say: Make a backup (Timemachine) First install homebrew. Follow their instructions, then come back here. If you don't have a clean install, some of the following\u2026","rel":"","context":"In &quot;Coding&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":566,"url":"https:\/\/joernhees.de\/blog\/2014\/02\/25\/scientific-python-on-mac-os-x-10-9-with-homebrew\/","url_meta":{"origin":360,"position":1},"title":"Scientific Python on Mac OS X 10.9+ with homebrew","date":"2014-02-25","format":false,"excerpt":"Scientific python setup guide for Mac OS X 10.9 Mavericks with homebrew","rel":"","context":"In &quot;Coding&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":731,"url":"https:\/\/joernhees.de\/blog\/2015\/11\/23\/setting-up-a-linked-data-mirror-from-rdf-dumps-dbpedia-2015-04-freebase-wikidata-linkedgeodata-with-virtuoso-7-2-1-and-docker-optional\/","url_meta":{"origin":360,"position":2},"title":"Setting up a Linked Data mirror from RDF dumps (DBpedia 2015-04, Freebase, Wikidata, LinkedGeoData, ...) with Virtuoso 7.2.1 and Docker (optional)","date":"2015-11-23","format":false,"excerpt":"So you're the guy who is allowed to setup a local DBpedia mirror or more generally a local Linked Data mirror for your work group? OK, today is your lucky day and you're in the right place. I hope you'll be able to benefit from my many hours of trials\u2026","rel":"","context":"In &quot;Coding&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":610,"url":"https:\/\/joernhees.de\/blog\/2014\/11\/10\/setting-up-a-local-dbpedia-2014-mirror-with-virtuoso-7-1-0\/","url_meta":{"origin":360,"position":3},"title":"Setting up a local DBpedia 2014 mirror with Virtuoso 7.1.0","date":"2014-11-10","format":false,"excerpt":"Newer version available: Setting up a Linked Data mirror from RDF dumps (DBpedia 2015-04, Freebase, Wikidata, LinkedGeoData, ...) with Virtuso 7.2.1 and Docker (optional) So you're the guy who is allowed to setup a local DBpedia mirror or more generally a local Linked Data mirror for your work group? OK,\u2026","rel":"","context":"In &quot;Coding&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":584,"url":"https:\/\/joernhees.de\/blog\/2014\/04\/23\/setting-up-a-local-dbpedia-3-9-mirror-with-virtuoso-7\/","url_meta":{"origin":360,"position":4},"title":"Setting up a local DBpedia 3.9 mirror with Virtuoso 7","date":"2014-04-23","format":false,"excerpt":"Newer version available: Setting up a Linked Data mirror from RDF dumps (DBpedia 2015-04, Freebase, Wikidata, LinkedGeoData, ...) with Virtuso 7.2.1 and Docker (optional) I just found this aged post in my drafts folder, maybe someone will still like it... So you're the guy who is allowed to setup a\u2026","rel":"","context":"In &quot;Coding&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/posts\/360"}],"collection":[{"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/comments?post=360"}],"version-history":[{"count":3,"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/posts\/360\/revisions"}],"predecessor-version":[{"id":794,"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/posts\/360\/revisions\/794"}],"wp:attachment":[{"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/media?parent=360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/categories?post=360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/tags?post=360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}