Home / Alt manpages / probe-bcache(8)

  • probe-bcache(8)
  • Admin command
  • linux

Probe a bcache Device Safely with probe-bcache

probe-bcache tells you, read-only, whether a block device carries a bcache superblock, and in the exact shape a udev rule expects. This guide uses bcache-tools 1.0.8-5build1, where the helper lives at /usr/lib/udev/probe-bcache; the package's manpage calls it probe-bcache because that is the name udev gives it in its own execution environment. Budget ten minutes.

  • You need: an existing block device to inspect and enough permission to open it read-only.
  • Untouched by this guide: nothing gets formatted, registered, mounted or detached. Check a device path twice before you use it anyway.

1. Confirm the installed helper and package

Work out which file you are actually about to run. This is read-only and needs no elevated privileges:

$ dpkg-query -W -f='${Package} ${Version}\n' bcache-tools
bcache-tools 1.0.8-5build1
$ ls -l /usr/lib/udev/probe-bcache
-rwxr-xr-x 1 root root ... /usr/lib/udev/probe-bcache

command -v probe-bcache will not necessarily find it on this package, so calling the installed path directly keeps the example unambiguous. Inside a udev rule the helper runs as an imported program, not as something you would type at a prompt.

Checkpoint

If the file is missing, stop and repair the package before probing anything. Do not download a replacement binary or reach for a different helper as a substitute.

2. Choose the device without touching it

List block devices and their types before you pick a path:

$ lsblk -o NAME,PATH,TYPE,SIZE,FSTYPE,UUID,MOUNTPOINTS
NAME   PATH       TYPE  SIZE FSTYPE UUID                                 MOUNTPOINTS
vda    /dev/vda   disk   ...
|-vda1 /dev/vda1  part   ... ext4   ...                                  /
vdb    /dev/vdb   disk   ...

Swap /dev/DEVICE below for the block device you actually mean to inspect. The helper opens that path read-only and checks the bcache superblock location, but it is still a privileged storage operation on many installs, so use sudo for just this one command if your account cannot open the device:

$ DEVICE=/dev/DEVICE
$ sudo /usr/lib/udev/probe-bcache "$DEVICE"

A matching device prints one line with its UUID and the type bcache, in the plain human-readable form:

<uuid>: UUID="" TYPE="bcache"

The UUID on a real device is what you compare against your inventory. That empty UUID field is part of the documented output for this non-udev format; it is not a sign the bcache UUID is missing.

3. Treat silence as a result, not a failure

For a device that is not bcache-formatted, the helper normally prints nothing at all, and it still returns exit status zero when it cannot identify a candidate. So check both the output and the context together:

$ sudo /usr/lib/udev/probe-bcache "$DEVICE" > /tmp/probe-bcache.out
$ status=$?
$ test ! -s /tmp/probe-bcache.out && echo 'no bcache signature reported'
no bcache signature reported
$ printf 'exit status: %s\n' "$status"
exit status: 0

An empty result only means this run did not report a bcache signature. It does not prove the device is unused, safe to overwrite, or ready for a fresh bcache layout.

Warning

Do not follow a silent probe with make-bcache unless you have separately confirmed the device, its backups and the intended destructive operation. You can clean up the temporary file with rm -- /tmp/probe-bcache.out; it only ever held the command's output.

4. Request udev-style properties

Reach for -o udev when another udev rule is going to consume the result as IMPORT{program}. The only documented value for the output option is the literal word udev:

$ sudo /usr/lib/udev/probe-bcache -o udev "$DEVICE"
ID_FS_UUID=<uuid>
ID_FS_UUID_ENC=<uuid>
ID_FS_TYPE=bcache

These properties let udev create a UUID symlink. The installed bcache rule imports this form and checks ID_FS_TYPE before doing anything further; if the probe stays silent, the rule simply has no bcache type to act on. Keep the option and its value glued together: -o udev is not a general reporting mode.

Nothing here persists. The command reads the path and exits. If you are testing a udev rule you wrote yourself, reload and trigger rules only through your normal change-control process; that is a separate, riskier operation from probing and can generate device events that other rules pick up too.

5. Diagnose the common traps

A missing or unreadable path can also produce no output at all. Check the path and permissions before you read silence as a confirmed non-bcache result:

$ readlink -f "$DEVICE"
/dev/DEVICE
$ sudo test -r "$DEVICE"; printf 'read check: %s\n' "$?"
read check: 0

A typo in the output format is a different failure. The helper rejects anything except udev:

$ sudo /usr/lib/udev/probe-bcache -o json "$DEVICE"
Invalid output format json
$ printf 'exit status: %s\n' "$?"
exit status: 1

Do not bolt on flags borrowed from a different storage tool. The manpage documents exactly one option, -o udev, plus a device operand. If you need a fuller superblock report, reach for a tool built for that job, such as bcache-super-show, and keep its device argument just as explicit.

Done means

  • Confirmed the package version and helper path before running anything.
  • Picked the target with lsblk and used the exact device path.
  • Know a match prints a bcache UUID and type.
  • Know a non-match can be silent with exit status zero.
  • Used -o udev only when a udev import will consume the properties.
  • Made no change to the device or any persistent bcache configuration.