BTRFS:是否可以切换到另一个树根?

BTRFS:是否可以切换到另一个树根?

我的 BTRFS 分区损坏了,

mount -o usebackuproot ...

不起作用:

[ 9252.141767] BTRFS info (device dm-1): trying to use backup root at mount time
[ 9252.141779] BTRFS info (device dm-1): disabling disk space caching
[ 9252.141784] BTRFS info (device dm-1): has skinny extents
[ 9252.184586] BTRFS error (device dm-1): parent transid verify failed on 7777276116992 wanted 100336 found 89751
[ 9252.186302] BTRFS error (device dm-1): parent transid verify failed on 7777276116992 wanted 100336 found 89751
[ 9252.186306] BTRFS warning (device dm-1): failed to read tree root
[ 9252.186729] BTRFS error (device dm-1): parent transid verify failed on 7777276116992 wanted 100336 found 89751
[ 9252.187091] BTRFS error (device dm-1): parent transid verify failed on 7777276116992 wanted 100336 found 89751
[ 9252.187094] BTRFS warning (device dm-1): failed to read tree root
[ 9252.187372] BTRFS error (device dm-1): parent transid verify failed on 7777213923328 wanted 100335 found 89750
[ 9252.187589] BTRFS error (device dm-1): parent transid verify failed on 7777213923328 wanted 100335 found 89750
[ 9252.187592] BTRFS warning (device dm-1): failed to read tree root
[ 9252.187948] BTRFS error (device dm-1): parent transid verify failed on 7777188921344 wanted 100334 found 100336
[ 9252.188281] BTRFS error (device dm-1): parent transid verify failed on 7777188921344 wanted 100334 found 100336
[ 9252.188284] BTRFS warning (device dm-1): failed to read tree root
[ 9252.188661] BTRFS error (device dm-1): parent transid verify failed on 7260661022720 wanted 100333 found 96460
[ 9252.189025] BTRFS error (device dm-1): parent transid verify failed on 7260661022720 wanted 100333 found 96460
[ 9252.189029] BTRFS warning (device dm-1): failed to read tree root
[ 9252.236361] BTRFS: open_ctree failed

btrfs 检查也不起作用:

btrfs check /dev/mapper/media
parent transid verify failed on 7777276116992 wanted 100336 found 89751
parent transid verify failed on 7777276116992 wanted 100336 found 89751
parent transid verify failed on 7777276116992 wanted 100336 found 89751
parent transid verify failed on 7777276116992 wanted 100336 found 89751
Ignoring transid failure
Couldn't setup extent tree
Couldn't open file system

我找到了一些可以用来做“树根”的积木btrfs 恢复“:

btrfs restore -t 8889016483840 -D -i -v /dev/mapper/media /dev/null | wc -l
2264442

但我在这里遇到了问题。我的 btrfs 存储非常大,超过 20TB,而且我没有这么大的备用磁盘来备份和恢复它。是否可以修复这样的文件系统或“就地”切换到给定的树根块,而无需重新格式化它?

答案1

首先,确保您拥有有效的超级块:

btrfs rescue super-recover -v <device>

使用:

btrfs find-root <device>

找到最适合修复的树根

  1. 根节点应该具有最高级别
  2. 代数越高,使用该根恢复 fs 的机会就越大。

注意:你的错误信息中, wanted是日志中的生成,found是基于树根的生成。

从以下命令中找到最干净的输出:

btrfs check --tree-root <block> --super <sup>

在哪里:

  • <sup>012
  • <block>给出的是btrfs find-root(注意:乘以块大小,即使手册上说<bytenr>

然后按如下方式修复文件系统:

btrfs check --repair --tree-root <block> --super <sup>

--repair请注意实际改变文件系统的添加。

相关内容