How to revert bcache device to regular device

Greg Michalec picture Greg Michalec · Apr 2, 2014 · Viewed 8.8k times · Source

I have a 20 gb SSD device on my laptop that i decided to try bcache on. It seemed to work, but for some time now, I've been getting an error on boot:

error on 0f3bbb55-6839-4ed6-8127-7976a969f726: corrupted btree at bucket 17571, block 483, 61 keys, disabling caching

I figure I could try and repair this, but I've decided I'm probably better off just disabling bcache - I don't know enough about this to risk losing data/hair if something breaks, and I think I'd be better off using the partition as swap for faster hibernating.

My question is, how do I safely stop using bcache on the device without reformatting the backing device?

I am using /dev/sda7 as my backing device, and /dev/sdb2 as the caching device (/dev/sdb1 is root).

If it matters, I'm running Ubuntu 14.04 with kernel 3.13.0-21-generic.

Update: I am essentially looking for a solution that reverts the changes made by make-bcache -B. FWIW, I ended up "solving" this by moving everything to a new partition and deleting the old (see comment below), but I'll leave this question up in case someone has an actual solution.

Answer

STRML picture STRML · Jul 6, 2017

I had a time-sensitive issue with this recently and the following text saved my bacon:

D) Recovering data without bcache:

If bcache is not available in the kernel, a filesystem on the backing device is still available at an 8KiB offset. So either via a loopdev of the backing device created with --offset 8K, or any value defined by --data-offset when you originally formatted bcache with make-bcache.

For example: losetup -o 8192 /dev/loop0 /dev/your_bcache_backing_dev

From https://www.kernel.org/doc/Documentation/bcache.txt.

This has the added benefit of not modifying the partition table on the drive, so you can copy some data out and potentially remount it back to its original host.