How to return a bcache device to adjust regulare file system

I have a 20 gigabyte SSD device on my laptop and I decided to try bcache. It seemed to work, but for some time now I get an error message when loading:

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

I believe I can try and fix this, but I decided that I probably had better disable bcache - I donโ€™t know enough about it to risk losing data / hair if something breaks, and I think d is better to use section as a swap for faster sleep mode.

My question is: how can I safely stop using bcache on a device without reformatting the backup device?

I use / dev / sda 7 as my supporting device and / dev / sdb 2 as the caching device (/ dev / sdb1 is root).

If that matters, I am running Ubuntu 14.04 with the kernel 3.13.0-21-generic.

Update. I am essentially looking for a solution that returns the changes made by make-bcache -B. FWIW, I decided to "solve" this by moving everything to a new section and deleting the old one (see Comment below), but I will leave this question in case anyone has a real solution.

+6
source share
3 answers

Recently, I had a time-sensitive problem, and the following text saved my bacon:

D) Data recovery without bcache:

If bcache is not available in the kernel, the device-based file system is still available with an offset of 8KiB. This way, either through the loopdev of the supporting device created using --offset 8K, or any value specified by --data-offset when you originally formatted bcache using 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 disk, so you can copy some data and possibly remount it back to the original host.

+2
source

One solution is to disconnect the device from the cache and use it in no cache mode or through mode. To do this, run root :

 echo 1 > /sys/block/<device>/bcache/detach 

(where <device> is the cache backup device, /dev/sda7 in your case).

This will disconnect the backup device from the cache, so that the cache will no longer be used, but the disk will be available directly for all read and write operations. If your cache was not in a damaged state, this would also launch any dirty data from the cache back to the supporting device; in your damaged state you are probably out of luck.

You will still have to access the device through the /dev/bcache0/ interface, but caching will fail.

+1
source

It is not very difficult if you know the insides. I read from blocks to find out that to convert a normal partition to bcache it compresses the section a bit and then adds the bcache superblock there. Thus, the partition data remains. I did a test to find out that the bcache superblock has 8192 bytes:

 for i in {1..20}; do dd if=my_bcache_device skip=$i | file -; done 

So, to convert it back, just change the partition table so that it starts 8192 bytes later. With gdisk (or fdisk if you use MBR), delete the partition and then recreate it in a new place, and you will end :-) You can increase it later if you want (but I have not tried it).

Please note that if your bcache is dirty (and you can no longer use it), you will have to fsck your partition and mess with corrupted data. I was lucky that only a few files were corrupted after the fsck manual.

+1
source

All Articles