0

I installed BCACHE on a m3.large EC2 machine with instance SSD as cache disk and the elastic volume as backing disk. But once I reboot the EC2 machine BCACHE was gone and i cannot access the disk used to be backing drive again.

If I detach SSD(run BCACHE without cache) before reboot then after reboot v will still be there and i can attach SSD to it again.

The question is how do I recover BCACHE from a EC2 unclean reboot.

1 Answers1

0

You should try to unregister your cache devices on shutdown/reboot and re-create and attach them on boot, if not, It will cause you pain every time you decide to shut down your instance. There is a script that automates the startup and shutdown in the first

For the unclean case (forced stop or sudden instance crash) you need to

echo 1 > /sys/block/[Backing Device (EBS)]/bcache/running

Example: echo 1 > /sys/block/xvdf/bcache/running

Or if you use writeback and you assume your backing device will always boot healthy you can just add that line into your boot sequence (before your volume is mounted)

References:

rralcala
  • 158
  • 3
  • thanks. but from the past experience, the bcache directory doesn't exit after unclean reboot. – user3869212 Aug 21 '14 at 14:57
  • I was talking about /sys/block/xvdX/bcache/running (the ebs block device itself), after doing that your bcache directory will appear. – rralcala Aug 23 '14 at 16:19
  • I tried a unclean reboot again and I was able to register the cache disk on /sys/fs/bcache/register again and recover bcache. The directory you mention /sys/block/bcaching Device/bcache/running is not there. Thanks anyway. – user3869212 Sep 16 '14 at 19:19