[plug] Interesting VM trick

Brad Campbell brad at fnarfbargle.com
Mon May 26 06:26:26 UTC 2014


G'day Guys,

I do a _lot_ of my work in virtual machines. I have a dedicated box with 
GT stripes to run windows VM's for Cad and these machines run off an SSD 
with the entire block device passed to qemu as a raw disk. Performance 
was/is great.

I often have to switch between a Server 2003 & Windows 7 VM and this was 
achieved with a series of scripts that backed one up to rotating media 
using dd and ntfsclone, and then restored the other. This was a time 
consuming process and it annoyed me. I got hold of a cheaper and bigger 
SSD and tried to make the OS's co-exist on the one disk but just ended 
up locking horns with Windows.

Then it occurred to me that QEMU does not know if I pass a full raw disk 
or a partition. It looks the same, just smaller. So I partitioned the 
drive into two, and restored the respective MBR/partition tables at the 
start of each drive partition. kpartx then looked at each partition as a 
partitioned disk and set up /dev/mapper instances for me to restore the 
VM's to.

Now I can select either partition to pass to qemu (or both and run two 
machines side by side) and I get raw disk performance, but perfect 
separation of the machines. No more switching, and backups can be 
performed as previously, but with an added kpartx step. Windows can 
manage its own partition tables and file systems without interference.

I thought it was non-obvious enough to warrant posting it here in the 
case it might help someone someday.

Regards,
Brad


More information about the plug mailing list