<?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; recovery</title>
	<atom:link href="http://www.cinaq.com/wordpress/tag/recovery/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>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>
	</channel>
</rss>

