I have several KVM raw files that are read only (about 100gb).I am adding these raw files as loopback devices.I then create a snap file to allow the VM to have read/write access to its disk. This allows me to insert modifications, test, wipe the snap and repeat.Snippet of my perl script:$base_file = /images/vmbase.raw;$base_stats = stat($base_file);$base_blocks = $base_stats->size / 512;$base_size = floor($base_stats->size / 10**6);system(dd if=/dev/zero of=/dev/shm/vmbase.snap count=1 bs=1M seek=$base_size);$baseloop='losetup -f --show /images/vmbase.raw --read-only';$snaploop='losetup -f --show /dev/shm/vmbase.snap';system(dmsetup create vmdrive --table 0  snapshot $baseloop);`This creates a device called /dev/mapper/vmdrive that I then attach to my virtual machine. I can use parted /dev/mapper/vmdrive to see the available partitions. Now, it would great to switch to thin provisioning to see if I get a performance gain.Here is what I tried (used the cookbook from https://www.kernel.org/doc/Documentation/device-mapper/thin-provisioning.txt)First I create some block devices using loops:meta: 2GBsnap: 24GBdd if=/dev/zero of=/dev/shm/vmbase.meta bs=4096 count=524288dd if=/dev/zero of=/snaps/vmbase.snap bs=4096 count=5859385losetup -f /images/vmbase.raw --read-onlylosetup -f /dev/shm/vmbase.metalosetup -f /snaps/vmbase.snap`Then I create the pool device: (assume loop0 for raw, loop1 for meta and loop2 for snap) I use a 1MB block size and 2GB as my low free space threshold$ dmsetup create vmbase-pool \      --table 0 20971520 thin-pool /dev/loop1 /dev/loop0 2048 2048Follow that up by generating the snap of the external block device (my raw file)$ dmsetup message /dev/mapper/vmbase-pool 0 create_thin 0$ dmsnap create vmsnap \      --table 0 20971520 thin /dev/mapper/vmbase-pool 0 /dev/loop0I then attach the /dev/mapper/vmsnap device to my virtual machine and it won't boot. When I use parted to print the partition table I get errors. Part of this is I need to be able to launch multiple copies of the virtual machine at once.I'm using RHEL 6.7 with kernel 2.6.32-573.7.1Where am I going wrong?
Using Device mapper thin provisioning on loop devices
rhel;kvm;loop device;snapshot;device mapper