Unfortunately Bonnie++ isn’t that well suited to test SSD caching setups. To benchmark this setup I used two different tools. Stop the backing device (after unmounting /dev/bcache0 it will be stopped and removed, don’t forget to unregister the caching device): echo 1 > /sys/block/sda/sda/bcache/stop Benchmark Register the caching device again (or register another caching device): echo /dev/sdb > /sys/fs/bcache/registerĪttach the caching device: echo > /sys/block/sda/sda/bcache/attach Unregister the caching device (can be done with or without detaching) (/dev/bcache0 will still be available because of the backing device): echo 1 > /sys/fs/bcache//unregister echo 1 > /sys/block/sda/sda/bcache/detachĪttach the caching device again (or attach another caching device): echo > /sys/block/sda/sda/bcache/attach This can take a while when the write cache contains dirty data, because it must be written to the backing device first. To detach the caching device from the backing device run the command below (/dev/bcache0 will still be available). You can check the state of the writeback cache via: cat /sys/block/sda/sda/bcache/state The cache is clean again, when all cached writes have been written to the backing device. When writes are cached on the caching device, the cache is called dirty. echo writeback > /sys/block/sda/sda/bcache/cache_mode But there is a chance you will end up with corruption. In case of a power failure bcache will try to recover the data. Bcache uses a fairly simple journalling mechanism on the caching device. For example when there is a power failure or when the SSD dies. But you have to take in mind, there is a risk of losing data when using a writeback cache. To speed up the writes you have to enable writeback caching. Writes are being written directly to the backing device (HDD). By default bcache uses writethrough caching, which means that only reads are cached. Accessing and reading frequently used files is much faster now. Frequently used data is stored on the SSD. The commands for this procedure are shown in the image below.Īfter this I had a working SSD caching setup. For example when booting, bcache needs to know what devices to attach to each other.
#Fancycache ssd software
The creation of a caching and backing device is necessary because it’s a software implementation. This device can be formatted with your favourite filesystem. Those devices can be attached to each other to create a /dev/bcache0 device. First you have to create a caching device (SSD) and a backing device (HDD) on top of two existing devices. You can’t use bcache with an existing formatted partition. Unfortunately bcache isn’t plug-and-play. Fortunately damoxc already packaged bcache-tools for Ubuntu once.ĭebian package: /…/bcache/ Since there is no bcache-tools Debian package available yet, I created my own. On my low power home server I use Debian. Don’t forget to enable the BCACHE module before compiling. The bcache-3.2 branch from Kent’s git repo merged successfully.
In my low power homeserver I use a 2TB Western Digital Green disk (5400 RPM).
#Fancycache ssd Patch
The last one is interesting, because it’s a patch on top of the Linux kernel and will hopefully be accepted upstream some day.
There is Flashcache developed by Facebook, dm-cache by VISA and bcache by Kent Overstreet.