I have a computer running Debian 10 Buster (testing), kernel version:
Linux (none) 4.14.0-3-amd64 #1 SMP Debian 4.14.13-1 (2018-01-14) x86_64 GNU/Linux
The root filesystem is Btrfs with a single device.
Recently, I encountered the issue where the filesystem became mis-balanced, and I followed the steps on Mark's Blog to rebalance things. My system was so full, I had to follow the steps under "Balance cannot run because the filesystem is full", including creating a 3GB file with
dd and adding it to the btrfs filesystem as a loop device. This allowed it to be balanced successfully.
However, I forgot to remove the loop device before rebooting. Upon reboot, I am thrown into an initramfs prompt with the errors:
BTRFS error: failed to read chunk tree: -5 BTRFS error: open_ctree failed
btrfs filesystem show:
bytenr mismatch, want=167954300928 Label: none uuid: <uuid> Total devices 2 FS bytes used 91.58GiB devid 1 size 151.03GiB used 111.04GiB path /path/to/device *** Some devices missing
btrfs check returns:
bytenr mismatch, want=167954300928, have=0
Trying to partially mount the filesystem in order to remove the missing loopback device,
mount -o degraded,ro /path/to/device /mnt returns:
BTRFS error: failed to read block groups: -5 BTRFS error: open_ctree failed
The only other info in
dmesg is it complaining about the missing device with id 2.
btrfs rescue chunk-recover returns:
Scanning: DONE in dev0 open with broken chunk error Chunk tree recovery failed
Trying to restore from the filesystem
btrfs restore /path/to/device /mnt results in:
bytenr mismatch, want=167954300928, have 0 Could not open root, trying backup super bytenr mismatch, want=167954300928, have 0 Could not open root, trying backup super ERROR: superblock bytenr 274877906944 is larger than device size 162164375552 Could not open root, trying backup super
The situation seems similar to this forum post, where a new device was added briefly and then remove, but it is not exactly the same scenario.
My question is:
- What steps can I take to recover the system in its current state (perhaps by removing the missing loopback device), or
- If not possible, how can I recover some of the files?
Most of the system is backed up, but some important files were created between daily backup cycles and will be lost if they cannot be restored here.