如果您的btrfs驱动器具有子卷,则需要将其他-r <subvol-id>
选项传递给btrfs restore
。不幸的是,那里的脚本(如发布的一个user414471(http://oelkers.de/tips/undeleteBtrfs.sh))没有选择权,但是可以对此进行调整。
如果要手动执行此操作,则需要使用以下方法获取正确的subvol-id:
# mount /dev/sdXY /mnt/blah
# btrfs subvolume list /mnt/blah
# umount /mnt/blah
或者选择:
# btrfs restore -l /dev/sdXY | grep ROOT_ITEM
之后,您使用btrfs-find-root
来获取要还原到的块号(通常是在当前根数最大的块号之前的那个)。为此,您需要首先将默认子卷设置为要还原文件的子卷(然后再还原此更改):
# mount /dev/sdXY /mnt/blah
# btrfs subvolume set-default <subvol-id> /mnt/blah
# umount /mnt/blah
# btrfs-find-root /dev/sdXY
Well block 4321280 seems great, but generation doesn't match, have=400760, want=400984 level 0
...
Well block 9928704 seems great, but generation doesn't match, have=400764, want=400984 level 1
Well block 1094836224 seems great, but generation doesn't match, have=400983, want=400984 level 1
Found tree root at 1095270400 gen 400984 level 1
您最终可以使用btrfs restore
with -r <subvol-id>
进行恢复(--dry-run
如果需要,可以首先使用参数):
# btrfs restore -r <subvol-id> -t 9928704 -v --path-regex '^/(|dir1(|/dir2(|/dir3(|/.*))))$' /dev/sdXY /tmp/recovery
有关所有这些的更多信息,请参见:https:
//btrfs.wiki.kernel.org/index.php/Restore