Home / Alt manpages / probe-bcache(8)

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

Probe a bcache Device Safely with probe-bcache

You will finish with a read-only check that tells you whether a block device has a bcache superblock, and with the exact output shape needed by a udev rule. This guide uses bcache-tools 1.0.8-5build1, where the helper is installed at /usr/lib/udev/probe-bcache. The package's manpage documents the command as probe-bcache because udev supplies that name in its own execution environment.

Allow about ten minutes. You need an existing block device to inspect and enough permission to open it read-only. The examples do not format, register, mount, detach or otherwise modify a device. Do not substitute a device path until you have checked it twice.

1. Confirm the installed helper and package

First, establish which file you are going to run. This is an ordinary, read-only check and does not need 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

On this package, probe-bcache is not necessarily found by command -v. Calling the installed path directly makes the example unambiguous. In a udev rule, the helper is invoked as an imported program rather than as a normal interactive command.

Checkpoint: if the file is missing, stop and repair the package installation before probing anything. Do not download a replacement binary or guess another helper.

2. Choose the device without changing it

List block devices and their types before selecting 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   ...

Replace /dev/DEVICE below with the block device you actually intend to inspect. The command opens that path read-only and checks the bcache superblock location. It is still a privileged storage inspection in many installations: if your account cannot open the device, use sudo for this command only.

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

A matching device produces a line containing its UUID and the type bcache, in the normal human-readable form:

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

The UUID shown by a real device is the value you should compare with other inventory information. The empty UUID field in this non-udev format is part of the helper's documented output; do not treat it as proof that the bcache UUID is missing.

3. Treat silence as a result, not a failure

For a device that is not identified as bcache-formatted, the helper normally prints nothing. Its implementation also returns status zero when it cannot identify a candidate, so check both output and context:

$ 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 means this invocation did not report a bcache signature. It does not prove that the path is unused, safe to overwrite, or suitable for a new bcache layout. Do not follow a silent probe with make-bcache unless you have separately confirmed the device, backups and the intended destructive operation. The temporary file above can be removed after inspection with rm -- /tmp/probe-bcache.out; it contains only the command output.

4. Request udev-style properties

Use -o udev when another udev rule will consume the result as IMPORT{program}. The only documented output format is the literal value 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 are intended to let udev create a UUID symlink. The installed bcache rule imports this form and then checks ID_FS_TYPE before continuing. If the probe is silent, the rule has no bcache type to act on. Keep the option and its value together: -o udev is not a request to print a general report.

There is no persistent state to undo from this command. It reads the path and exits. If you are testing a udev rule you wrote yourself, reload and trigger rules only within your normal change-control process; that is a separate operation from probing and may cause device events for other rules.

5. Diagnose the common traps

A missing or unreadable path may also result in no output. Check the path and permissions rather than interpreting silence as a confirmed non-bcache device:

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

A typo in the output format is different. The helper rejects values other than udev:

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

Do not add flags copied from another storage utility. The manpage exposes one option, -o udev, followed by a device operand. If you need a fuller superblock report, use a tool and manpage intended for that job, such as bcache-super-show, and keep its device argument equally explicit.

Done means

  • You confirmed the installed package version and helper path.
  • You selected the target with lsblk and used the exact device path.
  • You know that a match prints a bcache UUID and type.
  • You know that a non-match can be silent with status zero.
  • You used -o udev only when consuming properties as a udev import.
  • You made no change to the device or persistent bcache configuration.