If you are a Virtualization Engineer you might need to deploy VMs within few minutes for your requirements. You can follow the traditional way which you can build the VM from the scratch, install the OS and patch the server. This will reasonable time and sometimes you can’t wait until you complete this process.
In a situation like this VM templates come in to play and will help you to quicker your process. In VMware there is a direct option to convert a VM to a template and in Hyper-V it is bit different. Here I’m going to show you how you can build your own template and deploy a VM from the template within few minutes.
At least one time you need to follow the traditional way and you need to install and patch the server from the scratch.
Once you done that, we can run the “sysprep” tool and “generalize” the current OS. If you select the “Generalize” option it will remove the unique information from your installation. Then it will start as a Windows fresh installation.
- Start your cmd as an “Administrator” and run the “sysprep” tool from “C:WindowsSystem32Sysprepsysprep.exe” location
- Once you get the “System Preparation Tool” select the “Generalize” option and select Shutdown Option as “Shutdown”
- Now go to your VM installation folder and get the VHDX/VHD as your base VM VHDX disk. So in Hyper-V this is the Template. If you need you can rename it as “Template.vhdx” or any suitable name. Take a copy of VHDX as the HDD of your VM.
- Now you need to create a new Hyper-V VM with your requirements CPU,RAM and all the other Hardware requirements except the OS HDD. Here I’m not going to show you how to create a VM in Hyper-V. At the “Connect Virtual Hard Disk” step you can select “Use an existing virtual hard disk” option or “Attach a virtual hard disk later” option I would recommend “Attach a virtual hard disk later”option.
Note : If you are using a generation 1 VM you need to add this HDD as a IDE Controller and if it is a Generation 2 VM you can use it as an iSCSI disk since there is a boot missing issue exists if you use an iSCSI bootable disk with generation 1 VM. (You can’t use Generation 1 VM HDD for Generation 2VM).
- Once you are done with VM creation power on the new Virtual Machine.
Now you can deploy any number of VMs from this template HDD, But you need to create a new VM allocating all the virtual hardware.