I mostly found bcache to suite me better, but due to a discussion today I came to test dm-cache. I didn't find a great entry doc how to do so, so I thought I could as well document and share here - and by that make "searchable".
So how to actually set dm-cache up on Ubuntu?
I was starting on this info on get most out of your nvme, but also
man lvmcache
is a good resource.I have (sorry) not more disks around:
Basic setup:
After that you can use that device "as usual". I also created a non cached device as reference for a basic test:
And mounted it
After this my setup looked like this:
Please be aware that dm-cache has evolved a lot. There are still many guides that recommend to tune the cache with "dmsetup message ...", but that all is part of the old "mq" policy. See Kernel Doc. These days the Stochastic multiqueue (smq) is the default, considered superior and comes without any tuning knobs. That went as far as to drop "mq" since Kernel 4.6 and make is an alias to the smq policy.
So very basic benchmarking with two slow sync io sequential disk crawlers and two aio random hot spots (and not all of the crawlers fitting onto the cache, but the hotspots easily do). There are more details on the results if you want to look. Results are much better than without cache, but the testcase was in no way sophisticated enough to check that in any detail.
This shall not become a discussion on bcache, dm-cache, ... as I stated at the beginning I usually prefer bcache as well but that is not the point. But if OTOH you have any recommendations for dm-cache to add please feel free to use the comment section.