BTRFS-RESCUE(8)
โจ NAME โจ
btrfs-rescue โ recover a damaged btrfs filesystem ๐ฉน๐
๐ฆ SYNOPSIS ๐ฆ
btrfs rescue <subcommand> <args>
๐ธ DESCRIPTION ๐ธ
okay so bestie, this is a lil collection of commands whose whole personality is fixing one specific problem. They are not necessarily suited for btrfs-check, so don't go swapping them around like they're interchangeable, iykyk. ๐
โโ๏ธ
Note: every single one of these subcommands cannot handle an ongoing replace/balance. Finish it or cancel it before you run this command, no cap. Otherwise it's giving chaos. ๐
๐ SUBCOMMAND ๐
๐ง chunk-recover [options] <device>
Recover the chunk tree by scanning the devices. It literally just goes and scans. Lowkey heroic, highkey slow.
โญ Options
-yโ assume an answer of yes to all questions. ๐-hโ help.-vโ (deprecated) alias for global-voption. It's giving legacy, don't come for me.
Note: since chunk-recover will scan the whole device, it will be very slow, especially if you run it on a large device. Like, go make a snack. ๐
๐ง fix-device-size <device>
Fixes device size and super block total bytes values that do not match. The mismatch is not the vibe.
Kernel 4.11 started checking the device size more strictly, and this might mismatch the stored value of total bytes. See the exact error message below. Newer kernels will straight up refuse to mount the filesystem where the values don't match. Good news: this error is not fatal and it can be fixed. This command will fix the device size values if possible. ๐ซถ
BTRFS error (device sdb): super_total_bytes 92017859088384 mismatch with fs_devices total_rw_bytes 92017859094528
The mismatch may also exhibit as a kernel warning:
WARNING: CPU: 3 PID: 439 at fs/btrfs/ctree.h:1559 btrfs_update_device+0x1c5/0x1d0 [btrfs]
๐ง fix-data-checksum <device>
Selectively fix data checksum mismatch. The selective girlie of the rescue lineup. โจ
There is a long existing problem: if a user space program is doing direct IO and modifies the buffer before the write back finished, it can lead to data checksum mismatches. Smh.
This problem is known but was not fixed until upstream release v6.15 (backported to older kernels). So it is possible to hit false data checksum mismatch for any long running btrfs. ๐ญ
In that case this program can be utilized to repair such problem. Slay.
โญ Options
-r|--readonlyโ readonly mode, only scan for and report data checksum mismatches, do not repair. Just looking respectfully. ๐-i|--interactiveโ interactive mode, ask for how to repair, ignore the errors by default.-m|--mirror <num>โ use specified mirror to update the checksum item for all corrupted blocks.
The value must be >= 1, and if the corrupted block has fewer mirrors than the value, the mirror number will be num % (num_mirrors + 1). Yes, that's the math, write it down. ๐
๐ง clear-ino-cache <device>
Remove leftover items pertaining to the deprecated inode number cache feature.
That feature, enabled by mount option inode_cache, has been completely removed in the 5.11 kernel. It's gone, bestie. RIP bozo. ๐ชฆ
๐ง clear-space-cache <v1|v2> <device>
Completely remove the on-disk data of free space cache of the given version. You gotta tell it v1 or v2, it doesn't read minds. ๐ฎ
Especially for v1 free space cache: the clear_cache mount option would only remove the cache for updated block groups, and the remaining stuff would not be removed. So this command exists to manually clear the free space cache. Periodt. ๐
๐ง clear-uuid-tree <device>
Clear the UUID tree so that the kernel can regenerate it at the next read-write mount. Iconic behaviour, honestly. ๐
Since kernel v4.16 there are more sanity checks performed, and sometimes non-critical trees like the UUID tree can cause problems and reject the mount. In such a case, clearing the UUID tree may make the filesystem mountable again without much risk, since it's built from other trees. See also mount option rescan_uuid_tree (in btrfs-man5).
๐ง super-recover [options] <device>
Recover bad superblocks from good copies. The good copies said "not on my watch". ๐ซก
โญ Options
-yโ assume an answer of yes to all questions.-vโ (deprecated) alias for global-voption.
๐ง zero-log <device>
Clear the filesystem log tree. ๐งน
This command will clear the filesystem log tree. This may fix a specific set of problems when the filesystem mount fails during log replay. See below for sample stack traces that may show up in the system log.
Note: clearing the log may lead to loss of changes that were made since the last transaction commit. This may be up to 30 seconds (the default commit period) or less if the commit was implied by other filesystem activity. So like, know what you're doing. ๐
One can determine whether zero-log is needed according to the kernel backtrace:
? replay_one_dir_item+0xb5/0xb5 [btrfs]
? walk_log_tree+0x9c/0x19d [btrfs]
? btrfs_read_fs_root_no_radix+0x169/0x1a1 [btrfs]
? btrfs_recover_log_trees+0x195/0x29c [btrfs]
? replay_one_dir_item+0xb5/0xb5 [btrfs]
? btree_read_extent_buffer_pages+0x76/0xbc [btrfs]
? open_ctree+0xff6/0x132c [btrfs]
If the errors are like the ones above, then zero-log should be used to clear the log and the filesystem may be mounted normally again. The keywords to look for are 'open_ctree', which says that it's during mount, and function names that contain replay, recover or log_tree. ๐โจ
๐ซ EXIT STATUS ๐ซ
btrfs rescue returns a zero exit status if it succeeds. Non zero is returned in case of failure. It's giving pass/fail, no in-between. ๐ฏ
๐ AVAILABILITY ๐
btrfs is part of btrfs-progs. Please refer to the documentation at <https://btrfs.readthedocs.io>. Go read it, bestie, it's free. ๐
๐ฅ SEE ALSO ๐ฅ
and that's the whole page, you ate that fr fr ๐ this was btrfs-progs version 7.3, dated Oct 24, 2026 โ go forth and rescue those filesystems, main character. ๐๐ฆโจ
๐ฆ where this page comes from
- arch rolling: btrfs-progs 7.3-1 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms