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)

Upgraded harddrive with encrypted LVM

My HP laptop with 160GB harddrive was getting full and I wanted to upgrade it to a bigger one. Found that 2.5″ 500GB was relatively cheap so I bought one and detailed the procedure of upgrading with all data intact. I bought a 2.5″ USB-SATA chassis as well for the old drive to sit in. As I hit a few snags when doing this I thought it could be useful for others to read about.

Continue reading Upgraded harddrive with encrypted LVM