Linux – Cannot attach cache device to backing device

arch linuxbcachelvmssd

I have an LVM and I wanted to use bcache to cache one of its LVs. (Yes, I know I could use lvmcache, but I was having issues booting and I gave up using it.)

First, I used blocks to convert the LV to a bcache backing device (this seemed to actually work!):

blocks to-bcache /dev/my_vg/my_lv

I created a caching device on my SSD:

make-bcache --block 4k --bucket 2M -C /dev/sdc4

I then attempted to attach the cache to the backing device:

bcache-super-show /dev/sdc4 | grep cset.uuid
echo 'above_uuid' > /sys/block/bcache0/bcache/attach

I then rebooted my machine (after adding /dev/bcache0 to /etc/fstab) and realized that the cache wasn't running.

# cat /sys/block/bcache0/bcache/state
no cache

# bcache-super-show /dev/my_vg/my_lv | grep cache_state
dev.data.cache_state    0 [detached]

Am I missing something? Is there another command I need to use to enable caching?

Why does bcache not like my cache device and not letting me attach it to my backing device? Did I use the wrong values for --block and --bucket?

Best Answer

I managed to fix this by re-creating the superblock on /dev/sdc4. Looks like the --block 4k --bucket 2M was incorrect and that's why the cache device wasn't attaching.

I cleared the superblock, then ran:

make-bcache -C /dev/sdc4

Now when I did:

echo 'uuid' > /sys/block/bcache0/bcache/attach

it worked!

Related Question