<?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/"
	>

<channel>
	<title>Iulian Dogariu &#187; linux</title>
	<atom:link href="http://www.iuliandogariu.com/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.iuliandogariu.com</link>
	<description>Who Spilled the Java Beans?</description>
	<lastBuildDate>Tue, 23 Feb 2010 11:45:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Finding free disk space in Ruby</title>
		<link>http://www.iuliandogariu.com/2008/12/finding-free-disk-space-in-ruby/</link>
		<comments>http://www.iuliandogariu.com/2008/12/finding-free-disk-space-in-ruby/#comments</comments>
		<pubDate>Tue, 16 Dec 2008 11:28:33 +0000</pubDate>
		<dc:creator>Iulian Dogariu</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.jayomega.net/blog/?p=177</guid>
		<description><![CDATA[UPDATED I can&#8217;t find a standard Ruby idiom for finding out the free/occupied disk space on a partition, so here&#8217;s a hack for doing it under Linux:
123456789def disk_used_space&#40; path &#41;
&#160; `df -Pk #{path} &#124;grep ^/ &#124; awk '{print $3;}'`.
&#160; &#160; to_i * 1.kilobyte
end

def disk_free_space&#40; path &#41;
&#160; `df -Pk #{path} &#124;grep ^/ &#124; awk '{print $4;}'`.
&#160; [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATED</strong> I can&#8217;t find a standard Ruby idiom for finding out the free/occupied disk space on a partition, so here&#8217;s a hack for doing it under Linux:</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">def</span> disk_used_space<span style="color:#006600; font-weight:bold;">&#40;</span> path <span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; <span style="color:#996600;">`df -Pk #{path} |grep ^/ | awk '{print $3;}'`</span>.<br />
&nbsp; &nbsp; <span style="color:#9900CC;">to_i</span> <span style="color:#006600; font-weight:bold;">*</span> 1.<span style="color:#9900CC;">kilobyte</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#9966CC; font-weight:bold;">def</span> disk_free_space<span style="color:#006600; font-weight:bold;">&#40;</span> path <span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; <span style="color:#996600;">`df -Pk #{path} |grep ^/ | awk '{print $4;}'`</span>.<br />
&nbsp; &nbsp; <span style="color:#9900CC;">to_i</span> <span style="color:#006600; font-weight:bold;">*</span> 1.<span style="color:#9900CC;">kilobyte</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<p>The <tt>-P</tt> (POSIX compliant output) argument to <tt>df</tt> is important, it forces the output to be more regular, thus easier to parse. Without -P, you&#8217;ll run into trouble if the names of the disk devices are particularly long, e.g. if the machine uses LVM:</p>
<pre>
mymachine:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/md0               9614052   2819896   6305788  31% /
/dev/mapper/storage-s1
                     331624912    395808 314383488   1% /mnt/s1
/dev/mapper/storage-s2
                     109681544    192248 103917712   1% /mnt/s2
</pre>
<p>The <tt>1.kilobyte</tt> idiom is available only if you use ActiveSupport, e.g. in a Rails application. If you can&#8217;t use ActiveSupport, just write 1024 instead.</p>
<p>Update: the <tt>-P</tt> option is not enough, you should also use <tt>-k</tt> to get the output in 1 KB blocks. Thanks to commenter Martin Rehfeld for the tip.</p>
<p>Hope you find this useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iuliandogariu.com/2008/12/finding-free-disk-space-in-ruby/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Romanian Police evangelising Linux to students</title>
		<link>http://www.iuliandogariu.com/2006/06/romanian-police-evangelising-linux-to-students/</link>
		<comments>http://www.iuliandogariu.com/2006/06/romanian-police-evangelising-linux-to-students/#comments</comments>
		<pubDate>Fri, 09 Jun 2006 17:18:02 +0000</pubDate>
		<dc:creator>Iulian Dogariu</dc:creator>
				<category><![CDATA[IT politics]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.jayomega.net/blog/?p=48</guid>
		<description><![CDATA[A newsletter from the Iaşi police reports that community officers have been visiting secondary schools in Iaşi to warn students of the perils of using unlicened software and illegally copied media. The police officers  introduced the 7th-graders to the Linux operating system and the thousands of free applications that accompany it.
Hats off! This is [...]]]></description>
			<content:encoded><![CDATA[<p>A newsletter from the <a href="http://en.wikipedia.org/wiki/Iaşi">Iaşi</a> police reports that community officers have been visiting secondary schools in Iaşi to warn students of the perils of using unlicened software and illegally copied media. <em>The police officers  introduced the 7th-graders to the Linux operating system and the thousands of free applications that accompany it.</em></p>
<p>Hats off! This is really the first time I hear about officials actually mentioning the Open-Source alternative, in the context of unlicensed commercial software.</p>
<p>For my unaware readers&#8230; This happens in a country whose Government itself signs <a href="http://www.mcti.ro/index.php?KTURL=page&#038;page=1627">&#8220;strategic partnerships&#8221;</a> with Microsoft and spends many millions of taxpayer €&#8217;s on MS licences in the educational system,  in spite of the tight budgets, underpaid staff, lack of teachers in rural areas, and the otherwise deplorable state of Romanian schooling.</p>
<p>The text of the news item, in Romanian, is mirrored <a href="http://wiki.lug.ro/mediawiki/index.php/Advocacy#Politia_Iasi">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iuliandogariu.com/2006/06/romanian-police-evangelising-linux-to-students/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Resizing partitions: The forgotten resize2fs</title>
		<link>http://www.iuliandogariu.com/2006/05/resizing-partitions-the-forgotten-resize2fs/</link>
		<comments>http://www.iuliandogariu.com/2006/05/resizing-partitions-the-forgotten-resize2fs/#comments</comments>
		<pubDate>Mon, 08 May 2006 14:21:09 +0000</pubDate>
		<dc:creator>Iulian Dogariu</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.jayomega.net/blog/?p=40</guid>
		<description><![CDATA[So you want to resize one of your partitions. If you&#8217;re using ext2/ext3, and the FS is larger than usual (mine was 170 GB), parted (otherwise a pretty neat tool) may fail on you with this message:
1No Implementation: This ext2 file system has a rather strange layout! &#160;Parted can't resize this (yet)
This happens with parted [...]]]></description>
			<content:encoded><![CDATA[<p>So you want to resize one of your partitions. If you&#8217;re using ext2/ext3, and the FS is larger than usual (mine was 170 GB), <a href="http://www.gnu.org/software/parted/">parted</a> (otherwise a pretty neat tool) may fail on you with this message:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">No Implementation: This ext2 file system has a rather strange layout! &nbsp;Parted can't resize this (yet)</div></td></tr></tbody></table></div>
<p>This happens with parted 1.6.25.1 (the current stable version). The <a href="http://www.gnu.org/software/parted/faq.html">parted FAQ</a> says that new code has been added in 1.7 to address this; however 1.7.0rc5 fails with a creepy error message, and an apology for me having run into a bug <img src='http://www.iuliandogariu.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Not more than a Google search away, I found the venerable <a href="http://linuxcommand.org/man_pages/resize2fs8.html">resize2fs</a>, which did the job perfectly.</p>
<p>When using resize2fs however, there is some additional work that you have to do. More specifically, resize2fs will resize the filesystem itself, <em>not</em> the underlying partitions. You must use fdisk (or equivalents) to enlarge the partition before growing the fs, or to cut the partition after shrinking the fs.</p>
<p>You should also NOT run resize2fs (or any other fs manipulation tool, for that matter) except on a CLEAN and consistent filesystem. Run e2fsck before and after resizing.</p>
<p>And finally, you may want to make sure that what you&#8217;re resizing is an ext2 filesystem, and not the newer ext3. As a reminder, to convert from ext3 to ext2, use</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;# tune2fs -O^has_journal /dev/sdaX</div></td></tr></tbody></table></div>
<p>And, after you&#8217;ve grown/shrunk your partition, you can go back to ext3 with:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;# tune2fs -j /dev/sdaX</div></td></tr></tbody></table></div>
<p>Don&#8217;t forget to update your fstab.</p>
<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iuliandogariu.com/2006/05/resizing-partitions-the-forgotten-resize2fs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
