SOLVED Snapshot Virtual Machines

passatiji

Dabbler
Joined
Dec 22, 2017
Messages
11
Hello everyone,

For virtual machines I used two drives ada5 & ada6 in a pool called VMachines. Using TrueNAS-12.0-U8 standard tools I have created a Virtual machine (Ubuntu 21.1) and assigned Zvol "model_ca-59sqxf" on the VMachines pool. It's visible from "Storage" -> pool and from "Virtual Machines" -> edit -> disk menu. Then I attempted to create a manual snapshot using these steps: Storage -> Snapshots -> Add -> Dataset "VMachines/amodel_ca-59sqxf", I tried both, the default and Recursive option. After creating a couple empty files I rolled back the snapshot and all the files are still there so the snapshot didn't return the VM to the original status.
Could you please help me figure out what could cause this behavior? Do I have to stop the VM before and during snapshot / rollback?
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Do I have to stop the VM before and during snapshot / rollback?
Depends what you want...

If you want a snapshot of the ZVOL that's likely to be consistent and start, then yes, the VM should be stopped when taking a snapshot.

If you take a snapshot while the machine is running, rolling it back will be equivalent to ripping out the power cord at the moment the snapshot was taken and then powering back on... maybe all good, but if writes were in progress at that moment, maybe not so good for them.

For sure in order to rollback a snapshot, the VM should not be running.

Could you please help me figure out what could cause this behavior?
Depending on the guest OS, file tables or other things relating to disk contents can be cached (or even have the primary copy in memory) and if you change the underlying disk with a snapshot rollback and there's nothing to trigger the guest to go and re-check the disk, then you're just sitting in a position where the whole thing is waiting to go wrong and start overwriting files that you haven't deleted... not good.
 
Last edited:

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
I frequently take snapshots of running machines and have been doing so for years. It is equivalent of pulling the power from a running physical machine but most applications are ok with that. There is always some granularity to any backup mechanism so you will lose some data. The important point is to define how much you can tolerate to lose.

But in case @sretalla did not state that explicitly enough: for a rollback it is absolutely mandatory to power down the VM, roll back, boot. File system check (in most cases automatic) and possibly database check recommended.
 
Last edited:

passatiji

Dabbler
Joined
Dec 22, 2017
Messages
11
Depending on the guest OS, file tables or other things relating to disk contents can be cached and if you change the underlying disk with a snapshot rollback and there's nothing to trigger the guest to go and re-check the disk, then you're just sitting in a position where the whole thing is waiting to go wrong and start overwriting files that you haven't deleted... not good.
Ohh, I see. So it looks like I am doing everything as I should except power cycling the VM. Repeated all the steps with power cycling and it worked. Thank you.
 
Top