运行后btrfs scrub
,可以检测到损坏的文件。为了确定无法纠正的文件,我们可以尝试读取磁盘上的每个文件:
sudo find / -type f -exec cp -v {} /dev/null \; 2> corrupted-files.txt
该命令的输出满足需要。但是需要几个小时才能完成。
Arch Linux wiki 建议使用以下命令来确定损坏的文件:
sudo journalctl --output cat | grep 'BTRFS .* i/o error' | sort | uniq
它可以快速获取结果。但是,文件路径是相对于它们的子卷路径的,因此对于从备份中修复文件非常宝贵:
BTRFS warning (device dm-2): i/o error at logical 69945753600 on dev /dev/mapper/zeytin-root, sector 142920640, root 636, inode 172280, offset 238682112, length 4096, links 1 (path: home/aea/couchdb/couchdb/data/shards/60000000-7fffffff/client2.1533443496.couch)
BTRFS warning (device dm-2): i/o error at logical 70045958144 on dev /dev/mapper/zeytin-root, sector 143116352, root 422, inode 172296, offset 307662848, length 4096, links 1 (path: home/aea/couchdb/couchdb/data/shards/e0000000-ffffffff/client2.1533443496.couch)
BTRFS warning (device dm-2): i/o error at logical 70045958144 on dev /dev/mapper/zeytin-root, sector 143116352, root 636, inode 172296, offset 307662848, length 4096, links 1 (path: home/aea/couchdb/couchdb/data/shards/e0000000-ffffffff/client2.1533443496.couch)
BTRFS warning (device dm-2): i/o error at logical 70138376192 on dev /dev/mapper/zeytin-root, sector 143296856, root 423, inode 100548, offset 688631808, length 4096, links 1 (path: var/log/auth.log)
BTRFS warning (device dm-2): i/o error at logical 70138425344 on dev /dev/mapper/zeytin-root, sector 143296952, root 423, inode 100548, offset 688644096, length 4096, links 1 (path: var/log/auth.log)
BTRFS warning (device dm-2): i/o error at logical 70138441728 on dev /dev/mapper/zeytin-root, sector 143296984, root 423, inode 100548, offset 688648192, length 4096, links 1 (path: var/log/auth.log)
BTRFS warning (device dm-2): i/o error at logical 70138449920 on dev /dev/mapper/zeytin-root, sector 143297000, root 419, inode 818783, offset 95145984, length 4096, links 1 (path: var/log/daemon.log)
BTRFS warning (device dm-2): i/o error at logical 70138564608 on dev /dev/mapper/zeytin-root, sector 143297224, root 419, inode 818783, offset 95154176, length 4096, links 1 (path: var/log/daemon.log)
BTRFS warning (device dm-2): i/o error at logical 70138884096 on dev /dev/mapper/zeytin-root, sector 143297848, root 419, inode 818783, offset 95174656, length 4096, links 1 (path: var/log/daemon.log)
有没有办法通过使用值来确定子卷路径sector XXXXXXX, root XXX, inode XXXXXXX, offset XXXXXXXX
?
这里的
root XXX
值是子卷的根 ID。所以对应子卷的路径可以由下式确定:进行内部连接的有用脚本如下:
输出:
因此,整体工具get-corrupted-files.sh变为: