a slightly easier way of going through the indirect block...<br>recovered=12<br>for i in `hexdump -e '4/4 "%10i " "\n"' /ramfs/restored.ind` ; do<br>        if [[ "$i" -ne 0 ]] ; then<br>
                dd if=$DEV bs=$BS of=/ramfs/restored.ind skip=$i seek=$((recovered++))  count=1<br>        fi<br>done<br><br>However, if the inode in question still exists, then I'd be inclined to suggest that you mount the filesystem<br>
(readonly preferably), and then hunt for the inode.... let the filesystem do the heavy lifting for you.<br><br>find /mount/recovered -inum 145601 -print<br><br>or, even better yet:<br><br>cp ` find /mount/recovered -inum 145601 -print` recovered-file<br>
<br><br><div class="gmail_quote">On Fri, Oct 8, 2010 at 6:10 AM, Bodo Thiesen <span dir="ltr"><<a href="mailto:bothie@gmx.de">bothie@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
* Ralf Gross <<a href="mailto:Ralf-Lists@ralfgross.de">Ralf-Lists@ralfgross.de</a>> hat geschrieben:<br>
<div class="im"><br>
> ~ # ext3grep /dev/sda6 --inode 145601<br>
</div>> size: 175659<br>
<div class="im">> sectors: 352 (--> 1 indirect block).<br>
</div><div class="im">> Direct Blocks: 325495 325496 325497 325498 325499 325500 325501 325502 325503 325504 325505 325506<br>
> Indirect Block: 325507<br>
><br>
> So I know that there is something left of the file, but I don't know how to get<br>
> it back.<br>
<br>
</div>*** WARNING *** The following code snippet is meant to explain what you<br>
could do. Please don't stop using your brain. ;)<br>
<br>
*** BEGIN SNIPPET ***<br>
<br>
#! /bin/sh<br>
<br>
DEV=/dev/sda6<br>
BS=4096<br>
# This may be 2048 or 1024 - whatever cluster size your ext2<br>
# file system uses<br>
<br>
# Recover the first 12 clusters (the direct clusters)<br>
dd if=$DEV bs=$BS of=/ramfs/restored.data skip=325495 count=12<br>
<br>
# Get the indirect cluster<br>
dd if=$DEV bs=$BS of=/ramfs/restored.ind skip=325507 count=1<br>
<br>
# And dump it's content decimally ...<br>
hexdump -e '4/4 "%10i " "\n"' /ramfs/restored.ind<br>
# you should get an output like<br>
# 325508 325509 325510 325511<br>
# 325512 [...]<br>
# Check, that the numbers are one bigger than the previous ones.<br>
<br>
# Recover the following parts of the file (assuming, that the first<br>
# number is the 325508 and that there are 5 countiguous numbers.<br>
# The 12 comes from the previous skip argument<br>
dd if=$DEV bs=$BS of=/ramfs/restored.data skip=325508 seek=12 count=5<br>
<br>
# If there is a jump in the numbers printed by hexdump, continue with<br>
# the next cluster chain (17 = 12 + 5 - it's just the sum of clustes<br>
# already written to the file):<br>
dd if=$DEV bs=$BS of=/ramfs/restored.data<br>
skip=$whatever_number_comes_now seek=17 count=$length_of_chain<br>
<br>
# Repeat the last step until you are done.<br>
<br>
*** END SNIPPET ***<br>
<br>
After you are done, check the file and then copy it over to the file<br>
system so your user can continue to work on it again. And tell that user<br>
that he should stop using the application he was using all together.<br>
Overwriting a file with updated content is not state of the art for at<br>
least two decades. The old file content has to be saved in a backup file<br>
first or the old file could just be renamed. Every software I use does it<br>
either way. This way your user wouldn't have had this problem in the first<br>
place (just take the backup file and throw away the last 20 minutes of<br>
work - recovery takes longer anyways ...). Alternatively: Think about a<br>
proper daily (or even hourly) backup plan.<br>
<br>
Regards, Bodo<br>
<div><div></div><div class="h5"><br>
_______________________________________________<br>
Ext3-users mailing list<br>
<a href="mailto:Ext3-users@redhat.com">Ext3-users@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/ext3-users" target="_blank">https://www.redhat.com/mailman/listinfo/ext3-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Stephen Samuel <a href="http://www.bcgreen.com">http://www.bcgreen.com</a>  Software, like love, <br>778-861-7641                              grows when you give it away<br>