VM - Read only

Hi

Does anyone know if there is a way to create a VM that self resets once shut down, and none of the changes are committed to disk?

Sounds like something that may be part of qcow2, but I can’t find anything that wouldn’t be doing it manually through snapshots

With Linux there’s plenty of ways to skin this cat.
You could create a custom LiveCD ISO so the vm doesn’t even need a disk attached to it.
https://help.ubuntu.com/community/LiveCDCustomization

Ideally it would be with a .img or .qcow2, and be toggle-able i.e. sometimes able to comit, but most times not

You might look at making Snapshots. Then roll back to the desired snapshot

1 Like

I don’t really know how it would work, but you could install any Linux to a squashfs. That would write all the changes to the ram and forget everything after a reboot

Sounds like Tails to me

I wouldn’t call it “manual”. It would be trivially easy to script virsh to do what you want with snapshots before booting the VM.

As far as “toggled,” you would just tell it to merge/consolidate your snapshot into the base image when desired.

With KVM you even have the choice of internal or external snapshots. Using external snapshots, you could even make the base image file read-only/immutible to ensure nobody does something foolish and accidentally ruin it.