Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* Damaged super block / fs root
@ 2011-05-30 15:59 Dennis Bergmann
  2011-05-30 16:12 ` Hugo Mills
  0 siblings, 1 reply; 6+ messages in thread
From: Dennis Bergmann @ 2011-05-30 15:59 UTC (permalink / raw)
  To: linux-btrfs

I have accidently damaged the first block(s) of a btrfs partition
and can't mount it anymore.

I can see that my data is still intact by running a command like:

cat /dev/sda5 | hexdump -C | more

Do any (experimental) tools exist which would allow me to recover the files?


Thank you

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Damaged super block / fs root
  2011-05-30 15:59 Damaged super block / fs root Dennis Bergmann
@ 2011-05-30 16:12 ` Hugo Mills
  2011-05-30 16:47   ` Dennis Bergmann
  2011-05-30 19:23   ` Peter Stuge
  0 siblings, 2 replies; 6+ messages in thread
From: Hugo Mills @ 2011-05-30 16:12 UTC (permalink / raw)
  To: Dennis Bergmann; +Cc: Btrfs mailing list

[-- Attachment #1: Type: text/plain, Size: 1084 bytes --]

On Mon, May 30, 2011 at 05:59:54PM +0200, Dennis Bergmann wrote:
> I have accidently damaged the first block(s) of a btrfs partition
> and can't mount it anymore.
> 
> I can see that my data is still intact by running a command like:
> 
> cat /dev/sda5 | hexdump -C | more
> 
> Do any (experimental) tools exist which would allow me to recover the files?

   There's btrfs-select-super, which is in the git repo for btrfs
tools, in the next or tmp branches. That should allow you to select an
alternative superblock to use, which (I think) will help you. If it is
just your superblock that's damaged, that should help.

   You can check whether it's likely to be of use by running "btrfsck
-s 1" on your filesystem. If it passes OK, then btrfs-select-super
should be useful.

   Hugo.

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
  --- Attempted murder, now honestly, what is that?  Do they give a ---  
                  Nobel Prize for attempted chemistry?                   

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Damaged super block / fs root
  2011-05-30 16:12 ` Hugo Mills
@ 2011-05-30 16:47   ` Dennis Bergmann
  2011-05-30 19:03     ` Chris Mason
  2011-05-30 19:23   ` Peter Stuge
  1 sibling, 1 reply; 6+ messages in thread
From: Dennis Bergmann @ 2011-05-30 16:47 UTC (permalink / raw)
  To: linux-btrfs

On 30.05.2011 18:12, Hugo Mills wrote:
>     You can check whether it's likely to be of use by running "btrfsck
> -s 1" on your filesystem. If it passes OK, then btrfs-select-super
> should be useful.
>
>     Hugo.

Didn't work, unfortunately.

My btrfsck version is v0.19-35-g1b444cd-dirty and running
"btrfsck -s 1 /dev/sda5" quits with the following message:

using SB copy 1, bytenr 67108864
No valid Btrfs found on /dev/sda5








^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Damaged super block / fs root
  2011-05-30 16:47   ` Dennis Bergmann
@ 2011-05-30 19:03     ` Chris Mason
  2011-05-31  8:50       ` Dennis Bergmann
  0 siblings, 1 reply; 6+ messages in thread
From: Chris Mason @ 2011-05-30 19:03 UTC (permalink / raw)
  To: Dennis Bergmann; +Cc: linux-btrfs

Excerpts from Dennis Bergmann's message of 2011-05-30 12:47:01 -0400:
> On 30.05.2011 18:12, Hugo Mills wrote:
> >     You can check whether it's likely to be of use by running "btrfsck
> > -s 1" on your filesystem. If it passes OK, then btrfs-select-super
> > should be useful.
> >
> >     Hugo.
> 
> Didn't work, unfortunately.
> 
> My btrfsck version is v0.19-35-g1b444cd-dirty and running
> "btrfsck -s 1 /dev/sda5" quits with the following message:
> 
> using SB copy 1, bytenr 67108864
> No valid Btrfs found on /dev/sda5
> 

How big is the FS?  What command did you use to overwrite the super
block?  Please try to tell us exactly which commands were run.

There are other ways we can try to pull things off, but you should try
btrfsck -s 2 as well.

-chris

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Damaged super block / fs root
  2011-05-30 16:12 ` Hugo Mills
  2011-05-30 16:47   ` Dennis Bergmann
@ 2011-05-30 19:23   ` Peter Stuge
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Stuge @ 2011-05-30 19:23 UTC (permalink / raw)
  To: Btrfs mailing list; +Cc: Hugo Mills, Dennis Bergmann

[-- Attachment #1: Type: text/plain, Size: 4964 bytes --]

Hugo Mills wrote:
>    You can check whether it's likely to be of use by running "btrfsck
> -s 1" on your filesystem. If it passes OK, then btrfs-select-super
> should be useful.

Inspired by this I cloned latest btrfs-progs-unstable and tried it on
my broken 60-something GB btrfs, but no luck:

$ btrfsck -s 0 /dev/sdb2
using SB copy 0, bytenr 65536
btrfsck: disk-io.c:739: open_ctree_fd: Assertion `!(!tree_root->node)' failed.
Aborted
$ btrfsck -s 1 /dev/sdb2
using SB copy 1, bytenr 67108864
btrfsck: disk-io.c:739: open_ctree_fd: Assertion `!(!tree_root->node)' failed.
Aborted
$ btrfsck -s 2 /dev/sdb2
using SB copy 2, bytenr 274877906944
No valid Btrfs found on /dev/sdb2
$ 


I created an empty 384 MB btrfs:

$ dd if=/dev/zero of=/tmp/test_fs bs=1024k count=384
$ mkfs.btrfs /tmp/test_fs
$ 

And then I compare output from btrfs-debug-tree between test_fs and
my broken one:

$ strace -e pread64 btrfs-debug-tree /tmp/test_fs 2>&1 | sed 's-,"\(.\{5\}\).*"-, "\1"-'
pread64(3, "\351\"..., 2859, 65536) = 2859
pread64(3, "I\227"..., 2859, 67108864) = 2859
pread64(3, ""..., 2859, 274877906944)   = 0
pread64(5, "\351\"..., 2859, 65536) = 2859
pread64(5, "I\227"..., 2859, 67108864) = 2859
pread64(5, ""..., 2859, 274877906944)   = 0
pread64(5, "\37\2"..., 4096, 20971520) = 4096
pread64(5, "\311\"..., 4096, 37752832) = 4096
pread64(5, "\247C"..., 4096, 37756928) = 4096
pread64(5, "\225\"..., 4096, 37761024) = 4096
pread64(5, "\210z"..., 4096, 37765120) = 4096
pread64(5, "\3\34"..., 4096, 37748736) = 4096
root tree
leaf 29364224 items 9 free space 2349 generation 7 owner 1
fs uuid d29c2f7a-0a4e-4a1d-8458-2d241f6f29de
chunk uuid fb34ff75-1cb6-4974-af37-e0a464135216
        item 0 key (EXTENT_TREE ROOT_ITEM 0) itemoff 3756 itemsize 239
                root data bytenr 29368320 level 0 dirid 0 refs 1
        item 1 key (DEV_TREE ROOT_ITEM 0) itemoff 3517 itemsize 239
                root data bytenr 29372416 level 0 dirid 0 refs 1
...

$ strace -e pread64 btrfs-debug-tree /dev/sdb2 2>&1 | sed 's-, "\(.\{5\}\).*"-, "\1"-'
pread64(3, "p\23{"..., 2859, 65536) = 2859
pread64(3, "\320r"..., 2859, 67108864) = 2859
pread64(3, ""..., 2859, 274877906944)   = 0
pread64(5, "p\23{"..., 2859, 65536) = 2859
pread64(5, "\320r"..., 2859, 67108864) = 2859
pread64(5, ""..., 2859, 274877906944)   = 0
pread64(5, "\353$"..., 4096, 20971520) = 4096
pread64(5, "\275\"..., 4096, 20987904) = 4096
pread64(5, "\253\"..., 4096, 20983808) = 4096
pread64(5, "\0\0\"..., 4096, 36675878912) = 4096
pread64(5, "\0\0\"..., 4096, 36675878912) = 4096
pread64(5, "\0\0\"..., 4096, 36944314368) = 4096
btrfs-debug-tree: disk-io.c:739: open_ctree_fd: Assertion `!(!tree_root->node)' failed.
--- SIGABRT (Aborted) @ 0 (0) ---
+++ killed by SIGABRT +++

I also tried the btrfsck again:

$ strace -e pread64 btrfsck -s 0 /dev/sdb2 2>&1 | sed 's-, "\(.\?.\?.\?\).*"-, "\1"-'
pread64(3, "p\2"..., 2859, 65536) = 2859
pread64(3, "\32"..., 2859, 67108864) = 2859
pread64(3, ""..., 2859, 274877906944)   = 0
pread64(3, "p\2"..., 2859, 65536) = 2859
pread64(3, "\32"..., 2859, 67108864) = 2859
pread64(3, ""..., 2859, 274877906944)   = 0
pread64(5, "p\2"..., 2859, 65536) = 2859
pread64(5, "\32"..., 2859, 67108864) = 2859
pread64(5, ""..., 2859, 274877906944)   = 0
pread64(5, "\35"..., 4096, 20971520) = 4096
pread64(5, "\27"..., 4096, 20987904) = 4096
pread64(5, "\25"..., 4096, 20983808) = 4096
pread64(5, "\0\"..., 4096, 36675878912) = 4096
pread64(5, "\0\"..., 4096, 36675878912) = 4096
pread64(5, "\0\"..., 4096, 36944314368) = 4096
btrfsck: disk-io.c:739: open_ctree_fd: Assertion `!(!tree_root->node)' failed.
using SB copy 0, bytenr 65536
--- SIGABRT (Aborted) @ 0 (0) ---
+++ killed by SIGABRT +++
$ strace -e pread64 btrfsck -s 1 /dev/sdb2 2>&1 | sed 's-, "\(.\?.\?.\?\).*"-, "\1"-'
pread64(3, "p\2"..., 2859, 65536) = 2859
pread64(3, "\32"..., 2859, 67108864) = 2859
pread64(3, ""..., 2859, 274877906944)   = 0
pread64(3, "\32"..., 2859, 67108864) = 2859
pread64(5, "\32"..., 2859, 67108864) = 2859
pread64(5, "\35"..., 4096, 20971520) = 4096
pread64(5, "\27"..., 4096, 20987904) = 4096
pread64(5, "\25"..., 4096, 20983808) = 4096
pread64(5, "\0\"..., 4096, 36675878912) = 4096
pread64(5, "\0\"..., 4096, 36675878912) = 4096
pread64(5, "\0\"..., 4096, 36944314368) = 4096
btrfsck: disk-io.c:739: open_ctree_fd: Assertion `!(!tree_root->node)' failed.
using SB copy 1, bytenr 67108864
--- SIGABRT (Aborted) @ 0 (0) ---
+++ killed by SIGABRT +++
$ strace -e pread64 btrfsck -s 2 /dev/sdb2 2>&1 | sed 's-, "\(.\?.\?.\?\).*"-, "\1"-'
pread64(3, "p\2"..., 2859, 65536) = 2859
pread64(3, "\32"..., 2859, 67108864) = 2859
pread64(3, ""..., 2859, 274877906944)   = 0
pread64(3, ""..., 2859, 274877906944)   = 0
No valid Btrfs found on /dev/sdb2
using SB copy 2, bytenr 274877906944
$ 


Does this give any hint about how the tree has been broken?


//Peter

[-- Attachment #2: Type: application/pgp-signature, Size: 190 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Damaged super block / fs root
  2011-05-30 19:03     ` Chris Mason
@ 2011-05-31  8:50       ` Dennis Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Dennis Bergmann @ 2011-05-31  8:50 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Chris Mason

Hello Chris

On 30.05.2011 21:03, Chris Mason wrote:
> How big is the FS?
About 100 G on a  500 G partition. I would only like to recover some 
plain text files from it (source code),
I don't need the partition to be mountable again.

>   What command did you use to overwrite the super
> block?  Please try to tell us exactly which commands were run.
I had to install FreeBSD on that disk (with Linux, a btrfs partition, 
and several free partitions on it).
When using the FreeBSD partition tool, I didn't create or delete any 
partitions. I only assigned a
free partition to FreeBSD. When I booted later in Linux the Btrfs 
partition did not mount anymore.

> There are other ways we can try to pull things off, but you should try
> btrfsck -s 2 as well.
btrfcsk -s 2 exits with:

using SB copy 2, bytenr 274877906944
No valid Btrfs found on /dev/sda10




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-05-31  8:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-30 15:59 Damaged super block / fs root Dennis Bergmann
2011-05-30 16:12 ` Hugo Mills
2011-05-30 16:47   ` Dennis Bergmann
2011-05-30 19:03     ` Chris Mason
2011-05-31  8:50       ` Dennis Bergmann
2011-05-30 19:23   ` Peter Stuge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox