Create LVM thin provisioning with SSD cache

Awesome LVM setup for my VMs

I recently built a new home server and I wanted to use LVM thin provisioning backed by a nvme cache. This is basicly just a snippet from my command history.

[Update: I later found out that libvirt doesn’t seem to support LVM thin provisioning. Dang it! Guess I’ll have to do just SSD caching then]


/dev/sda 2TB WDC Black harddrive
/dev/sdb 2TB WDC Black harddrive
/dev/nvme0n1 256GB Intel 600p SSD

A bunch of RAID1 devices on sda and sdb. Of concern here is:
/dev/md125  1.9TB RAID1 mirror of /dev/sda5 + /dev/sdb5

Machine is called virt1 and runs CentOS 7

Create LVM thin pool

Create Physical Volumes
pvcreate /dev/md125
pvcreate /dev/nvme0n1

Create Volume Group vg_virt1 on big RAID volume
vgcreate vg_virt1 /dev/md125

Create Thin Pool tp_vmpool on all available space in vg_virt
lvcreate -l100%FREE –thinpool tp_vmpool vg_virt1 –verbose

Volumes can now be created in vg_virt/tp_vmpool

Connect LVM Cache (dm-cache)

Extend Volume Group with SSD
vgextend vg_virt1 /dev/nvme0n1

Create a cache pool out of the free space
lvcreate –type cache -L 238G -n lv_virt1_cachepool /dev/vg_virt1/tp_vmpool /dev/nvme0n1

(the 238G was the effective space – 1% or something like that. It may work with -l100%FREE too)


One thought on “Create LVM thin provisioning with SSD cache”

  1. For what it’s worth, while virt-manager won’t show virtual size logical volumes (thinp LVs), you can use ‘virsh edit VM’ and just edit the configuration to point to whatever logical volume you want, including a thinp LV. I do it all the time.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s