Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fix btrfs "btrfs parent transid verify failed on ..."

btrfs fi show displays all btrfs file system but also a lot of errors like:

parent transid verify failed on 109973766144 wanted 1823 found 1821

The filesystem can still be unmounted and remounted.

like image 851
Per Avatar asked Sep 28 '17 15:09

Per


4 Answers

Beware of btrfs-zero-log

btrfs-zero-log documentation states clearly that it's not a generic tool to use:

btrfs-zero-log is not a general fix-everything tool, despite what many people believe and state around the internet. You generally don't need to use it.

There is only a use case for this tools: when you have BTRFS: failed to read log tree logs.

Fixing parent transid verify failed errors with usebackuproot

The 3.2 Linux kernel introduced in January 2012 the recovery option. Then, in May 2016 with the 4.6 version, it was superseded by usebackuproot. You can also see the commit if you're interested.

The documentation explain clearly what it does:

usebackuproot
nousebackuproot

    (since: 4.6, default: off)

    Enable autorecovery attempts if a bad tree root is found at mount time.
    Currently this scans a backup list of several previous tree roots and
    tries to use the first readable. This can be used with read-only mounts as well.

    Note: This option has replaced recovery.

A note in the official FAQ section states that this is the right way to fix this "parent transid" error:

How do I recover from a "parent transid verify failed" error?

For example:

parent transid verify failed on 29360128 wanted 1486656 found 1486662

If the second two numbers (wanted 1486656 and found 1486662) are close together (within about 20 of each other), then mounting with

-o ro,usebackuproot

may help. If it's successful with a read-only mount, then try again without the ro option, for a read-write mount.

If the usebackuproot doesn't work, then the FS is basically unrecoverable in its current state with current tools. You should use btrfs restore to refresh your backups, and then restore from them.

Commands to use

These commands are just example of a failed btrfs disk on a Fedora installation. Replace /dev/sda2 with your device and /sysroot with your mount point

First try in read only mode:

mount -t btrfs -o ro,usebackuproot /dev/sda2 /sysroot

If that works, try again without the readonly command:

mount -t btrfs -o usebackuproot /dev/sda2 /sysroot

If this works, your should be able to boot your Linux.

like image 163
lifeisfoo Avatar answered Nov 15 '22 13:11

lifeisfoo


Surfing the web I found a lot of answers recommending to clear btrfs' internal log by using btrfs-zero-log. I thought btrfsck could help but eventually I discovered the official recommendation which is to first just start a btrfs scrub before taking other actions!

So just run btrfs scrub /path/to/mountpoint if you too can still mount your filesystem. And maybe it works like in my case.

like image 25
Per Avatar answered Nov 15 '22 11:11

Per


I faced a similar situation:

  1. logs were full with parent transid verify failed on 109973766144 wanted 1823 found 1821
  2. dmesg was full with BTRFS info (device sda): no csum found for inode 16485445 start 73728 and BTRFS warning (device sda): csum failed ino 16485465 off 36864 csum 2268363541 expected csum 0

configuration of my system

  1. NAS with 3 nfs shares
  2. BTRFS file system
  3. Rockstor Operating System

  4. RAID 10 setup

additional information

  1. the btrfs mount became read only

  2. btrfs-scrub failed with ERROR: scrubbing /dev/md124p2 failed for device id 1: ret=-1, errno=5

I solved it by deleting the nfs export ie. from /etc/export/ and then remounting the volumes and voila everything became ok

UPDATE 29 Jan 2018: after working for a few days it went back exactly to the same state

like image 31
coda Avatar answered Nov 15 '22 11:11

coda


First run this command:

sudo btrfs rescue super-recover -v /dev/sda2

If it tells you “All supers are valid, no need to recover”, you need to run the following command to clear the filesystem log tree:

sudo btrfs rescue zero-log /dev/sda2

Now you should be able to mount your Btrfs file system.

like image 2
W.M. Avatar answered Nov 15 '22 11:11

W.M.