I recently had a problem on my test box running btrfs where it would not boot up past the grub menu. I managed to boot off a live CD and found that I couldn’t mount the boot disk either and it gave the error:
mount: wrong fs type, bad option, bad superblock on /dev/sda1, or too many mounted file systems
Looking in dmesg I found this error over and over:
parent transid verify failed on 5413130240 wanted 22358 found 22337
It appears that the disk filesystem had become corrupted after a “power failure”. Running the fsck -t btfs /dev/sda1 returned no errors and found no problems.
It turns out the fsck tools bundled in ubuntu 11.04 (and even those downloadable from the btrfs website) weren’t able to fix this specific issue.
I did however manage to fix it by checking out a copy from btrfs-tools git repository and using the latest files from the lead developer’s git, even though his last change was some time back I guess this hadn’t been merged into the main tree.
So the fix
boot from the live cd cd ~ mkdir btrfs-tools cd btrfs-tools git clone git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs-unstable.git
Download the btrfs-select-super.c, disk-io-c and disk-io.h from the link above and drop them into the git cloned folder above.
cd into the cloned folder and run
./configure make all make btrfs-select-super chmod 750 ./btrfs-select-super ./btrfs-select-super -s 1 /dev/sda1
where “1” is the second superblock copy (zero being the default which has become corrupted) and /dev/sda1 the target disk/partition.
Once you’ve done this run ./btrfsck /dev/sda1 and reboot. If all is well your PC should now boot.
If that doesn’t work try superblock 2.
./btrfs-select-super -s 2 /dev/sda1
You might also like to try the patch in the mailing-list here and mount the filesystem as read-only. If it works this would let you get your data off at least.
Check out the new restore tool to recover files from the broken filesystem.