Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently using VirtualBox on my Linux server to run a small Windows guest OS. I've configured its main virtual hard drive as what VBox calls "Immutable" - meaning that any changes to it are written into a differencing image that is discarded when the system reboots.

Can KVM do something similar?

I've read about snapshots via "savevm", "loadvm" but I believe that's saved states, not differencing images.

What I ultimately want is a VM with two drives: one reverts on each reboot, one keeps its changes. Ideally, the unchangeable drive image should be stored with only read access granted to the user running KVM.

share|improve this question
up vote 2 down vote accepted

KVM does have this functionality through the use its supporting tools. The name of the tool is qemu-img and you can either create snapshots at will or you can specify at disk creation time that it should use a (different) backing disk which will not be altered by any changes you make (the changes will persist in the, let's call it the fronting disk, and you can merge them too).

It sounds as if you are trying to create something like an appliance, like a set-top box or a router. In that case you are making this perhaps too complicated. Simply make your boot disk immutable (mount it read-only) and have all the mutable data on the second disk. It's done all the time. Indeed, some machines I've seen booted off a CD but still had hard disks to store data. No need for COW disks. Or maybe not.

share|improve this answer
Thanks for pointing me to qemu-img. It seems I could use a read-only base image for the partition and recreate the differencing image when the VM is shut down. – Cygon Mar 1 '11 at 10:38
Btw, I'm just creating a Windows build slave to do daily builds for some of my projects. To prevent the build environment from getting tainted eventually I want to be able to undo any changes that have happened to the system effortlessly. – Cygon Mar 1 '11 at 10:45
My answer is not clear in the backing disk case. One can create a disk that has a backing disk. Changes to the newly created disk are stored in the "disk" itself but the backing disk is untouched. Merging is good for applying updates or upgrading. – Allen Mar 1 '11 at 18:12
@Cygon How do I make a boot disk immutable and instruct KVM to put all the mutable data on the second disk? Also, won't Windows just refuse to boot in this case? – Nickolai Leschov May 4 '14 at 23:46
I have ultimately decided to use VirtualBox, but I think Allen has answered your question already - install Windows on the VM, then create another hard drive that uses the former as backing disk and mount it as the one and only drive. All Windows sees then is a single, normal hard drive it can write to. – Cygon May 6 '14 at 6:03

this can be easily scripted, and RHEV already has this functionality built in. script to star VM would be: 1) take snapshot 2) start VM with snapshot attached
on shutdown, remove snapshot, very straightforward

share|improve this answer
And it's possible to exempt one of two virtual hard drives from this snapshot? – Cygon Feb 28 '11 at 9:12
if you script it manually - of course – dyasny Feb 28 '11 at 10:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.