Cloning VMs and Containers in ProxMox

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey guys welcome to how to do computers i'm mike and today we're going over templates and cloning in proxmox this can be done with vms as well as containers and it will save you an absolute ton of time with deploying multiple instances of the same os the first thing you'll want to do is set up a golden image for the vm or container you want to clone in my case here it's a windows server 2019 virtual machine but the process is similar for pretty much any os cloning a windows vm does however require a few extra steps then cloning a linux machine but we'll go over those in a minute first i'd like to go over the difference between cloning from a template and cloning from an existing vm each one has its pros and cons for both you'll start off the same you'll set up a vm and install the os then you'll make all the configuration changes and install all of the things that you think that the copies will need like a favorite browser a guest agent like the proxmox qemu agent and of course all updates and or repositories you might need now you have two options you can convert this to a template which can be used to make clones or you can leave it as a virtual machine and clone it from the vm itself when you convert the vm to a template it effectively stops being a vm in that you can no longer power it on and use it the drawback of this is that you'll have no way of applying updates installing different software or applying configurations to the template you would have to create a new template to do that the greatest benefit to using a template is creating what's called a linked clone what this does is it allows you to create a clone that uses the template as a sort of base so that the clone won't need to have its own copy of the os files or anything else that you've saved to the original template it will simply read them from the template itself this will end up saving a lot of space on your storage especially if you plan on making many instances of this machine keep in mind if you choose to go this route you won't be able to delete the template if there are any linked clones running off of it that means that if you want to make a new template with updated software and configurations you'll need to build everything from scratch on the other hand you can simply go with cloning the vm as it is the benefit with this is that you can make changes to your golden image dynamically applying needed updates and configurations as you see fit if you do this though you'll lose the useful ability to create a linked clone which means that each time you clone the machine it will be taking up as much disk space as the original vm usually my personal choice for production machines is to stick with leaving the virtual machine as a virtual machine and cloning it when i need to deploy a new instance every so often i power on the golden image and apply updates which makes deploying a new machine a little bit faster as i don't need to wait for more and more updates to apply the older the template gets i will however sometimes use a template if i need to spin up several test instances as they are much faster to create and to manage in the short term so let's go ahead and go into our server golden image open up the console quick side note if you're running a domain server you shouldn't join the golden image to the domain as i've experienced problems with this in the past so on this machine i've installed a couple of things and made sure that it's completely up to date with all the security patches i've also ensured that all the options and hardware settings are appropriately set in proxmox so now it's ready to be cloned regardless of what you have done to the machine i do recommend doing two things to your golden image specifically with windows the first is ensure that the qemu guest agent is already installed and second i like to create a batch file on the desktop that will make the post clone process a little simpler so here we have sysprep.bat if we edit we can see that it executes sysprep from the sysprep directory with the flags generalize oobe and reboot i'll be sure to post this in the description below all you'll do is open up an empty notepad file paste this into the notepad file and then save it as sysprep.bat on your desktop and it will be ready to run whenever you deploy a new image so the reason we run sysprep is that whenever you clone a windows machine it needs to have a new machine id assigned to it or there can be conflicts especially if you're running them together on a domain there are arguments regarding this topic on various forums and some people believe that this is an unnecessary step however my experience has proven otherwise so i always assist prep any new windows virtual machine another note here after you run sysprep it will delete the original windows profile and create a new one so it won't copy profile based configurations like folder views taskbar and start menu shortcuts or pretty much anything that stores configuration data in the local user's app data folder it should however still preserve installed programs drivers updates etc so now in proxmox go ahead and go to your node and find the golden image first we'll go over a basic clone so go ahead and right click select clone you'll enter a name vmid and a target storage this one is going to be our file server so i'll call it svr fs01 i'll leave the storage the same as the source vm and the vmid as 103. hit clone and this may take a little while you can monitor the progress by going to your tasks double clicking on it and watching the output so that took right around two minutes to copy once it says task okay the vm should be cloned and here we go now let's select the vm and hit start to start it and then we'll let it boot into windows now if this was a linux machine you could simply rename it and be done however in windows like i mentioned before we need to run sysprep so once you're booted in you'll run that batch file that we created earlier and then let it do its work this process usually takes a few minutes and then it will reboot so i'll get back after that is finished once the computer is finished rebooting you'll be brought to an initialization screen make sure that the appropriate options are set hit next click accept and then you'll need to set a password and hit finish so once the sys prep is complete your machine should be ready to go now let's take a look at templates since i do want to keep the original golden image vm i've made a clone of it for demonstration purposes and named it svr 2019-template since we won't be allowed to make any more changes to the template once it's created we can actually go ahead and cis prep this machine before we convert it into a template this makes it so that when we clone it we don't need to run sysprep on the clone it'll already be initialized so before we run the sysprep batch file that we created earlier i'll make one adjustment to it so go ahead and right click and then hit edit and we want to change the reboot flag at the end to say shutdown go ahead and save it and then run and now we'll wait once again for the assist prep to complete except this time it won't automatically reboot after it's finished so now that the virtual machine has finished the sysprep and it is shut down we can right click on the vm and then select convert to template hit yes and then allow that to finish now when you make a clone of this template it'll automatically assign the machine a new machine id without the added step of running sysprep which is a bit of a time saver as well so now let's go ahead and make a clone of the template if you right click on it you'll see that the only option available is to make a clone so click that we'll give it a name for now i'll just call it test server leave the vmid as 106 and for this we'll leave it as a linked clone go ahead and clone it and unlike a standard clone it should create instantly so just like before the machine will reboot a couple of times and then you'll get the same post sysprep initialization screen and there we go your linked clone is up and running now i won't go over cloning or creating templates for containers as the process is nearly identical to virtual machines that being said i believe that is all for now as always thanks for watching let me know in the comments if you run into any issues or if you have any questions and i'll see you in the next video [Music]
Info
Channel: H2DC - How to do Computers
Views: 7,700
Rating: undefined out of 5
Keywords: proxmox, homelab, h2dc, how to do computer, how 2 do computers, guide, tutorial, PVE, virtualization, hypervisor, virtual machine, windows, linux, install, VM, homelabbing, virtio. Virt-io, server, home server, clone, template, convert, linked clone, cloning
Id: Wip5EjGo5ME
Channel Id: undefined
Length: 8min 41sec (521 seconds)
Published: Fri Dec 03 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.