LVM Cache is a interesting feature that I saw some web review on the web. It can speed up traditional mechanical disk with a cache partition on SSD. Essentially the concept is the same as Windows Readyboost or Fusion Drive, which the caching is controlled by firmware.
Resize the SSD
e2fsck /dev/sda1 resize2fs /dev/sda1 100000M
Use GParted to adjust the partition size
Mark Data(sdb1), Cache(sda2) and Meta(sda3) as LVM PV
sudo pvcreate /dev/sdb1 sudo pvcreate /dev/sda2 sudo pvcreate /dev/sda3
Create Volume Group with the PVs
# Must spare some space sudo vgcreate VG /dev/sdb1 /dev/sda2 /dev/sda3 sudo lvcreate -l 95%FREE -n data VG /dev/sdb1 sudo lvcreate -l 95%FREE -n cache VG /dev/sda2 sudo lvcreate -l 95%FREE -n meta VG /dev/sda3
Create Cache Pool and config cache mode as Writeback (improve read / write performance)
sudo lvconvert --type cache-pool --poolmetadata VG/meta VG/cache sudo lvconvert --type cache --cachepool VG/cache --cachemode writeback VG/data
In case you are unlucky that u encounter the cache corruption. You need to execute the following commands to rebuild the cache
vgchange -a y VG lvchange -a y VG/data lvconvert --repair VG/data
Reference:
http://man7.org/linux/man-pages/man7/lvmcache.7.html