Enabling maintenance mode in Hyper-V refers to a state where a Hyper-V host prepares to undergo maintenance operations. When a host is in maintenance mode, it prevents new virtual machines from being automatically started or migrated to it, allowing administrators to perform updates, configuration changes, or hardware maintenance without impacting running virtual machines. To enable maintenance mode in Hyper-V, you can use either Hyper-V Manager or PowerShell.
Method 1: Using Hyper-V Manager:
- Open Hyper-V Manager on the Windows Server or Windows 10 computer where the Hyper-V role is installed.
- In the left pane, select the Hyper-V host for which you want to enable maintenance mode.
- In the right pane, under “Actions,” click on “Enter Maintenance Mode.”
- A confirmation dialog will appear, stating that virtual machines will be live migrated if possible. Click “Yes” to proceed.
- The Hyper-V host will enter maintenance mode, and any running virtual machines will be live migrated to other available hosts in the Hyper-V cluster or failover cluster (if applicable).
- Once maintenance mode is enabled, you can perform the necessary maintenance tasks on the host.
- To exit maintenance mode, right-click on the host in Hyper-V Manager and choose “Exit Maintenance Mode.”
Method 2: Using PowerShell:
Alternatively, you can use PowerShell to enable maintenance mode on a Hyper-V host. Open a PowerShell window with administrator privileges and use the following command:
Enable-VMHostMaintenanceMode -VMHost "HyperVHostName" -Evacuate
Replace "HyperVHostName" with the name of the Hyper-V host on which you want to enable maintenance mode. The -Evacuate parameter ensures that running virtual machines are live migrated to other available hosts in the Hyper-V cluster or failover cluster (if applicable).
To exit maintenance mode, use the following PowerShell command:
Disable-VMHostMaintenanceMode -VMHost "HyperVHostName"
Replace "HyperVHostName" with the name of the Hyper-V host from which you want to exit maintenance mode.
Remember that enabling maintenance mode will automatically live migrate running virtual machines if possible. Ensure that you have a properly configured Hyper-V cluster or failover cluster to handle the migration of virtual machines during maintenance operations. Additionally, make sure that you have the necessary permissions to manage Hyper-V hosts and virtual machines.