[SOLVED] BTRFS filesystem corrupted. help needed

maybe. im looking through the copies i managed to make and it seems one very important file is corrupt. its a VM image that contains my webserver.
already tried testdisk with it, it was no help.

I’m going to go out on a limb and assume you have no btrfs snapshots?


This sort of filesystem failure is common with BTRFS on power outages. I don’t intend this as belittling or anything, just recommending that in the future, it might be wise to choose a different FS.

4 Likes

i have a snapshot from april, which is so old its basically useless.
btrfs restore managed to get me a copy of everything but my VM image.

Take the snapshot from april, pull the VM image.

Take the webserver backups (or an additional copy of the data), restore it over the old image?

That’s how I’d do it.

The other thing you could do is try to pull what you can from the disk image and see if you get the critical parts.

1 Like

so… all my backups of the webserver are also on the VMs image.

So take the image and try to photorec it.

If you losetup the image, you should be able to operate on the partitions.

2 Likes

this is what I would do as well

2 Likes

here’s what i am going to do (on the image i made of my ssd):
i am going to try and use “btrfs receive” to revert to my april backup. then, if that works, i will write the files i got from “btrfs restore” over the restored backup (using “cp -vr”). this should make an image with the intact partition table and btrfs trees from april, but the files will all be as they were when i used btrfs restore.
if this plan works, i will then repeat the process on the actual SSD.

i will report my results in this thread.

1 Like

Sounds like a workable plan, but before you restore, copy that in case theres something corrupt. Old files are probably better than no files I’m guessing.

1 Like

i may have a problem here: “btrfs receive” wont work on my corrupted partition. because the partition can only mount read-only.

do you have a spare drive to ‘receive’ to?

1 Like

i do not.

well you have the original image still that is unmodified right?

could just wipe it and start over that way

1 Like

reformat the btrfs partition?
that might work. but how can i do that while preserving all UUIDs and my BTRFS settings? (like CoW rules and stuff)

if the UUID changes, my entire bootloader and fstab would need rewritten.

the loss of my BTRFS settings would cause catastrophic instability. im not confident in my ability to remember exactly what everything is supposed to be.

I dont think theres any way to avoid the uuid change on a format. I’m not that hip on btrfs enough to help unfortunately.

1 Like

if i suceed in recreating my system on the looped image, would it be a better idea to dd the image to the ssd as opposed to using cp -vr to try and recreate my system again?

In theory it shouldnt matter

I’d probably use dd myself though

1 Like

What I did recently was attached a live dvd iso of a distro to my vm image and then booted into recovery mode where I mounted my volume and then I just copied my data over to my NAS and then rebuilt my sever.

On hardware that lies about cache flushes.

That includes a lot of SSDs.

  • The best ones have full battery or capacitor power backup.
  • The next best, like Samsung I believe, will always revert to a consistent point in time so at least there aren’t block writes from the future on disk.
  • The regular type will at least keep their SSD FTL metadata internally consistent although the user’s data won’t be necessarily in order. This is what happened to you.
  • The worst type may not exist any more but were around in 2012. A power loss during SSD write could result in corruption of all data on the drive. The only way to recover to was Secure Erase the entire drive.
    (The 80 GB FusionIO drive I had (much like NVMe is now) was great but on power-loss it had to do a recovery scan to rebuilt its FTL. Took over five minutes.)

so i reformatted the btrfs partition using mkfs.btrfs and then i copied the files i got from btrfs restore to the new partition, then i tried booting my main system.
it fails for some unknown reason. the kernel panics during boot and the panic data scrolls way off screen. making it impossible for me to see why my kernel panicked.