5

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?

  • 1
    Did you register the hacking and caching devices? Registration and attachment are separate steps. evilpiepirate.org/git/linux-bcache.git/tree/Documentation/… – Emmanuel Rosa Apr 17 '17 at 23:25
  • If I do ls /sys/fs/bcache/, I see the cset.uuid for my cache drive (as well as register and register_quiet) and I can mount /dev/bcache0, so it looks like everything was registered. – Rocket Hazmat Apr 18 '17 at 16:44
  • 1
    Do you have a script to re-register the devices? You should only need to attach them once, but they need to be registered every time you boot. Arch Linux has a config file for this: wiki.archlinux.org/index.php/Bcache#Configuring – Emmanuel Rosa Apr 18 '17 at 21:06
  • If I try to (re-)register the devices, I see -bash: echo: write error: Invalid argument, which I think means they are already registered. – Rocket Hazmat Apr 25 '17 at 0:47
3

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!

2

I had the same problem:

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

caused the write error: Invalid argument.

Specifically, it was the --block 4k that caused the problem.

make-bcache --bucket 2M -C /dev/nvme0n1p1 

Worked perfectly.

  • 1
    Just had the same issue. Surprised the docs still haven't been updated – regomodo Jun 7 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.