Guide

Add a virtual machine to a cluster

A virtual machine is only protected by the cluster if it lives on the cluster's shared storage and has been handed to the cluster to look after. This guide creates one, hands it over and moves it between hosts while it runs.

10 minutesRun as a domain admin on the first host
What improves

The VM can move between hosts and restarts elsewhere if its host fails.

Why it matters

A VM on a host's own disk is not protected, even when that host is in a cluster.

How you do it

Create the VM on the shared volume, hand it to the cluster, then move it live to prove it works.

Create the VM on the shared volume

The VM's files must be under C:\ClusterStorage, the storage both hosts can reach. A VM stored on a host's own disk cannot move.

CON-HV-01
$vm = 'CON-TEST-01'

New-VM -Name $vm -Generation 2 -MemoryStartupBytes 1GB -Path 'C:\ClusterStorage\Volume1' `
    -NewVHDPath "C:\ClusterStorage\Volume1\$vm\$vm.vhdx" -NewVHDSizeBytes 20GB -SwitchName 'CON-SET-01' | Out-Null
Set-VMNetworkAdapterVlan -VMName $vm -Access -VlanId 50
Start-VM $vm
PartMeaning
Path under C:\ClusterStoragePuts the VM on the shared volume.
SwitchNameThe team switch. It must have the same name on every host, or the VM cannot move.
VlanId 50The network the VM belongs on. The team carries it to the right place.

A VM with no operating system installed is enough for a first test. It sits at a "no boot device" screen and the cluster still treats it as running.

Hand it to the cluster

CON-HV-01
Add-ClusterVirtualMachineRole -VMName $vm | Out-Null
Get-ClusterGroup $vm | Format-Table Name, OwnerNode, State -AutoSize

The VM should show Online on the host you created it on. From now on, manage it in Failover Cluster Manager, not Hyper-V Manager.

Move it while it runs

CON-HV-01
Move-ClusterVirtualMachineRole -Name $vm -Node CON-HV-02 -MigrationType Live
Get-ClusterGroup $vm | Format-Table Name, OwnerNode, State -AutoSize

The owner should change to the other host, with the VM still Online. This is a live migration: the VM is not switched off, and anyone using it would not notice.

What a live move proves

  • Both hosts can read and write the shared storage.
  • The cluster network carries traffic between the hosts.
  • The team switch has the same name and VLANs on both.

Use it before maintenance: move the VMs off a host, update and restart it, then move them back.

Existing VMs

A VM that already exists on a host's own disk has to be moved to the shared volume first. In Hyper-V Manager, choose Move, then Move the virtual machine's storage, and pick a folder under C:\ClusterStorage\Volume1. Then run step 2.

Done when

Check

The VM shows Online in the cluster and has moved to the other host and back without being switched off.

Your progress is kept in this browser only.