1

I have accidentally configured my SSD as a backing device instead of a caching device. Simply trying either one of the following:

sudo make-bcache -C /dev/sdb1
sudo make-bcache -C /dev/sdb

Gives the errors:

Can't open dev /dev/sdb1: Device or resource busy
Can't open dev /dev/sdb: Device or resource busy

How does one rectify a situation like this?

Gerharddc
  • 325
  • 1
  • 4
  • 12

1 Answers1

2

You need to tell the kernel to close the bcache device before rerunning make-bcache on the underlying device.

To close a backing device:

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

To close a cache device:

echo 1 > /sys/block/<device>/bcache/set/unregister

(See the documentation for more details.)

So in your case, if you accidentally configured the /dev/sdb1 partition as a backing device, you can close it with

echo 1 > /sys/block/sdb/sdb1/bcache/stop

and then rerun make-bcache with the --wipe-bcache option to overwrite the previous setup:

make-bcache --wipe-bcache -C /dev/sdb1
Vincent Yu
  • 496
  • 4
  • 11
  • You can add the `-B`acking devs simultaneously. It saves a step later. You don't have to do all of that registering. And anyway - haven't the `bcache-tools` provided more direct options for this stuff yet? – mikeserv Jun 26 '15 at 03:48