Rate This Document
Findability
Accuracy
Completeness
Readability

"sdx device busy" Displayed When Creating Bcache on Ceph

Symptom

In a Ceph environment configured with bcache, reinstalling the operating environment may occasionally cause an error during bcache configuration, stating "make-bcache --wipe-bcache -B /dev/sdx -C /dev/nvmexx". The details are shown in the screenshot below:

Key Process and Cause Analysis

Residual bcache partition information on the drive is loaded by the system and can be checked using the lsblk command.

Conclusion and Solution

Perform the following steps to recover the drive:

  1. Perform detach and stop operations in the bcache folder under the sdb directory.
    echo 1 >/sys/block/sdb/bcache/detach
    echo 1 >/sys/block/sdb/bcache/stop
  2. Perform a dd write operation on the sdb drive.
    dd if=/dev/zero of=/dev/sdb count=2048 bs=1M
  3. Unregister the residual bcache under the /sys/fs/bcache/ directory.
    cd  /sys/fs/bcache/31040c7b-55f2-4170-bf77-d2e8b958e31a/
    echo 1 >  unregister

    In the corresponding bcache directory, perform an unregister operation.

  4. Reboot the server.

Script reference:

  • Perform detach, stop, and dd write operations on drives sda through sdh.
    for i in {0..7}
    do
            temp=`expr $i % 8 + 97`
            diskID=$(printf \\x`printf %x ${temp}`)
            echo 1 >/sys/block/sd${diskID}/bcache/detach
            echo 1 >/sys/block/sd${diskID}/bcache/stop
            dd if=/dev/zero of=/dev/sd${diskID} count=2048 bs=1M
    done
  • Perform the unregister operation on the /sys/fs/bcache/ directory across nodes ceph1 through ceph4.
    #!/bin/bash
    for n in {1..4}
    do
        echo "ceph$n"
        f=$(ssh ceph$n "ls /sys/fs/bcache/")
        for i in $f
        do
            ssh ceph$n "echo 1 > /sys/fs/bcache/$i/unregister"
        done
    done