July 21, 2025Jul 21 I've been experimenting with LVM-backed VM storage as a middle ground between file-based images and direct device passthrough. I wanted better performance than img files but didn't want to sacrifice snapshots or lose an entire NVMe device to a single VM. The I/O performance improvement over regular img files is pretty substantial - my Windows VM feels much more responsive now.The interesting thing is that while it looks like more layers: VM → qemu → LVM → loop device → file → filesystem → storageIt actually performs better than direct file access because you get proper block device I/O with better caching and alignment.Setup process:Create storage file: truncate -s 100G vdisk-lvm.imgMount via loop device: losetup /dev/loop4 vdisk-lvm.imgInitialize LVM: pvcreate /dev/loop4 && vgcreate vm-storage /dev/loop4Create logical volume: lvcreate -L 90G -n windows vm-storageUpdate VM XML to point to /dev/vm-storage/windows instead of the img fileThe bonus is you get LVM snapshots, which are really handy for things like Windows updates where you want an easy rollback option.I set up some User Scripts to handle the loop device mounting automatically when the array starts/stops.Benchmarks (all using NVME + Real World test, the disk image sits on a Samsung 990 Pro NVMe drive, encrypted XFS format):Using raw image file, "typical" setup:<disk type='file' device='disk'> <driver name='qemu' type='raw' cache='none' io='native' discard='unmap' iothread='1'/> <source file='/mnt/primary/domains/Windows/vdisk1.img'/>Using LVM mounted<disk type='block' device='disk'> <driver name='qemu' type='raw' cache='none' io='native' discard='unmap' iothread='1'/> <source dev='/dev/vm-storage/windows' index='1'/>My question is: why isn't this approach discussed more often in VM guides or forums? Is there some downside I'm not seeing, or is it just the perceived complexity that keeps people using raw/qcow2 files?The performance improvement seems worth the slightly more involved setup. It's not native NVME speeds, but you retain snapshot flexibility. Edited July 21, 2025Jul 21 by jch
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.