<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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/"
	>

<channel>
	<title>thegioraproject.com &#187; linux</title>
	<link>http://thegioraproject.com</link>
	<description></description>
	<pubDate>Mon, 02 Jun 2008 04:20:20 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>Workaround for subdirectory limit on ext3 filesystem</title>
		<link>http://thegioraproject.com/2008/03/02/workaround-for-subdirectory-limit-on-ext3-filesystem/</link>
		<comments>http://thegioraproject.com/2008/03/02/workaround-for-subdirectory-limit-on-ext3-filesystem/#comments</comments>
		<pubDate>Sun, 02 Mar 2008 16:33:59 +0000</pubDate>
		<dc:creator>Kevin Burke</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://thegioraproject.com/2008/03/02/workaround-for-subdirectory-limit-on-ext3-filesystem/</guid>
		<description><![CDATA[Just keep in mind that this is a temporary workaround for a problem that should be addressed in a more robust fashion. So on the ext3 filesystem there is a subdirectory limit of 32,000. The problem is that when you reach this limit and you try to add another subdirectory you get a programmer type [...]]]></description>
			<content:encoded><![CDATA[<p>Just keep in mind that this is a temporary workaround for a problem that should be addressed in a more robust fashion. So on the ext3 filesystem there is a subdirectory limit of 32,000. The problem is that when you reach this limit and you try to add another subdirectory you get a programmer type error: &#8220;Too many links&#8221;. If you aren&#8217;t at the command line and calling mkdir directly this can be very cryptic bubbling up in your programs stack trace. What it means is that there are too many hard links(directories or files) in the directory.</p>
<p>It is a real show stopper, especially if it is the directory to which upload all over your website&#8217;s user generated content. Here is a quick workaround until you can solve the problem more gracefully. The limit is for hard links and not soft links (symbolic links). So, what you want to do is:</p>
<ol>
<li>Create an overflow directory.</li>
<li>Move all of your current subdirectories from the current directory to the overflow directory.</li>
<li>Create a symlink for each subdirectory in the current directory pointing the directory in the overflow directory.</li>
</ol>
<p>Of course you won&#8217;t want to do this by hand, so you might want to whip up a script to do this. Mine was only a few lines of ruby (also note that it was made easier by the fact that the directories were sequential numbers):</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp; &nbsp; require &#8216;fileutils&#8217;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;old_dir = &quot;/village/data_file/content&quot;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;new_dir = &quot;/village/data_file/overflow&quot;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp;(0..41671).each do |index|
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;dir = File.join(old_dir, index.to_s)
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;if File.exist?(dir)
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;FileUtils.mv(dir, new_dir)
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;FileUtils.ln_sf(File.join(new_dir, index.to_s), dir)
</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp;end
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;end</div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://thegioraproject.com/2008/03/02/workaround-for-subdirectory-limit-on-ext3-filesystem/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Piping grep to rm</title>
		<link>http://thegioraproject.com/2008/02/28/piping-grep-to-rm/</link>
		<comments>http://thegioraproject.com/2008/02/28/piping-grep-to-rm/#comments</comments>
		<pubDate>Thu, 28 Feb 2008 19:24:12 +0000</pubDate>
		<dc:creator>Kevin Burke</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://thegioraproject.com/2008/02/28/piping-grep-to-rm/</guid>
		<description><![CDATA[I discovered a neat trick to deleting folders/files based on a pattern. Let&#8217;s say you have a directory structure like this:
/test
/test/aaaa
/test/bbbb
/test/cccc
/test/ddd
/test/eee
/test/fff
You&#8217;ve decided that any folder with a&#8217;s, b&#8217;s, or c&#8217;s has to go. You definitely don&#8217;t want to delete them all by hand; especially if there are a couple thousand of them. The first thing [...]]]></description>
			<content:encoded><![CDATA[<p>I discovered a neat trick to deleting folders/files based on a pattern. Let&#8217;s say you have a directory structure like this:</p>
<p>/test<br />
/test/aaaa<br />
/test/bbbb<br />
/test/cccc<br />
/test/ddd<br />
/test/eee<br />
/test/fff</p>
<p>You&#8217;ve decided that any folder with a&#8217;s, b&#8217;s, or c&#8217;s has to go. You definitely don&#8217;t want to delete them all by hand; especially if there are a couple thousand of them. The first thing you need to do is find the directories that you want to remove:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">ls | grep &quot;[a-c]&quot;</div>
</li>
</ol>
</div>
<p>Which produces the following:<br />
aaaa<br />
bbbb<br />
cccc</p>
<p>Great! Now what? All you need to do is pipe that to rm using xargs:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">ls | grep &quot;[a-c]&quot; | xargs rm -rf</div>
</li>
</ol>
</div>
<p>All files that match the given pattern will be deleted. <strong>But, be careful that the pattern only matches the files you would like to delete</strong>. Run ls | grep first before you pipe anything to rm, unless you like trying to restore deleted files.</p>
<p class="zoundry_raven_tags">  <!-- Tag links generated by Zoundry Raven. Do not manually edit. http://www.zoundryraven.com -->  <span class="ztags"><span class="ztagspace">Technorati</span> : <a href="http://technorati.com/tag/linux" class="ztag" rel="tag">linux</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://thegioraproject.com/2008/02/28/piping-grep-to-rm/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
