Just wanted to share this little recipe since it took a non-trivial amount of scraping on my part to find it. I am now running a Debian Jessie system using lvmcache. This turned out to be a bit trickier than I'd thought; it doesn't work out of the box. I performed the following steps:
- Created cached volume via instructions in the "lvmcache" man page
- Created a single LV from that volume group and used it as the PV for another volume group
- Moved my root and home volumes onto that volume group
- Rebooted
Ultimately, the solution was twofold. First, install the "thin-provisioning-tools" package (which contains the "check_cache" binary). Then, copy the following simple script into "/etc/initramfs-tools/hooks":
Code: Select all
#!/bin/sh
PREREQ="lvm2"
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
if [ ! -x /usr/sbin/cache_check ]; then
exit 0
fi
. /usr/share/initramfs-tools/hook-functions
copy_exec /usr/sbin/cache_check
manual_add_modules dm_cache dm_cache_mq
This comes with a couple downsides. First, check_cache is a dynamically linked executable and relies on the C++ stdlib; this means that my initramfs image is now 18M or so. (In theory, a statically-linked build could solve this problem... but it's honestly just a lot simpler to do things this way.) Second, check_cache is not fast -- it seems to take several seconds at boot time -- so it doesn't really speed up the boot process. But my whole system is running cached on my SSD, which is really what I wanted.