Skip to contentSkip to conversation

Rescue a single-device btrfs instance with zeroed tree root

DISCUSSION Ivan Shapovalov 1 participant 2 messages Jun 21, 2016 – Jun 27, 2016 Btrfs file system

lore
Share & tools
lore
#0 lore raw

Hello,

So this is another case of "I lost my partition and do not have backups". More precisely, _this_ is the backup and it turned out to be damaged.

(The backup was made by partclone.btrfs. Together with a zeroed out tree root, this asks for a bug in partclone...)

So: the tree root is zeroes, backup roots are zeroes too, btrfs-find-root only reports blocks of level 0 (needed is 1). Is there something that can be done? Maybe it is possible to reconstruct the root from its children?
Operations log following.
Please Cc: me in replies as I'm not subscribed to the list.

1. regular mount

# mount /dev/loop0p3 /mnt/temp

=== dmesg ===

[106737.299592] BTRFS info (device loop0p3): disk space caching is enabled
[106737.299604] BTRFS: has skinny extents
[106737.299884] BTRFS error (device loop0p3): bad tree block start 0 162633449472
[106737.299888] BTRFS: failed to read tree root on loop0p3
[106737.314359] BTRFS: open_ctree failed

=== end dmesg ===

2. mount with -o recovery

# mount -o recovery /dev/loop0p3 /mnt/temp

=== dmesg ===

[106742.305720] BTRFS warning (device loop0p3): 'recovery' is deprecated, use 'usebackuproot' instead
[106742.305722] BTRFS info (device loop0p3): trying to use backup root at mount time
[106742.305724] BTRFS info (device loop0p3): disk space caching is enabled
[106742.305725] BTRFS: has skinny extents
[106742.306056] BTRFS error (device loop0p3): bad tree block start 0 162633449472
[106742.306060] BTRFS: failed to read tree root on loop0p3
[106742.306069] BTRFS error (device loop0p3): bad tree block start 0 162633449472
[106742.306071] BTRFS: failed to read tree root on loop0p3
[106742.306084] BTRFS error (device loop0p3): bad tree block start 0 162632237056
[106742.306086] BTRFS: failed to read tree root on loop0p3
[106742.306097] BTRFS error (device loop0p3): bad tree block start 0 162626682880
[106742.306100] BTRFS: failed to read tree root on loop0p3
[106742.306111] BTRFS error (device loop0p3): bad tree block start 0 162609168384
[106742.306114] BTRFS: failed to read tree root on loop0p3
[106742.327272] BTRFS: open_ctree failed

=== end dmesg ===

3. btrfs-find-root

# btrfs-find-root /dev/loop0p3
Couldn't read tree root
Superblock thinks the generation is 22332
Superblock thinks the level is 1
Well block 162633646080(gen: 22332 level: 0) seems good, but generation/level doesn't match, want gen: 22332 level: 1
Well block 162633596928(gen: 22332 level: 0) seems good, but generation/level doesn't match, want gen: 22332 level: 1
Well block 162633515008(gen: 22332 level: 0) seems good, but generation/level doesn't match, want gen: 22332 level: 1

Thanks,

Signature · 1 line
Ivan Shapovalov / intelfx /
#1 lore raw
Quoted 10 lines · Ivan Shapovalov

Hello,

So this is another case of "I lost my partition and do not have backups". More precisely, _this_ is the backup and it turned out to be
damaged.

(The backup was made by partclone.btrfs. Together with a zeroed out tree root, this asks for a bug in partclone...)

Quoted 6 lines

So: the tree root is zeroes, backup roots are zeroes too, btrfs-find-root only reports blocks of level 0 (needed is 1). Is there something that can be done? Maybe it is possible to reconstruct the root from its children?
Operations log following.
Please Cc: me in replies as I'm not subscribed to the list.

Anyone? I'd appreciate any advice on how to rebuild the tree roots.

I'd even write some code if someone tells me the disk format and logical tree constraints (i. e. in which order to put pointers to child nodes).

BTW, it looks like all tree roots are lost, i. e. btrfs-find-root with any objectid (extent tree, subvolume tree, anything in ctree.h) finds only level 0 nodes.

It should be possible to rebuild intermediate nodes, isn't it? Do they contain valuable information?

Please Cc: me in replies as I'm not subscribed to the list.

Thanks,

Signature · 1 line
Ivan Shapovalov / intelfx /
Quoted 60 lines

1. regular mount

# mount /dev/loop0p3 /mnt/temp

=== dmesg ===

[106737.299592] BTRFS info (device loop0p3): disk space caching is
enabled
[106737.299604] BTRFS: has skinny extents
[106737.299884] BTRFS error (device loop0p3): bad tree block start 0
162633449472
[106737.299888] BTRFS: failed to read tree root on loop0p3
[106737.314359] BTRFS: open_ctree failed

=== end dmesg ===

2. mount with -o recovery

# mount -o recovery /dev/loop0p3 /mnt/temp

=== dmesg ===

[106742.305720] BTRFS warning (device loop0p3): 'recovery' is
deprecated, use 'usebackuproot' instead
[106742.305722] BTRFS info (device loop0p3): trying to use backup
root at mount time
[106742.305724] BTRFS info (device loop0p3): disk space caching is
enabled
[106742.305725] BTRFS: has skinny extents
[106742.306056] BTRFS error (device loop0p3): bad tree block start 0
162633449472
[106742.306060] BTRFS: failed to read tree root on loop0p3
[106742.306069] BTRFS error (device loop0p3): bad tree block start 0
162633449472
[106742.306071] BTRFS: failed to read tree root on loop0p3
[106742.306084] BTRFS error (device loop0p3): bad tree block start 0
162632237056
[106742.306086] BTRFS: failed to read tree root on loop0p3
[106742.306097] BTRFS error (device loop0p3): bad tree block start 0
162626682880
[106742.306100] BTRFS: failed to read tree root on loop0p3
[106742.306111] BTRFS error (device loop0p3): bad tree block start 0
162609168384
[106742.306114] BTRFS: failed to read tree root on loop0p3
[106742.327272] BTRFS: open_ctree failed

=== end dmesg ===

3. btrfs-find-root

# btrfs-find-root /dev/loop0p3
Couldn't read tree root
Superblock thinks the generation is 22332
Superblock thinks the level is 1
Well block 162633646080(gen: 22332 level: 0) seems good, but
generation/level doesn't match, want gen: 22332 level: 1
Well block 162633596928(gen: 22332 level: 0) seems good, but
generation/level doesn't match, want gen: 22332 level: 1
Well block 162633515008(gen: 22332 level: 0) seems good, but
generation/level doesn't match, want gen: 22332 level: 1

Thanks,