While there are a lot of examples that describe how to set up a LVM cache on an SSD for a HDD backed storage, they mostly fail to describe an additional step needed to preserve the cache across a reboot on a Ubuntu system.

The culprit is that the drivers needed to enable the LVM cache are not built into the kernel, nor available in the initrd. Therefore, these drivers need to be added to the initrd. Additionally, some cache management helper tools are also not installed by default on a Ubuntu system.

The following shortcut can be used to automatically create and add a LVM cache to an existing storage instead of the multitude of steps that are usually shown.

# lvcreate --type cache --name Name --size Size VG/LV [PV]

Additional software is needed to manage the cache e.g. cache_check.

# apt install thin-provisioning-tools

Edit the initramfs configuration to load the required modules to the initrd.

# content of /etc/initramfs-tools/modules
dm_cache
dm_cache_smq
dm_presistent_data
dm_bufio
dm_bio_prison

Finally, update the initrd.

# update-initramfs -u

Categories: Experiential

0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.