In a Hyper-V environment, administrators can choose to start a virtual machine automatically when a Hyper-V server...
is booted, as well as control the behavior of a VM during the hypervisor shutdown. This article examines some of the best Hyper-V management practices for automatic start and stop actions.
Automatic Start Action options
The Hyper-V Automatic Start Action is configured on a per VM basis. You can access the Hyper-V Automatic Start Action options by opening the Hyper-V Manager, right clicking on a VM and selecting the Settings command from the shortcut menu -- the automatic start settings are also exposed through System Center Virtual Machine Manager. Once the settings window for the VM is displayed, simply select the Hyper-V Automatic Start Action option from the console tree. You can see the Automatic Start Action settings below in Figure A.
As you can see in the figure above, Hyper-V gives you three options for automatically starting VMs. The first option is "Nothing." This option essentially tells Hyper-V not to do anything with the VM when the Hyper-V server is booted. In other words, setting the Automatic Start Action to "Nothing" prevents the VM from automatically being started when the Hyper-V server is booted.
The second option is to automatically start if it was running when the service stopped. This is the default option, and it tells Hyper-V to check to see what the status of the VM was at the time that the server was shut down. If the VM was running, then Hyper-V will automatically start the VM as a part of the host server's boot process.
The third option is to always start the VM automatically. Users are given an option to select an automatic start delay. Using this option allows you to choose to delay the start of a VM for a number of seconds.
Although the default behavior is to automatically start the VM if it was running at the time that the server was stopped, I recommend using this automatic start option only for critical infrastructure servers, such as DNS servers, DHCP servers and domain controllers. Application servers and less critical infrastructure servers should be configured to use a startup delay. The reason for this is that some application servers will fail to come online if the required infrastructure is not already present. Using a startup delay ensures that the infrastructure has time to come online before application servers begin to boot.
Automatic Stop Actions
Like the automatic start options, the automatic stop options are also set on a per VM basis and can be configured using either the Hyper-V Manager or System Center Virtual Machine Manager. To access these settings within the Hyper-V Manager, right click on the VM that you want to configure and select the Settings command from the shortcut menu. When the Settings window appears, select the Automatic Stop Action option from the console tree. You can see the available settings in Figure B.
Hyper-V gives you three options for handling a VM in response to a physical-host-server shutdown. The first option is to save the VM state. In many cases, this is a good option, but it can require a significant amount of disk space. Hyper-V uses disk space equal to the amount of memory that has been allocated to the VM. This allows the memory contents to be written to the disk so that the VM can later be brought back online in the same state in which it previously existed.
The second option is to turn off the VM. This option is similar to yanking the power cord out of a physical server. It isn't a graceful shutdown, but this is the option that you will probably have to use if you have a VM without Hyper-V Integration Services.
The third option is to shut down the guest operating system. This option uses the Hyper-V Integration Services to perform a graceful shutdown of the VM.
Many resources suggest that saving the VM state is the preferred Hyper-V Automatic Stop Action. However, there are some situations in which saving the VM state may not be the best course of action. For example, if you have a VM that has been allocated a very large amount of memory, but your storage resources are limited, then saving the VM state might not be a good idea because it will consume storage space. This is also a poor choice if you need the VMs to be taken offline as quickly as possible.
Likewise, if you have a distributed application that spans multiple VMs, then using the saved state option usually isn't going to be a good idea. The reason for this is that the VMs might be brought back online in a random order, thereby confusing the distributed application. For these types of VMs, it may be better to shut down the guest operating system.
As you can see, Hyper-V allows you to control the automatic start and Automatic Stop Actions for your VMs. It is worth noting that the settings behave a little bit differently if the VM has been made highly available. If a host server is taken offline, highly available VMs will failover to another cluster node rather than initiating an Automatic Stop Action.
Another thing to keep in mind is that Automatic Stop Actions do not work in the event of a host server crash. A crash happens abruptly, and Automatic Stop Actions are only initiated in the event of a graceful host shutdown.
Managing Hyper-V security permission options
Configure Hyper-V virtual switches with PowerShell
The 10 best Hyper-V tools