如何修复 BTRFS 分区上的错误

如何修复 BTRFS 分区上的错误

我需要帮助检查和修复 BTRFS 分区。这一切都是从我系统上的一些目录无法访问开始的。当我执行时,这些目录的权限显示为问号ls -l

d????????? ? ?           ?            ?  dir1/
d????????? ? ?           ?            ?  dir2/
d????????? ? ?           ?            ?  dir3/

我怀疑上次备份时出了问题rsync。当我尝试删除这些目录之一时,rm -frv dir1出现以下错误:

rm: cannot remove 'dir1': Input/output error

我卸载了分区并运行了 BTRFS' 检查

sudo umount /dev/sda1
sudo btrfs check /dev/sda1

我收到许多此类错误:

root 5 inode 77131 errors 2001, no inode item, link count wrong
        unresolved ref dir 68134 index 0 namelen 11 name <filename.ext> filetype 1 errors 6, no dir index, no inode ref

请在下面找到该命令的摘要btrfs check

ERROR: errors found in fs roots
found 291234099200 bytes used, error(s) found
total csum bytes: 268053312
total tree bytes: 372293632
total fs tree bytes: 58654720
total extent tree bytes: 7356416
btree space waste bytes: 45522801
file data blocks allocated: 290844143616
 referenced 290844143616

请您引导我到这里好吗?如何修复文件系统?btfrs check警告的手册页反对使用repair命令。

答案1

你有备份吗?如果不,现在做一个。它显然不会包括损坏的数据,但只丢失这些数据比丢失所有数据要好。

一旦有了备份,只需在修复模式下运行检查命令即可。它可能修理东西。如果是这样,那么你就没事了。如果没有,或者情况变得更糟,只需删除该卷并从备份中恢复即可。根据过去的经验,如果您使用的是最新版本的 btrfs-progs(撰写本答案时当前最新版本是 6.0.2),修复模式可能至少会让文件系统进入一致状态(尽管您可能会丢失那些损坏的目录)。

无论哪种情况,您都应该首先调查一下导致此问题的原因。

相关内容