I've tried echoing to detach and stop. The device will remove itself, but will show up again on reboot. One time on reboot, it restored the mdadm raid I had as a backing device!
The other time I disabled the ramdrive that it was paired with, did a detach. And /dev/bcache0 came back up again after reboot.
There is no unregister under
/sys/fs/block/bcache
I've also looked in /sys/fs/bcache…
/sys/block/md0/md0p1/bcache
for this non existent unregister.
only register and register-quiet
I even uninstalled bcache-tools, and /dev/bcache0 still shows up after reboot and is caching /dev/md0!
Best Answer
If you want to permanently destroy the bcache volume, you need to wipe the bcache superblock from the underlying device. This operation is not exposed through the sysfs interface. So:
Stop the bcache device as usual with
echo 1 > /sys/block/<device>/bcache/stop
. On newer kernels this may fail with "Permission denied". In such a case, you would need to stop the device by its UUID as explained here:Wipe the superblock with
head -c 1M /dev/zero > /dev/<device>
. (If you have a sufficiently new version ofutil-linux
, you can usewipefs
instead, which is more precise in wiping the bcache signature:wipefs -a /dev/<device>
.) Obviously, you need to be careful to select the right device because this is a destructive operation that will wipe the header of the device. Take note that you will no longer have access to any data in the bcache volume!