Version control for virtual disk images

disk-imageqemuversion controlvirtualization

Is there any existing system for efficiently tracking the version history of a virtual disk image?

Essentially, I have a disk image which is used as a "template" root filesystem for testing programs. I occasionally need to make changes to it (e.g. installing packages), but most of the time it is read-only. I need to be able to keep the full history of changes (mainly so that I can roll back if something goes wrong, but I also may need to look up an older revision by date & time in order to reproduce an earlier test.)

I'd like the history to be stored in some sort of incremental format, since most of the time the changes I'm making are very small (and the complete disk image is huge.)

I'd like it if each revision were stored in a separate file, for ease of backing up with rsync.

I'd like to be able to easily delete old revisions that are no longer needed.

I'd like it if the most recent revision were stored as something close to a flat file, i.e. the read performance should O(1), independent of how many older revisions there are.

Oh, and it needs to be possible for a VM to safely use the disk image (in read-only fashion) while I am making modifications; "committing" has to be an atomic operation.

(Obviously I expect there to be some tradeoffs among these criteria; I'm just trying to give an idea of what I'm looking for.)

Performance for the actual "version control" operations is comparatively unimportant; correctness and stability, on the other hand, are crucial.

I am currently using kvm / qemu, with qcow2 disk images, but I'd be interested in hearing about other options.

I can see how I might write such a version control system myself, using qemu-img with backing files and rebasing, but is there any existing set of tools that would work for this purpose?

Best Answer

It sounds like VAGRANT (https://www.vagrantup.com/) could be a good match for your needs. Vagrant works with several VM engines (e.g. virtualbox, vmware, check link above).

Some advantages include:

  • It's compatible with VCS systems (single text file)
  • Cross platform - windows, linux, mac
  • Extremely easy to share with anyone, anywhere
  • Provides consistent test environment

Getting going

First install vagrant and, say, virtualbox.

Then, you describe your virtual machine in a single VagrantFile which you can generate using:

vagrant init ubuntu/trusty64 [1]

Then you will have a descriptor file for your preferred OS. If you like, edit a few ip addresses, ports, packages and shared folders in the VagrantFile.

When you are done run:

vagrant up

and you have a virtual machine which you can log into using:

vagrant ssh

Customisation

If thats not enough and you have very specific requirements beyond the capabilities of vagrant, there are plenty of vagrant VMs pre-configured with configuration management systems such as cfengine, or chef, or puppet or whichever you prefer.

[1] There are lots of pre-configured vagrant vms out there, take a look at (https://vagrantcloud.com/discover/featured).

Related Topic