4

My Ubuntu 17.04 (64 bit) box has:

  • 1 x SSD (used for the OS)
  • 2 x HDD (used for data, such as /home and backups etc.)
  • 8GB RAM

If I shrink my SSD and create an empty partition for caching my HDD(s), is it possible to setup bcache without losing any existing data first?

The FAQ section of the bcache website says it is possible but does not demonstrate how.

Can I use bcache with an existing device, without reformatting?

There is a conversion step, which can often be done in place. The extra step comes from the need for a bcache specific superblock on the backing device - so that bcache can keep the devices in sync and so you can't accidentally mount and use the backing device without going through the bcache driver. Without any such superblock, you could accidentally use your device in non bcache mode making the cache invalid/corrupt without bcache knowing about it (if you were using bcache in writethrough mode) - or worse, if you were using it in writeback mode the filesystem on the backing device would appear to be completely corrupted.

The following tutorials require reformatting all drives involved first:

1 Answers1

0

The FAQ appears to have been updated, and now includes the following:

blocks is a tool to add a superblock at the start of a block device. There are several ways to accomplish this; blocks can convert LVM logical volumes, partitions that have some free space or a shrinkable filesystem before them, and LUKS encrypted volumes. blocks can also convert a device to LVM and then to bcache, which can be useful when a direct bcache conversion is impossible.

You can use blocks to-bcache to convert a partition a bcache device, and the resulting bcache device should be mountable as the original filesystem.

Unfortunately the code is pretty old and depends on python3.3 so it takes some work to get all the dependencies together to get it to run. Also, it needs to operate on a partition, so for example if you created btrfs on /dev/sda instead of /dev/sda1 I don't think the tool will work.

Nattgew
  • 2,139