Recently, I ran into a problem with an old SSD formatted with btrfs. The filesystem refused to mount. Checking dmesg
I had an error stating that "the device total_bytes should be at most NUMBER1 but found NUBMER2"
, where NUMBER1 is less than NUMBER2.
The solution is to use the relatively new fix-device-size
feature in btrfs rescue
. This was added sometime after 2022, likely in Linux 6.3 (the patch to add this feature was submitted in the kernel developer mailing list in mid-2022). At the moment, I can confirm that 6.4.13 has this feature. Syntax wise, the command is:
btrfs rescue fix-device-size <device>
Just replace <device> with the /dev/ path to the device you are having issues mounting due to the size missmatch. This should work for most cases where the total_bytes for the device is only ‘slightly’ larger than the actual device size.
-John Havlik