Skip to content
vast-cow's blog
Go back

Recreating a bcache Backing Device with a New Block Size (Cache Device Not Used)

Edit page

This article describes how to change the bcache block size when you are operating without a cache device (the cache device has already been detached, and you will not add one during re-creation). Because bcache block size is defined at creation time, the practical approach is to recreate the bcache backing device with the desired parameters.

Important Notes (Read First)

Prerequisites

Step 1 — Record the Current Data Offset

Read the existing bcache superblock on the backing device and record the data offset (commonly shown as dev.data.first_sector or an equivalent field):

sudo bcache-super-show /dev/sdb1

Make a note of the value that corresponds to the data start offset. You will reuse it as <OFFSET> in Step 4.

Step 2 — Stop Using the bcache Device Cleanly

2.1 Unmount (and stop upper layers)

If /dev/bcache0 (or similar) is mounted, unmount it:

mount | grep bcache
sudo umount /dev/bcache0

If you use LVM, dm-crypt, MD RAID, etc. on top of /dev/bcache0, stop those layers first.

2.2 Stop the bcache device

Stop the bcache device via sysfs (example for /dev/bcache0):

echo 1 | sudo tee /sys/block/bcache0/bcache/stop

If this fails, an upper layer is still holding the device open. Re-check mounts and dependent mappings.

Step 3 — Remove Existing bcache Signatures from the Backing Device

Wipe the bcache signatures from the backing device:

sudo wipefs -a /dev/sdb1

This removes filesystem/RAID/bcache signatures that would otherwise conflict with re-creation.

Step 4 — Recreate bcache on the Backing Device with a New Block Size

Now recreate the backing device bcache metadata, specifying:

sudo make-bcache --block 4k --data-offset <OFFSET> -B /dev/sdb1

Notes:

Step 5 — Verify the New bcache Device

Confirm that /dev/bcache* has been created:

ls -l /dev/bcache*
lsblk -f | grep -E 'bcache|sdb1'

Check state (example for /dev/bcache0):

cat /sys/block/bcache0/bcache/state

At this point, you can create a filesystem (if appropriate) and mount it, or reintroduce your higher layers (LVM, dm-crypt, etc.) as required by your environment.

Operational Consideration (Running Without a Cache Device)

If you do not add a cache device, bcache effectively behaves as a pass-through block device wrapper. This can still be useful if you plan to attach cache later or want consistent device naming/management, but you should be aware that you are not gaining caching benefits until a cache set is attached.

Common Failure Modes and How to Avoid Them

Summary

To change bcache block size without using a cache device, you:

  1. Record the data offset from bcache-super-show.
  2. Cleanly stop usage and stop the bcache device.
  3. Remove signatures with wipefs -a.
  4. Recreate bcache backing only using make-bcache --block <new> --data-offset <old> -B.
  5. Verify /dev/bcache* and proceed with your storage stack.

Edit page
Share this post:

Comments


Previous Post
Docker Wrapper Command for Interactive, Host-Networked Runs with Local Home and Working Directory Mounts
Next Post
Container Definitions to Run OpenWebUI (Ubuntu 24.04 / Dockerfile & Singularity)