Booting from an lvm-cached volume
The following Debian Forum topic and blog post based on it has the missing information.
Outline
-1) Back up your LVM configuration and have a like CD ready.
0) Make sure you have a separate /boot
partition (your cached root will only be available later). This can be a 200MB partition and can be part of the same VG as your cached root.
1) You need dm-cache in your kernel image (instead of module). check your config and make sure you have CONFIG_DM_CACHE=y
. If it is a module (=m) you will need to recompile a kernel where this is set to y. It is probably a good idea to use menuconfig and set this option from there (it will make sure dm-cache's dependency chain is also =y
).
Device Drivers --->
Generic Driver Options --->
--- Multiple devices driver support (RAID and LVM)
<*> Device mapper support
<*> Cache target (EXPERIMENTAL)
2) Install thin-provisioning-tools
(will do fsck-like functions on the cache at boot-time).
3) Create a file in /etc/initramfs-tools/hooks
with the following content. This will make sure the executable from step 2 and some dependencies are inside your init ramdisk image.
#!/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
4) Run update-initramfs -u -k all
to re-generate all your initrd images.
When using vbence's answer, also make the /etc/initramfs/hooks/ file from step 3 executable. Otherwise it won't get run by update-initramfs