Assumption
- You just installed the Windows Server 2022 into the VM you want to make it template for other VM Server Rapid deployment.
- You have the Hyper-V Cluster having the Cluster shared volume so that any member node can import the template VM into the new Failover Cluster VM env for build.
Step 1: Prepare the OS and VM Hardware settings for Imaging
- Complete the server installation on new VM.
- Apply all patches.
- Apply all necessary applications.
- Turn on any Windows Roles and Features you want to supply to the new machine just after the setup completed from VM import.
- Make sure you configure the vNIC on OS to the DHCP setting so that we can avoid any IP conflict from static IP address setting.
- Configure the VM machine options properly
- make sure the VM has proper memory capacity assignment
- Make sure the VM has the proper count of CPU assignment.
- Make sure the VM has the TPM settings turn on or off as per requirement. if TPM is turned on, make sure you are aware of the Guradian setup completing.
“HostGuradianService” issue in Hyper-V Live migration? – Infra Lover Tech Forum (toshitoshi.net) - Make sure the VM belongs to the right Switch so that the machine can join to the proper network.
- In general, DVD drive is not necessary. Remove it if so.
- Make sure the Guest Service is selected.
- If you don’t need, turn off the checkpoint option.
- Make sure you use the Dynamic MAC address assignment. if you use the static MAC address, the same MAC address makes a confusion in the later network communication.
- make sure the VM has proper memory capacity assignment
Step2: Sysprep !
- You start the sysprep process to normalize the system to place the windows to post-installation stage.
- Open Command prompt via Administrator mode.
- Move to c:\windows\system32\sysprep
- perform the basic sysprep as below.
>Sysprep.exe /generalize /oobe /shutdown - Complete the sysprep process and wait to shut the machine down completely.
Step3: Export the image.
- Go to Hyer-V Manager and access to the Hyper-V node hosting the VM Server image.
- Right click the VM and Export.
- Specify the Folder under Cluster shared volume mount folder.
- Export.
- Monitor the status from the VM list screen.
Step4: Create the new VM from the Exported template image
- Open Hyper-V Manager and access to the node where the new VM is created on via Template image.
- Right click the node, “Import Virtual Machine..”
- Next till “Locate Folder” and select the folder where the master VM Server image has been exported in Step3. And then, Next.
- Select the VM template image. And Next.
- Select the copy option. and Next.
- Specify the path created for new VM especially with the actual name to avoid any folder confliction.
You must specify the location of the Cluster Shared Volume. - Specify the hard disk file location. it can be same path you specified at above step. And next.
- Finish the import process.
- Rename VM name. You will see the VM name in Hyper-V console is same one of VM image.
you need to change the name. - Go to the Failover Cluster console and access to Hyper-V Cluster. Right click “Roles” and “Configure Roles.”
- At the Select Role, specify Virtual Machine. And Next.
- You will find the machine in which you just imported from the exported image. Select it and Next. Next – And finish.
- Confirm the image got registered into Hyper-V Cluster control.
- Run it and setup the Server.