Are cloned VMs and their ZVols independent from their parent?

shoulders

Dabbler
Joined
Jul 3, 2021
Messages
14
I use an Ubuntu Server VM as a template. I clone this Ubuntu VM so I can try out various software on a fresh copy of Ubuntu server with all of my basic settings applied without having to re-install the Linux OS over and over again.

My questions are, if I delete this 'parent' VM:
  • Will this damage the 'child' ZVol clones?
  • Will the 'child' ZVol become independent?
  • Will the 'child' ZVols show a higher disk usage than they currently do now (snapshot data + parent VM data)?
The my Ubuntu server 'Parent VM' has been cloned many times..

The reason I ask this is when you snapshot a dataset that is all you are doing, just adding another snapshot to that particular dataset, but when you clone a VM the ZVol is copied by snapshot but does not show the full disk usage yet then word 'Cloned' implies it is copied.

I understand that the VM configurations are fully cloned and are independent but I am unclear as to the status of the associated ZVol.

Thanks for any help here.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
I never used cloned VMs so I am not quite sure what TN does under the hood.

If you want a truly independent copy, then do just that: use zfs send <volume> | zfs receive <new volume> to create a complete copy and then configure that as an existing zvol for your virtual disk.

HTH
Patrick
 

shoulders

Dabbler
Joined
Jul 3, 2021
Messages
14
I know about send and receive:smile:, for me it all boils down to, is using the clone command on VMs safe?

Also, I think that the clone button should use the send|receive and not make a snapshot causing this issue. Just make it you can only clone an offline VM.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Sorry, I never used it. Because I know what happens with send and receive and prefer that. :smile:
 

shoulders

Dabbler
Joined
Jul 3, 2021
Messages
14
You are right, send and recv is a much better solution.

Going forward I still need to figure out what is happening with the clones.
 
Last edited:

shoulders

Dabbler
Joined
Jul 3, 2021
Messages
14

Cloned VMs are not clones, they are snapshots!​

  • Do NOT use the 'Clone' button and expect an independent clone of your VM.
  • This functionality is simliar to snapshots and how they work in VirtualBox, except here, TrueNas bolts a separate KVM instance on the newly created snapshot and presents it as a new KVM.
  • This should only be used for testing new features and things out on existing VMs.
  • TrueNAS should rename the button 'Clone' --> 'Snapshot VM' as this is a better description.
I will outline what happens and what you get when you 'Clone' a VM.

View attachment KVM-Clone_Button.webp

  1. Click the 'Clone' button.
  2. TN creates a snapshot of the VM's ZVol.
  3. TN clones this snapshot to a new ZVol.
  4. TN creates a new VM using the meta settings from the 'parent' VM and the newly created ZVol.
FAQ
  • You cannot delete a Parent VM if it has Child/Cloned VMs. You need to delete the children first.
    View attachment KVM-Deleting_Parent_VM-Error_Message.webp
  • You cannot delete a Parent ZVol if it has Child/Cloned ZVols. You need to delete the children first.
    View attachment KVM-Deleting_Parent_ZVol-Error_Message.webp
  • Deleting a Child/Cloned VM (with the option 'Delete Virtual Machine Data') only deletes the ZVol, not the snapshot that it was created from on the parent.
  • When you delete the Parent VM (with the option 'Delete Virtual Machine Data'), all the snapshots are deleted as you would expect.
  • Are the child VM (meta settings only) linked or is it just the ZVols.
    • I am assuming the ZVols are linked, the meta information is not.
  • How can I tell if the ZVol is a child of another?
    1. Select the ZVol in the 'Datasets' section. It will show a 'Promote' button next to the delete button.
    2. The naming convention of the ZVol will help. The clone's name that you selected will be added to the end of the parents name to give you the full name of the ZVol. So all children of that parent, will start with the parents name.
      View attachment KVM-ZVol_Naming_Convention.webp
  • Don't manually rename the ZVols, as this helps visually identify to which parent it belongs.
  • The only true way to get a clone of a VM is it use send|recv to create a new (full) instance of the ZVol, and then manually create a new VM assigning the newly created ZVol.
I am not an expert, but I hope this helps if someone else is stuck.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
@Patrick M. Hausen - I don't suppose you know why my images are not showing inline?
Just a guess - because the forum software does not know how to handle a "WEBP" file? What is that, anyway? Never seen it before. My screen shots are PNG.
 

shoulders

Dabbler
Joined
Jul 3, 2021
Messages
14
.webp is the next generation of image format. Google made it. It has a lossless mode and can do high compression. I use it all the time because of the massive size reductions on images. On Windows a software called Paint.NET fully supports this format if you want a play.

When I do screenshots all mine are in PNG, but I have converted these because I had already added them to my article/notes so I just used them.
 
Joined
Oct 22, 2019
Messages
3,641
I made a suggestion:

 
Top