Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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.