<?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>CINAQ ~xiwen &#187; Linux</title>
	<atom:link href="http://www.cinaq.com/wordpress/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cinaq.com/wordpress</link>
	<description>Whistles and bells</description>
	<lastBuildDate>Mon, 12 Dec 2011 22:51:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>setup an encrypted directory on the sdcard in Android</title>
		<link>http://www.cinaq.com/wordpress/2011/10/setup-an-encrypted-directory-on-the-sdcard-in-android/</link>
		<comments>http://www.cinaq.com/wordpress/2011/10/setup-an-encrypted-directory-on-the-sdcard-in-android/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 09:41:16 +0000</pubDate>
		<dc:creator>xiwen</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[cryptsetup]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[htc hd2]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[sdcard]]></category>

		<guid isPermaLink="false">http://www.cinaq.com/wordpress/?p=88</guid>
		<description><![CDATA[Introduction Recently I acquired an HTC HD2 smartphone. It is running Android from NAND. To be specific, the HD2_NDT_MIUI_GINGER_STABLE_V2.2_MAGLDR rom found at XDA. It is known Android isn&#8217;t quite secure in terms of physical access. It is inevitable to loose ones mobile device. When that happens we should rest assured the information on that device [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<h4>Introduction</h4>
<p>Recently I acquired an HTC HD2 smartphone. It is running Android from NAND. To be specific, the HD2_NDT_MIUI_GINGER_STABLE_V2.2_MAGLDR rom found at XDA. It is known Android isn&#8217;t quite secure in terms of physical access. It is inevitable to loose ones mobile device. When that happens we should rest assured the information on that device is not accessible by others.</p>
<p><span id="more-88"></span></p>
<h4>Approach</h4>
<p>There are several ways to solve this problem. But I opted to use cryptsetup because 1) I&#8217;m familiar with it 2) transparency: an encrypted container accessible by normal apps 3) portability: the raw container can be opened on other Linux systems.</p>
<p>The first problem is <b>cryptsetup</b> is absent on a standard Android system. Thanks to <a href="http://androidvoid.wordpress.com/2009/09/30/android-encryption-using-cryptsetup-and-luks/">this post</a> I could get a hold of a binary(ideally one should compile their own). <b>cryptsetup</b> must be pushed to the Rooted device with e.g. <i>adb push</i><br />
I put mine in <i>/sd-ext/bin</i> which is an <b>ext2</b> partition the sdcard together with <b>crypt.sh</b> (found lower in this post, <a href="http://forum.xda-developers.com/showpost.php?p=14897706&#038;postcount=10">inspired by this</a>). The script by default creates a ~1.8GB container on the sdcard called <b>crypt.raw</b> and the mount point at <b>/sdcard/crypt</b>. </p>
<h4>Usage</h4>
<p>First the container must be initialized. This can be done within <b>adb shell</b>:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sh /sd-ext/bin/crypt.sh setup</div></div>
<p>It will take a while depending on the container size.</p>
<p>After it&#8217;s done you can mount the container:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sh /sd-ext/bin/crypt.sh mount</div></div>
<p>and unmount:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sh /sd-ext/bin/crypt.sh umount</div></div>
<p>What if we&#8217;re away from a computer without access to <b>adb</b>? Simply use <b>connectbot</b> to open a local connection then escalate privileges using</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">su</div></div>
<p>From here on, we can unlock the container whenever we please and it is compatible with all other apps. </p>
<h4>Conclusions</h4>
<p>The approach described above uses cryptsetup, a widely deployed solution in the Linux world. It enables the user to store data securely and transparently. The container size limit (2GB) can be overcome by using ext2/3/4 instead of the default vfat on the &#8220;host&#8221; filesystem. Or use a dedicated partition for it.</p>
<p>While this article doesn&#8217;t dive deep into realizing a water tight system it illustrates one can take measures themselves to increase security. A pit fall of this solution is that one can forget to lock the container. A device without pattern or pin lock (I don&#8217;t trust it myself. Hell, at least it is something) cannot protect your data. It is also wise to turn off debugging mode otherwise an attacker can just hook up your phone on USB and then fire up <b>adb</b> which grants them root access to an unlocked container. <i>Maybe I should write an article on securing Android</i></p>
<p>Several improvements can be made in the future:<br />
- a GUI frontend to crypt.sh<br />
- tight integration with the system: encrypt complete /sdcard and /data for instance<br />
- use pin/pattern to unlock container</p>
<h4>script: crypt.sh</h4>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/system/bin/sh</span><br />
<br />
<span style="color: #666666; font-style: italic;"># in kilobytes; vfat limits to 2G</span><br />
<span style="color: #007800;">SIZE</span>=<span style="color: #000000;">1900000</span><br />
<span style="color: #007800;">VOLNAME</span>=crypt<br />
<span style="color: #007800;">CRYPTSETUP</span>=<span style="color: #000000; font-weight: bold;">/</span>sd-ext<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>cryptsetup<br />
<br />
SETUP<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">dd</span> <span style="color: #007800;">if</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>zero <span style="color: #007800;">of</span>=<span style="color: #000000; font-weight: bold;">/</span>sdcard<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${VOLNAME}</span>.raw <span style="color: #007800;">bs</span>=<span style="color: #000000;">1024</span> <span style="color: #007800;">count</span>=<span style="color: #800000;">${SIZE}</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mknod</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>loop21 b <span style="color: #000000;">7</span> <span style="color: #000000;">21</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; losetup <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>loop21 <span style="color: #000000; font-weight: bold;">/</span>sdcard<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${VOLNAME}</span>.raw<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #800000;">${CRYPTSETUP}</span> <span style="color: #660033;">--cipher</span> aes-cbc-essiv:md5 <span style="color: #660033;">--key-size</span> <span style="color: #000000;">256</span> luksFormat <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>loop21<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #800000;">${CRYPTSETUP}</span> luksOpen <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>loop21 <span style="color: #800000;">${VOLNAME}</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; mkfs.ext2 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${VOLNAME}</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #800000;">${CRYPTSETUP}</span> luksClose <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${VOLNAME}</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; losetup <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>loop21<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>sdcard<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${VOLNAME}</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
MOUNT<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mknod</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>loop21 b <span style="color: #000000;">7</span> <span style="color: #000000;">21</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; losetup <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>loop21 <span style="color: #000000; font-weight: bold;">/</span>sdcard<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${VOLNAME}</span>.raw<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #800000;">${CRYPTSETUP}</span> luksOpen <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>loop21 <span style="color: #800000;">${VOLNAME}</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${VOLNAME}</span> <span style="color: #000000; font-weight: bold;">/</span>sdcard<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${VOLNAME}</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
UMOUNT<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">umount</span> <span style="color: #000000; font-weight: bold;">/</span>sdcard<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${VOLNAME}</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #800000;">${CRYPTSETUP}</span> luksClose <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${VOLNAME}</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; losetup <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>loop21<br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #007800;">$1</span> <span style="color: #000000; font-weight: bold;">in</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; setup<span style="color: #7a0874; font-weight: bold;">&#41;</span> SETUP <span style="color: #000000; font-weight: bold;">;;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">umount</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> UMOUNT <span style="color: #000000; font-weight: bold;">;;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> MOUNT <span style="color: #000000; font-weight: bold;">;;</span><br />
<span style="color: #000000; font-weight: bold;">esac</span></div></div>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.cinaq.com/wordpress/2011/10/setup-an-encrypted-directory-on-the-sdcard-in-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>weather: simple command line weather script</title>
		<link>http://www.cinaq.com/wordpress/2011/01/weather-simple-command-line-weather-script/</link>
		<comments>http://www.cinaq.com/wordpress/2011/01/weather-simple-command-line-weather-script/#comments</comments>
		<pubDate>Sun, 23 Jan 2011 13:55:54 +0000</pubDate>
		<dc:creator>xiwen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[weather]]></category>

		<guid isPermaLink="false">http://www.cinaq.com/wordpress/?p=80</guid>
		<description><![CDATA[In my quest to make my systems more useful I created a command line weather script. There are similar programs made already like weathercli, weather-util. But the first didn&#8217;t work at all. The second only supports USA states/cities. Not quite useful in my situation where I want weather conditions of The Hague in The Netherlands. [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>In my quest to make my systems more useful I created a command line weather script. There are similar programs made already like weathercli, weather-util. But the first didn&#8217;t work at all. The second only supports USA states/cities. Not quite useful in my situation where I want weather conditions of The Hague in The Netherlands.</p>
<p>The result is a simple bash script that fetches xml data from <i>Google Weather AP</i>I using <i>curl</i>. This data is then parsed using <i>xmlscarlet</i> and <i>awk</i>.</p>
<p><img src="http://www.cinaq.com/wordpress/wp-content/uploads/2011/01/weather.png" alt="" title="weather" width="230" height="123" class="alignnone size-full wp-image-81" /></p>
<p><a href="https://i.cinaq.com/redmine/projects/awesome/repository/entry/bin/weather">View the final script</a></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.cinaq.com/wordpress/2011/01/weather-simple-command-line-weather-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Awesome config and nagios graph scripts</title>
		<link>http://www.cinaq.com/wordpress/2010/12/awesome-config-and-nagios-graph-scripts/</link>
		<comments>http://www.cinaq.com/wordpress/2010/12/awesome-config-and-nagios-graph-scripts/#comments</comments>
		<pubDate>Sat, 04 Dec 2010 17:50:41 +0000</pubDate>
		<dc:creator>xiwen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[awesome]]></category>
		<category><![CDATA[configs]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[nc10]]></category>
		<category><![CDATA[netbook]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://www.cinaq.com/wordpress/?p=71</guid>
		<description><![CDATA[Recently I made my Awesome config, its related scripts and nagios performance data check scripts available to the public. Check them out at my Open source projects site. Related posts:Projects Train Recurrent neural network using particle swarm optimizer


Related posts:<ol><li><a href='http://www.cinaq.com/wordpress/projects/' rel='bookmark' title='Projects'>Projects</a></li>
<li><a href='http://www.cinaq.com/wordpress/2010/12/train-recurrent-neural-network-using-particle-swarm-optimizer/' rel='bookmark' title='Train Recurrent neural network using particle swarm optimizer'>Train Recurrent neural network using particle swarm optimizer</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Recently I made my Awesome config, its related scripts and nagios performance data check scripts available to the public. Check them out at my <a href="https://i.cinaq.com/redmine/projects/osp">Open source projects</a> site.</p>
<p><a href="http://www.cinaq.com/wordpress/wp-content/uploads/2010/12/awesome.png"><img src="http://www.cinaq.com/wordpress/wp-content/uploads/2010/12/awesome-300x123.png" alt="" title="awesome" width="300" height="123" class="alignnone size-medium wp-image-72" /></a></p>


<p>Related posts:<ol><li><a href='http://www.cinaq.com/wordpress/projects/' rel='bookmark' title='Projects'>Projects</a></li>
<li><a href='http://www.cinaq.com/wordpress/2010/12/train-recurrent-neural-network-using-particle-swarm-optimizer/' rel='bookmark' title='Train Recurrent neural network using particle swarm optimizer'>Train Recurrent neural network using particle swarm optimizer</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.cinaq.com/wordpress/2010/12/awesome-config-and-nagios-graph-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Train Recurrent neural network using particle swarm optimizer</title>
		<link>http://www.cinaq.com/wordpress/2010/12/train-recurrent-neural-network-using-particle-swarm-optimizer/</link>
		<comments>http://www.cinaq.com/wordpress/2010/12/train-recurrent-neural-network-using-particle-swarm-optimizer/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 19:39:00 +0000</pubDate>
		<dc:creator>xiwen</dc:creator>
				<category><![CDATA[LIACS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Research]]></category>

		<guid isPermaLink="false">http://www.cinaq.com/wordpress/?p=67</guid>
		<description><![CDATA[In the project LIACS SWI 2010 a recurrent neural network is trained using a standard particle swarm optimizer. This trained NN is then used as the brain to drive a two-wheel truck in an on-dimensional world with obstacles. The fitness of a solution is determined by simulating a run and then calculate the traveled distance. [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>In the project <a href="https://i.cinaq.com/redmine/projects/swi2010">LIACS SWI 2010</a> a recurrent neural network is trained using a standard particle swarm optimizer. This trained NN is then used as the brain to drive a two-wheel truck in an on-dimensional world with obstacles. </p>
<p><span id="more-67"></span></p>
<p>The fitness of a solution is determined by simulating a run and then calculate the traveled distance. Check the project site for all details and source codes.</p>
<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/J_QZrTARB8A?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/J_QZrTARB8A?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.cinaq.com/wordpress/2010/12/train-recurrent-neural-network-using-particle-swarm-optimizer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recovering data from corrupted partitiontable</title>
		<link>http://www.cinaq.com/wordpress/2009/01/recovering-data-from-corrupted-partitiontable/</link>
		<comments>http://www.cinaq.com/wordpress/2009/01/recovering-data-from-corrupted-partitiontable/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 17:15:26 +0000</pubDate>
		<dc:creator>xiwen</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[corrupt]]></category>
		<category><![CDATA[ext2]]></category>
		<category><![CDATA[ext3]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[partition]]></category>
		<category><![CDATA[partitiontable]]></category>
		<category><![CDATA[recovery]]></category>
		<category><![CDATA[scandrive]]></category>
		<category><![CDATA[sfdisk]]></category>

		<guid isPermaLink="false">http://www.cinaq.com/wordpress/?p=11</guid>
		<description><![CDATA[The situation is very simple. It does not happen regularly, but if you do come across it you might find this post useful. Now quit the chit-chat. As the title already implies, my external HDD (harddrive), a Western Digital mybook 500GB with data ended up with a corrupted partitiontable. The story began like this: I [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>The situation is very simple. It does not happen regularly, but if you do come across it you might find this post useful. Now quit the chit-chat. As the title already implies, my external HDD (harddrive), a Western Digital mybook 500GB with data ended up with a corrupted partitiontable.</p>
<p><span id="more-11"></span></p>
<p>The story began like this: I needed a hfs (Mac OS) to do some testing. I remember the first 3 partitions on my HDD functioned as test-subject during my <a href="https://i.cinaq.com/trac/amsonia">Amsonia adventures</a>. So I thought, why not merge these into one larger partition. In the beginning my HDD had this structure:</p>
<table>
<tr>
<td>
primary 1
</td>
<td>
swap
</td>
</tr>
<tr>
<td>
primary 2
</td>
<td>
fat32
</td>
</tr>
<tr>
<td>
primary 3
</td>
<td>
ext3
</td>
</tr>
<tr>
<td>
extended partition
</td>
<td>
-
</td>
</tr>
<tr>
<td>
logical 1
</td>
<td>
ext3
</td>
</tr>
<tr>
<td>
logical 2
</td>
<td>
ext3
</td>
</tr>
</table>
<p>This structure is then altered using <i>fdisk</i> and resulted in this state:</p>
<table>
<tr>
<td>
Free space
</td>
<td>
-
</td>
</tr>
<tr>
<td>
extended partition
</td>
<td>
-
</td>
</tr>
<tr>
<td>
logical 1
</td>
<td>
ext3
</td>
</tr>
<tr>
<td>
logical 2
</td>
<td>
ext3
</td>
</tr>
</table>
<p>So the process of freeing space was done beautifully. The data on my logical partitions remained intact as they should be. The next step would be of course connect the disc to the macbook and launch <i>Disk Utility</i> to create the partition and format it. I double checked it won&#8217;t touch the partitions by reviewing the options hidden in <i>options</i>. Everything seems fine, so let&#8217;s apply the changes&#8230;. and there comes the surprise: Disk utility failed to apply the changes and ejects the device.</p>
<p>Apparently Disk Utility did modify the partitiontable but failed to do it successfully. Here I am, my partitions inaccessible. A quick web-hunt resulted in trying out <i>gpart</i>. The process of scanning 500GB took around 10 hours to complete; the disc was connected over usb 2.0. Average readspeed was 16mb/s. When gpart was done scanning, it didn&#8217;t report anything useful. So the hunt continues till I stumbled against <a href="http://www.unixwiz.net/techtips/recovering-ext2.html">Recovering lost ext2 Linux filesystems</a>. After reading the article I decided to give their hand-crafted utility a try. <i>My article is written with the hope to add value to the information you&#8217;ve gathered. It should not be seen as a replacement! </i></p>
<p>After scanning the whole disc, Scandrive produces a ~2mb report. As the article indicates, lines of the following format might indicate partition start:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ext2&nbsp; &nbsp; 432180492 &nbsp; # size=68095510 #0</div></div>
<p>So, let&#8217;s filter out these interesting line with <i>grep</i>:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">grep -w &quot;#0&quot; /path/to/file</div></div>
<p>The key here is to find a pattern in the less cluttered data. With pattern I mean consecutive large groups having the same size. All found groups are potential partitions, the first block of the group minus two might be the start of a partition. </p>
<p>Once you&#8217;ve gathered the offsets and sorted by group size, you can start trying to recreate the partitiontable (preferably one by one) using <i>sfdisk</i>.</p>
<p>Back to my situation, after some trial and error attempts I found <i>logical 1</i>, but the size appears to be incorrect. Because the system could only read that partition partially (some directories could not be read). So I decided to calculate the maximum size of my HDD and use it as the right-boundary. This allowed me to recover all files on <i>logical 1</i>. When the copying process was done, the second partition can also be found and treated in the same way. </p>
<p>You can define the boundaries (your new partitiontable structure) in a text file like this:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># partition table of /dev/sdc<br />
unit: sectors<br />
<br />
/dev/sdb1 : start= &nbsp; &nbsp; &nbsp; 432003978, size=544764087, Id=83</div></div>
<p>Then write it to the disc using sfdisk:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sfdisk -n /dev/YOURDEV &lt; /path/to/new/pt</div></div>
<p>If you think it is good, commit to disc:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sfdisk --force /dev/YOURDEV &lt; /path/to/new/pt</div></div>
<p>Then try to mount the new partition. If mount bails out with an error, don&#8217;t panic, continue trying other potential starting offsets.</p>
<p>Notice the start offset is calculated this way, say you found this line:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ext2&nbsp; &nbsp; 432180492 &nbsp; # size=68095510 #0</div></div>
<p>The start offset should be: 432180492-2 = 432180490<br />
You only have to do this for the first offset in a group!</p>
<p>The recovering adventure lasted 1.5 days with a happy ending. I&#8217;ve learned a lot during this process, I hope you find this information useful. Special thanks go to <i>Steve Friedl&#8217;s Unixwiz.net Tech Tips</i>.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.cinaq.com/wordpress/2009/01/recovering-data-from-corrupted-partitiontable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debian as nxserver and OS X tiger with nxclient (freeNX)</title>
		<link>http://www.cinaq.com/wordpress/2008/07/debian-as-nxserver-and-os-x-tiger-with-nxclient-freenx/</link>
		<comments>http://www.cinaq.com/wordpress/2008/07/debian-as-nxserver-and-os-x-tiger-with-nxclient-freenx/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 07:41:30 +0000</pubDate>
		<dc:creator>xiwen</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[macbook]]></category>
		<category><![CDATA[nomachine]]></category>
		<category><![CDATA[nxclient]]></category>
		<category><![CDATA[nxserver]]></category>
		<category><![CDATA[qtnx]]></category>
		<category><![CDATA[rdp]]></category>
		<category><![CDATA[tiger]]></category>

		<guid isPermaLink="false">http://www.cinaq.com/wordpress/?p=9</guid>
		<description><![CDATA[Test-drive NX server free edition on a debian server and a client running OS X Tiger.


No related posts.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.nomachine.com">No Machines</a> NX solution has been around for a while. It is an equivalent of RDP (remote desktop protocol in the MS windows world) which supports resumable sessions.  It opens the door the conventional X-protocol was not designed to operate on, which is efficient usage of bandwidth.<span id="more-9"></span></p>
<p><strong>Setup</strong> &#8211; The environment I tested consists of the following components:</p>
<ol>
<li>A server, in my case a Debian Etch</li>
<li>A client, mac OS X Tiger on a macbook</li>
<li>X11 on OS X</li>
<li><a href="http://www.nomachine.com/select-package.php?os=linux&amp;id=1">freenx server-3.2.0-13</a> from No Machine</li>
<li><a href="http://www.nomachine.com/download-client-macosx.php">nxclient-3.2.0-9</a>, there are other platforms.</li>
<li>A window manager on the server, I use e17 (see screenshot in the end)</li>
<li>In case you wonder, my connection is an Adsl 2+ with 14mbps down and 1mbps up.  Ping to the server under normal network load is 20ms.</li>
</ol>
<p><strong>Performance</strong> &#8211; &#8220;Wow&#8221;, that&#8217;s all I can say. The performance is just great! Compared to RDP, I think they are on the same level, or possibly better: the special effects (animations) in e17 worked flawlessly, the transitions were smooth. Flipping desktop had a little delay, not quite noticable though. During usage it uses approximately 20kb/s (kilobytes) of the pipe.</p>
<p><strong>Security</strong> &#8211; You shouldn&#8217;t worry about security as NX traffics are tunneled through SSH by default, hence you only need to open port 22 on the server side.</p>
<p><strong>QtNX</strong> &#8211; George Wright released a <a href="http://blog.gwright.org.uk/articles/2008/01/30/qtnx-for-mac-os-x-a-release">QT-based nxclient for OS X</a>. This is an alternative of nxclient if you dislike the X11-aqua-like interface components.</p>
<p><strong>Drawbacks</strong> &#8211; First is its X11 requirement, this means a lot of things; like no clip-board integration.  GDM (or any Desktop manager) doesn&#8217;t support NX (as of this writing). This can be worked around pretty easily with a wrapper (or I hope so). I&#8217;m considering to add it to my projects queue.</p>
<p><strong>Experiments</strong> &#8211; In the future some hard-benchmarks can prove freenx&#8217; competence. For now it has convinced me enough.</p>
<p><a href="http://www.cinaq.com/wordpress/wp-content/uploads/2008/07/picture-3.png"><img class="alignnone size-medium wp-image-10" title="e17 in nxclient" src="http://www.cinaq.com/wordpress/wp-content/uploads/2008/07/picture-3-300x187.png" alt="" width="300" height="187" /></a></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.cinaq.com/wordpress/2008/07/debian-as-nxserver-and-os-x-tiger-with-nxclient-freenx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

