Won't boot, kernel oops, failed mount, btrfs problems, btrfs-zero-log info

This is more of a how to/informative post in case anyone else runs into a kernel oops or something similar, like a power outage, that caused there btrfs partitions to no longer boot. Luckily in my case the only partition that is being affected is my home partition(knock on wood) but I have a live usb created for in case of emergency, regardless.

So I was doing something and I got a system bell alert, and decided to kill X(ctrl alt backspace) well basically I had to manually power off afterwards as I could not restart from console, and upon rebooting I got something like home.mount failed and a bunch of errors regarding log_tree, pretty similar to what youll see here on the btrfs wiki:

https://btrfs.wiki.kernel.org/articles/p/r/o/Problem_FAQ_68af.html

Well obviously I didn’t want to just erase everything and bite the bullet, so on the first page of google that wiki popped up and explained everything. Well, the biggest part of this is to inform you that you don’t have to lose everything, and this can also be done from the live usb, the instructions on the wiki page state:

You will need to build and run the btrfs-zero-log tool: get a recent copy of the user-space tools, and build them:

$ make
$ make btrfs-zero-log
$ sudo btrfs-zero-log /dev/sda1

Firstly, the link to the other wiki page is wrong, the correct link is: btrfs Wiki

Next you’ll find that after cloning btrfs-progs-unstable.git from multiple sources, it won’t build.

You’ll need these dependencies, which are the same on live cd/usb if you have to use that method(e2fsprogs may not be needed but I install it anyways, other distros may require it regardless:

libbuid-devel git e2fsprogs-dev gcc make - and any of the dependencies that go alone with them

so I had to find a working git repo, and masons normal repo is down, so I found this one:

git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs.git

the rest of the steps are pretty much the same as on the wiki page except you’ll see that there in no tmp branch so ignore this step:

git checkout(co) tmp

Next you’ll find it errors either when running make or when running make btrfs-zero-log but that is fine, afterrwards all you need to do is run

sudo btrfs-zero-log /dev/sda1

replacing your partition of course. It should exit with no alerts or errors and then you’re done, just reboot and thats that.

I have cloned btrfs-progs into / so whenever this happens(to me) I can just run btrfs-zero-log and reboot again, the wiki states you may lose a few seonds of data, if that. I’ll mirror the repo in a tar.gz later on incase the link goes down, as I spent hours finding a working link and then another hour figuring out that it wasn’t gonna work, so I finally gave up and tried that stable repo. Hope this helps someone and sorry for not posting the best ‘how to’.

I wanted to add that in my case the kernel oops was caused by deluge(bit torrent client) and I have yet to fix the problem but I do know what to avoid doing and how to resolve the issue, in case anyone was wondering.