Frequently Asked Questions

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.

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.

bcache-register is killed by the OOM killer

When bringing up a device, bcache makes large contiguous memory allocations. Build your kernels with CONFIG_COMPACTION for this step to succeed.

Does bcache provide a measurable/noticeable speed boost?

Absolutely. When you first read a sector, obviously it needs to come off your hard drive. For the second and subsequent times you need that sector, it can come off your SSD. First, reads from your SSD do not need a seek; for most people and most drive access patterns that's a massive speed boost right there (exceptions would include streaming large unfragmented files or drives that are very heavy on writes and light on reads). Second, you're splitting up the work; the SSD handles the smaller, fragmented reads, allowing the hard drive to focus on the long streaming reads. Tasks such as directory listings and reading lots of small files or heavily fragmented files can take between 1/2 and 1/4 of the wall clock time to complete. And third, in most cases current production SSDs outperform rotating media. The three SSDs Bill's using for testing have between 215MB/s and 245MB/s read speed. Most hard drives don't get to that performance range.

My budget's tight; could I use a thumb drive or other small flash drive to cache my hard drive?

Yes, you could, and it would give some benefit, but not as much. Since these are commonly 2GB-16GB, you can't cache as much of the original hard drive. Also, SSDs, while they use similar underlying chips as thumb drives, use different firmware to improve reliability and performance. A flash drive would make a good test platform, but keep in mind that you're limiting bcache's performance.

As for the cost of SSDs, many online vendors sell 30+GB SSDs in the hundred dollar range. Even 30GB of cache can make a noticeable boost to your drive performance. No more drive bays in your laptop? Filemate makes two SSDs that fit in an Expresscard slot and also have a USB cable for hooking up to systems without that slot.

Can I put the SSD in a USB SATA case and cache that way?

Yes, and it works reasonably well. The one thing to keep in mind is the USB performance. ''Never'' use a USB 1.1 port; it's so slow as to be unusable. USB 2.0 tops out at 60MB/s, which is still enough to give a nice performance boost, especially for reads that would otherwise have involved a lot of seeks, but it does keep the SSD from reaching its full potential (in many cases >200MB/s on reads).

I thought SSDs wore out quickly if you did regular writes to them?

For older SSDs, that was true. Newer SSDs will recognize that a given block is getting heavy writes and will actually swap a heavily written block with a more lightly written block (moving the data transparently and using internal pointers to keep track of the move). This is called "wear leveling" and its use can take a drive whose individual blocks might have tens of thousands of writes before failure and produce an SSD that can support up to millions of writes in a given location by moving data around underneath. Also, keep in mind that unlike (most) standard filesystems that treat SSDs as random access devices that can take any number of writes of any size, bcache understands the write issues in SSDs and tunes its write algorithms to minimize the number of erasures needed. As a side note, what we think of as ''write'' performance problems on SSDs are largely ''erase'' performance problems.

What sizes does make-bcache accept? (for -w -b ...)

The units are in bytes, but you can also specify it in human readable format. (1k = 1024bytes)

I get "Bad bucket size 0"

Your bucket-size is to large.

When trying to add register devices to /sys/fs/bcache/register I receive "write error: Invalid argument"

Check dmesg for more info.

When formatting a backing device, the bucket info is also displayed, does the back-end device use buckets?

No, they just share the same superblock format.

Dirty data is always 0

Make sure your cache_mode is set to writeback.

{{{echo writeback > /sys/block/bcacheX/bcache/cache_mode}}}

My dirty_data value negative

"The tracking for dirty_data isn't entirely correct, but it doesn't matter much because it's only used for setting the writeback rate."

Also, the negative value is harmless for the algorithm.