<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>GigaOM &#187; hsfdebug</title>
	<atom:link href="http://gigaom.com/tag/hsfdebug/feed/" rel="self" type="application/rss+xml" />
	<link>http://gigaom.com</link>
	<description></description>
	<lastBuildDate>Tue, 18 Jun 2013 05:04:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='gigaom.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/0db8f6557d022075dbbf010c54d46d93?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>GigaOM &#187; hsfdebug</title>
		<link>http://gigaom.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://gigaom.com/osd.xml" title="GigaOM" />
	<atom:link rel='hub' href='http://gigaom.com/?pushpress=hub'/>
		<item>
		<title>Disk Fragmentation &amp; OS X: When Does it Become a Problem?</title>
		<link>http://gigaom.com/2009/04/14/disk-fragmentation-os-x-when-does-it-become-a-problem/</link>
		<comments>http://gigaom.com/2009/04/14/disk-fragmentation-os-x-when-does-it-become-a-problem/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 13:49:10 +0000</pubDate>
		<dc:creator>Andrew Bednarz</dc:creator>
				<category><![CDATA[CNN Big Tech]]></category>
		<category><![CDATA[NYT Enterprise]]></category>
		<category><![CDATA[SYN Feature Enterprise]]></category>
		<category><![CDATA[defrag]]></category>
		<category><![CDATA[drive genius]]></category>
		<category><![CDATA[fragmentation]]></category>
		<category><![CDATA[hsfdebug]]></category>
		<category><![CDATA[idefrag]]></category>
		<category><![CDATA[TechTool Pro]]></category>

		<guid isPermaLink="false">http://theappleblog.com/?p=21480</guid>
		<description><![CDATA[Disk fragmentation is an old problem that has affected every operating system throughout history. File fragmentation occurs when a single file isn&#8217;t located in the same physical location on the disk, but is scattered around. OS X does a great job at minimizing file fragmentation by [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gigaom.com&#038;blog=14960843&#038;post=172608&#038;subd=gigaom2&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><img  title="idefrag_icon" src="http://gigapple.files.wordpress.com/2009/04/idefrag_icon.png?w=128&#038;h=128" alt="idefrag_icon" width="128" height="128" class=" alignleft" />Disk fragmentation is an old problem that has affected every operating system throughout history. File fragmentation occurs when a single file isn&#8217;t located in the same physical location on the disk, but is scattered around. OS X does a great job at minimizing file fragmentation by rewriting files in contiguous space when a file is opened, is under 20MB and contains more than eight fragments. This works quite well to prevent heavy <em>file</em> fragmentation, but what it doesn&#8217;t prevent is <em>free space</em> fragmentation.</p>
<h3>Free space fragmentation?</h3>
<p>Free space fragmentation can become a problem when you start running low on disk space. If you have a small percentage of your disk free &#8212; and you frequently use and then free-up disk space with temporary files &#8212; you&#8217;re likely to have high free space fragmentation. This means the free space is spread all over your hard drive in small amounts here and there &#8212; its not all laid out in one contiguous section in one spot. <span id="more-172608"></span></p>
<p>So what&#8217;s the problem with this? Ultimately, this impacts OS X&#8217;s ability to keep file fragmentation under control as it can not rewrite large growing files into contiguous empty space, as there is none. Any new large files that are written also get fragmented by the same issue. Just as importantly, when space is fragmented, caching files for the system and for applications also get spread around all over the place. OS X utilizes file caching heavily. The problem is that when the file cache is spread all over the hard disk, it takes a time penalty to access (and also to write) these files. Being able to write and access caches from the same physical area gives a very noticeable speed increase &#8212; rebuilding caches after de-fragmenting can thus be advantageous.</p>
<h3>How do I tell if my free space is fragmented?</h3>
<p>If you suspect you might be suffering from free space fragmentation, there is a free tool you can use to verify your suspicion. Download <a href="http://www.osxbook.com/software/hfsdebug/">hsfdebug</a> (the download link is at the end of the page) and copy the file <em>hsfdebug</em> to any directory (such as your home directory, ~/). Open a terminal window, navigate to the directory you copied the file to, and run the following command:</p>
<p><code>sudo ./hfsdebug -0 | sort -n</code></p>
<p>This will list all the blocks of free space available, in order from smallest to largest. For example the last 10 lines of output when I ran this was:<br />
<code><br />
10391       0x134e488       0x1350d1e    40.59 MB<br />
10993       0x11004e7       0x1102fd7    42.94 MB<br />
11691       0x152cd74       0x152fb1e    45.67 MB<br />
12229       0x26d1a05       0x26d49c9    47.77 MB<br />
14537       0x2693cdc       0x26975a4    56.79 MB<br />
24090       0x129b388       0x12a11a1    94.10 MB<br />
57704       0x12a9b0c       0x12b7c73   225.41 MB<br />
68490       0x133c5dc       0x134d165   267.54 MB<br />
69680       0x12c82f7       0x12d9326   272.19 MB<br />
237568          0x1d02         0x3bd01   928.00 MB<br />
</code></p>
<p>This tells me that the largest amount of free space I have in one contiguous block is 928 MB. The next biggest is 272.19 MB and its all downhill from there (there were 60,000 lines in total, with 43,000 of them under 100 KB). Since I have a total of 22 GB free disk space, most of that is clearly spread out in tiny blocks. That&#8217;s pretty fragmented, which doesn&#8217;t surprise me as I deal with a lot of temporary files that are constantly being written and then deleted over a few days.</p>
<p>Of interest, hfsdebug can also tell you the amount of file fragmentation for the curious:<br />
<code>sudo ./hfsdebug -f -t 5</code></p>
<p>This will take a little while to process, but will tell you the percentage of files that are NOT fragmented:</p>
<p><code>Out of 1214506 non-zero data forks total, 1209938 (99.624 %) have no fragmentation.<br />
Out of 4135 non-zero resource forks total, 4074 (98.525 %) have no fragmentation.<br />
</code></p>
<p>So OS X has been doing a good job at keeping <em>file</em> fragmentation low, as expected.</p>
<h3>Why else would I need to defrag?</h3>
<p>Another reason to defragment free disk space is to make it possible to create a Boot Camp partition. While OS X can smoothly resize the existing partition and create the new one for Windows, it requires contiguous free space. If this doesn&#8217;t exist, you will be told &#8220;Can not create partition, please re-install OSX and try again.&#8221; This is because Apple does not provide a method to explicitly defrag your hard drive. For the cases it can help (such as creating the Boot Camp partition), Apple recommends just doing a full backup and restore; formatting the hard drive, re-installing the OS and restoring your files. This does indeed do the trick, as it forces every single byte to be rewritten to the disk &#8212; however there are a number of third party applications that will do the trick with much less effort.</p>
<h3>Defrag Tools</h3>
<p>The following applications will provide comprehensive disk defragmenting. I think its important to note that to maximize the benefit of caching performance, a tool such as <a href="http://www.titanium.free.fr/pgs2/english/onyx_leopard.html">Onyx</a> should also be used first to clear your System and User caches before you do your defragging. This results in the caches being rebuilt in contiguous space afterwards.</p>
<p><strong><a href="http://www.coriolis-systems.com/">iDefrag</a></strong> &#8212; iDefrag is all about defragging and provides a number of methods to do so. For example we could just use the &#8216;Compact&#8217; algorithm which will put all files at the start of the disk, making our free disk space all at the end with the minimum time spent. iDefrag is £19.95 ($30).</p>
<p><strong><a href="http://www.prosofteng.com/products/drive_genius.php">Drive Genius</a></strong> &#8212; Drive Genius is a full disk maintenance utility, allowing partitioning and recovery as well as defragmenting. It is claimed that Apple Geniuses at the Genius Bars use this when dealing with problematic hardware. Drive Genius costs $99.</p>
<p><strong><a href="http://www.micromat.com/index.php?option=com_content&amp;task=view&amp;id=202&amp;Itemid=107">TechTool Pro 5</a></strong> &#8212; TechTool Pro 5 claims to be a complete Mac problem-solving system, that includes disk defragmenting. A cut-down version (TechTool Deluxe) is included with Apple&#8217;s Apple Care product, but this does not contain the defragmenting functionality. The Pro version costs $98.</p>
<h3>Results?</h3>
<p>After a full defrag with iDefrag, re-running hfsdebug gave me an output of only 123 lines, with the following being the last 10:<br />
<code><br />
370        0x1883fd        0x18856e     1.45 MB<br />
377       0x232da2e       0x232dba6     1.47 MB<br />
445       0x232efb1       0x232f16d     1.74 MB<br />
479        0x1670b2        0x167290     1.87 MB<br />
768          0x1d02          0x2001     3.00 MB<br />
8343       0x232abfa       0x232cc90    32.59 MB<br />
63659         0x78756         0x88000   248.67 MB<br />
184298         0x3a202         0x671eb   719.91 MB<br />
1183949        0x881437        0x9a2503     4.52 GB<br />
5014722       0x232fb3d       0x27f7ffe    19.13 GB<br />
</code></p>
<p>So the bulk of my free space is now nicely contiguous and large. My caches are rebuilt and my system is noticeably snappier and more responsive. Milage may vary, depending on exactly how the fragmentation is affecting you to begin with, but free space defragmentation can definitely improve performance in some cases. Importantly, be sure to always have a backup on hand, as any power glitch during any long disk operation may cause damage your file system.</p>
<br />  <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gigaom.com&#038;blog=14960843&#038;post=172608&#038;subd=gigaom2&#038;ref=&#038;feed=1" width="1" height="1" /><p><a href="http://pubads.g.doubleclick.net/gampad/jump?iu=/1008864/GigaOM_RSS_300x250&#038;sz=300x250&#038;c=139676"><img src="http://pubads.g.doubleclick.net/gampad/ad?iu=/1008864/GigaOM_RSS_300x250&#038;sz=300x250&#038;c=139676" /></a></p><p><strong>Related research and analysis from GigaOM Pro:</strong><br />Subscriber content. <a href="http://pro.gigaom.com/?utm_source=apple&utm_medium=editorial&utm_campaign=auto3&utm_term=172608+disk-fragmentation-os-x-when-does-it-become-a-problem&utm_content=bed42">Sign up for a free trial</a>.</p><ul><li><a href="http://pro.gigaom.com/2012/04/is-android-broken-and-if-so-will-google-fix-it/?utm_source=apple&utm_medium=editorial&utm_campaign=auto3&utm_term=172608+disk-fragmentation-os-x-when-does-it-become-a-problem&utm_content=bed42">Is Android broken and if so, will Google fix it?</a></li><li><a href="http://pro.gigaom.com/2012/02/how-do-developers-ride-the-siri-wave/?utm_source=apple&utm_medium=editorial&utm_campaign=auto3&utm_term=172608+disk-fragmentation-os-x-when-does-it-become-a-problem&utm_content=bed42">How do developers ride the Siri wave?</a></li><li><a href="http://pro.gigaom.com/2012/02/ces-2012-a-recap-and-analysis/?utm_source=apple&utm_medium=editorial&utm_campaign=auto3&utm_term=172608+disk-fragmentation-os-x-when-does-it-become-a-problem&utm_content=bed42">CES 2012: a recap and analysis</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://gigaom.com/2009/04/14/disk-fragmentation-os-x-when-does-it-become-a-problem/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/205e8de04de9d77f950d5e6d2eec961b?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">bed</media:title>
		</media:content>

		<media:content url="http://gigapple.files.wordpress.com/2009/04/idefrag_icon.png" medium="image">
			<media:title type="html">idefrag_icon</media:title>
		</media:content>
	</item>
	</channel>
</rss>
