linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Elsayed <eternaleye+usenet@gmail.com>
To: linux-btrfs@vger.kernel.org
Subject: Re: filesystem finder / fixer
Date: Tue, 31 Jul 2012 10:52:40 -0700	[thread overview]
Message-ID: <jv9618$6nr$1@dough.gmane.org> (raw)
In-Reply-To: 20120731113247.11aab72a@natsu

Just realized I messed up sending this to the list.

Roman Mamedov wrote:

> On Mon, 30 Jul 2012 23:26:42 -0400 (EDT)
> serialhex@lavabit.com wrote:
> 
>> 1) is there a tool to help me recover data from my fs? I don't have a
>> backup of my partition table and so I have about 500GB of space where a
>> few partitionns might reside... GPT partitions mind you
> 
> If you only lost the partition table, there's a tool (strangely)named
> TestDisk, which can find the actual partitions on disk and restore it.
> Don't know if it supports GPT and BTRFS, though.
> 

If TestDisk doesn't support it, then you may be able to do it manually with 
some trial and error.

I just dumped the first 4 megabytes of my disk, and it looks like at offset
0x10040 (64K + 64 bytes) there's the string BHRfS (hex 5F 42 48 52 66 53 
5f). That matches the documentation (the first superblock should be at 64K). 
Therefore, if you can find that string, subtract 64 from the byte offset (to 
get the offset of the block it's in in bytes), divide that by 512, and 
subtract 125 (64 kilobytes in 512-byte blocks), you should have the number 
of 512-byte blocks from the start of the device that the partition should 
be.

Note: I have not actually done this. You may want to set the device read-
only (blockdev --setro) and use dm-linear directly to test whether the 
offset you find this way is correct.

Once you have a mapping or partition in the right place, you have two 
options for recovering your files: the btrfsck repair tool, or the btrfs-
restore extraction tool. The repair tool still doesn't fix all problems, but 
using btrfs-restore with btrfs-find-root has worked well for me in the past 
in one case where btrfsck didn't. Another benefit is that you can use it 
even while the disk is still in read-only mode and mapped via dm-linear, 
with essentially zero risk of damaging your data further. The downside is 
that you need a second drive that's big enough for all of your data.


  reply	other threads:[~2012-07-31 17:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-31  3:26 filesystem finder / fixer serialhex
2012-07-31  5:32 ` Roman Mamedov
2012-07-31 17:52   ` Alex Elsayed [this message]
2012-07-31 17:56     ` Alex Elsayed
2012-08-03 20:11     ` serialhex
2012-08-04  9:19       ` Martin Steigerwald
2012-07-31 10:42 ` Calvin Walton
2012-07-31 13:38   ` serialhex

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='jv9618$6nr$1@dough.gmane.org' \
    --to=eternaleye+usenet@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).