Tech Journal ‐ Milestone 7 - Peytonvt/SYS-350 GitHub Wiki
Milestone 7: Hyper-V Linked Clones and Automation
Overview:
- Creation of a Hyper-V Base Virtual Machine
- Configuration of Linked (Differencing) Virtual Hard Disks
- Deployment of Child Virtual Machines
- Automation of VM Management with PowerShell
- Comparison of Manual vs Automated VM Provisioning
Environment:
- Hypervisor: Microsoft Hyper-V
- Network: HyperV-WAN
- Shell: PowerShell
- Disk Type: VHDX (Differencing Disk)
Linked Clone Concept:
Linked clones allow rapid VM deployment by referencing a shared, read-only parent disk. Child disks only store changes, resulting in smaller disk usage and faster provisioning.
Parent Disk Preparation:
- Locate the base virtual hard disk used by the base VM.
- Set the parent VHDX file to read-only to prevent modification by child disks.
Final Script:
$parentVHD = Get-Item "C:\Users\Public\Documents\Hyper-V\Virtual hard disks\rocky-base.vhdx"
$parentVHD.Attributes = $parentVHD.Attributes -bor [System.IO.FileAttributes]::ReadOnly
`# Specificy path to the origianl VM VHD.
$parentVHD = Get-Item "C:\Users\Public\Documents\Hyper-V\Virtual hard disks\rocky-base.vhdx"
# Change the origianl VHD to read only.
$parentVHD.Attributes = $parentVHD.Attributes -bor [System.IO.FileAttributes]::ReadOnly
# Create the new Differencing VHD
New-VHD -Path "C:\Users\Public\Documents\Hyper-V\Virtual hard disks\rocky-clone1.vhdx" -ParentPath $parentVHD -Differencing
$childVHD = Get-Item "C:\Users\Public\Documents\Hyper-V\Virtual hard disks\rocky-clone1.vhdx"
# Create the VM using the Differencing VHD and configure settings
New-VM -Name rocky-clone1 -MemoryStartupBytes 4GB -BootDevice VHD -VHDPath $childVHD -Path .\VMData -Generation 2 -Switch HyperV-WAN
Set-VMProcessor -VMName rocky-clone1 -Count 4
# Disable Secure Boot
Set-VMFirmware -VMName rocky-clone1 -EnableSecureBoot off
# Start up the VM and Display Details
Start-VM -Name rocky-clone1
Get-VM -Name rocky-clone1
`