Understanding the present, shaping the future.

Search
LA ERA · Tech
Technology

Developer Successfully Recovers Data from Severely Corrupted 12TB Btrfs Storage Pool

A developer has successfully salvaged data from a 12TB Btrfs storage pool severely corrupted by an unexpected power outage, losing only 0.00016% of the data by building 14 custom recovery tools.

Alex Chen

2 min read

Developer Successfully Recovers Data from Severely Corrupted 12TB Btrfs Storage Pool
Data recovery process on hardware

A developer recently shared a detailed post-mortem with the Btrfs file system community, documenting how they recovered nearly 4.6TB of data from a storage pool that had become trapped in a fatal corruption loop. The pool, consisting of three devices, suffered extensive damage to its extent and free space trees following a sudden power failure—damage that standard native repair commands were unable to resolve.

When the developer attempted to use the standard `btrfs check --repair` command, the process became stuck in a commit loop that repeated over 46,000 times without making any progress. Even worse, the process began overwriting backup roots, effectively destroying any chance of rolling the system back to its pre-crash state.

To save the data, the developer wrote 14 custom C-based tools leveraging the Btrfs internal API. Ultimately, after processing 4.59TB of data, only about 7.2MB of files were lost, resulting in a recovery success rate of over 99.999%.

Recommendations for Improving Btrfs-progs

Rather than treating this solely as a bug report, the developer submitted nine specific recommendations to the Btrfs-progs development team to prevent similar issues in the future. These include adding progress detection to `btrfs check --repair` to trigger an automatic termination when an infinite loop is detected, thereby preventing the total destruction of backup data.

Furthermore, the suggestions include optimizing the `btrfs rescue` toolkit by introducing subcommands like `rebuild-extent-tree` and `clean-orphan-inodes`. If integrated into the official release, these tools would significantly lower the barrier for other users facing similar storage corruption scenarios.

The developer has made the source code for all custom tools and the full incident report publicly available on GitHub. They emphasized that these recommendations were born from hands-on recovery experience, stating, "If any of these observations or suggestions are worth pursuing, I would be more than happy to expand on the analysis and provide further log evidence."

The storage pool is now back in normal operation. This case not only provides a valuable reference for extreme recovery scenarios in Btrfs but also offers the open-source community new tools for handling complex file system disasters.