Automatic Start and Stop Actions for Hyper-V Virtual Machines

Hyper-V allows you to control the automatic start and stop behavior of virtual machines. This means that you can decide how a virtual machine will react before a host gracefully shuts down or after it boots up. Hyper-V treats virtual machines that are running on non-clustered hosts differently to those that are running on Hyper-V clusters (highly available virtual machines). I will discuss how virtual machines that are running on a non-clustered host will behave in this post. The behavior of highly virtual machines will be dealt with in a following post.

Hyper-V Automatic Start Action

If you edit the settings of a virtual machine, browse to Automatic Start Action. This allows you to configure what a virtual machine will do when its host starts up. There are three options:

  1. Nothing: The virtual machine will remain offline after the host boots up.
  2. Automatically Start If It Was Running When The Service Stopped: This option is useful in a test lab. You might have a mixture of virtual machines that are either running or stopped when the host shuts down. Hyper-V will automatically start up this virtual machine if this option is selected and the virtual machine was running when the host was shutdown.
  3. Always Start This Virtual Machine Automatically: This is the option you are likely to use for production virtual machines. You want to minimize downtime so the virtual machine will be started up when Hyper-V starts. Note that there is a sub-option to delay this start up by X seconds. This allows you to control contention for resources (mainly storage bandwidth) and to order the start of virtual machines (for example, start the domain controller, then SQL, application server, and then web server).
Automatic Start Action of a Hyper-V virtual machine
Configuring if/how a virtual machine will start after the host boots up.

Hyper-V Automatic Stop Action

If you just pull the power of a host or it crashes, the virtual machines will simply stop running as if you had pulled the power from them too. So you should always try to gracefully shutdown your hosts.

You can choose to configure your virtual machines to react to this action by editing the Automatic Stop Action options in the properties of each virtual machines. Here you will find three options, which Hyper-V will execute on a per-virtual machine basis before shutting down the host:

Sponsored Content

Passwords Haven’t Disappeared Yet

123456. Qwerty. Iloveyou. No, these are not exercises for people who are brand new to typing. Shockingly, they are among the most common passwords that end users choose in 2021. Research has found that the average business user must manually type out, or copy/paste, the credentials to 154 websites per month. We repeatedly got one question that surprised us: “Why would I ever trust a third party with control of my network?

  1. Save The Virtual Machine State: This option helps you minimize virtual machine downtime. The virtual machine is frozen in time, writing the memory and processor stack out to a file that is stored with the virtual machine. After that write is complete the virtual machine stops running. When the virtual machine starts up, it will read in that file and start executing, “auto-magically” continuing as if nothing had happened. The guest OS doesn’t need to boot up, services don’t need to initialize, caches don’t need to be repopulated; things within the virtual machine just continue as they were before the virtual machine stopped running.
  2. Turn Off The Virtual Machine: This option will pull the plug on the virtual machine. No state information is saved. The guest OS will act as if the virtual machine lost power if/when it is started up again. You will use this option on selected virtual machines if you don’t care about the state of a virtual machine and you need a quicker host shutdown.
  3. Shutdown The Guest Operating System: The guest OS of the virtual machine will be gracefully shut down when before the host will be shut down. No state is saved. The downside is that the guest OS and its services will take time to start up when the host restarts. You should consider delaying and ordering the start up of virtual machines if you select this option.
Automatic stop action of a Hyper-V virtual macine
Changing how a virtual machine behaves when the host is shut down.

There is a catch to the option to save a virtual machine state. If you have virtual machines with a sum of 250 GB RAM, then Hyper-V will need to write out up to (roughly) 250 GB RAM to disk to save their states to disk. You need to size for 250 GB of additional disk capacity beyond the normal storage requirements of virtual machines. You also need to be aware that Hyper-V maintains a .BIN file for each virtual machine to guarantee this space will be available. So that 250 GB is actually consumed even if the virtual machine is running.

This .BIN file was always present before Windows Server 2012 (WS2012) Hyper-V. Since WS2012, this .BIN file is maintained for a virtual machine only if you select the Save The Virtual Machine State automatic stop action for that virtual machine. This allows you to save the hypothetical 250 GB of disk capacity, but it means that you either turn off your virtual machines (not recommended) or cleanly shutdown your guest OSes when a host is shut down.

Related Topics:

Aidan Finn, Microsoft Most Valuable Professional (MVP), has been working in IT since 1996. He has worked as a consultant and administrator for the likes of Innofactor Norway, Amdahl DMR, Fujitsu, Barclays and Hypo Real Estate Bank International where he dealt with large and complex IT infrastructures and MicroWarehouse Ltd. where he worked with Microsoft partners in the small/medium business space.
Live Webinar - Thursday, December 2nd! Active Directory Masterclass: AD Configuration Strategies for Stronger SecurityREGISTER NOW - Thursday, December 2, 2021 @ 1 pm ET

Active Directory (AD) is leveraged by over 90% of enterprises worldwide as the authentication and authorization hub of their IT infrastructure—but its inherent complexity leaves it prone to misconfigurations that can allow attackers to slip into your network and wreak havoc. 

Join this session with Microsoft MVP and MCT Sander Berkouwer, who will explore:

  • Whether you should upgrade your domain controllers to Windows Server
    2019 and beyond
  • Achieving mission impossible: updating DCs within 48 hours
  • How to disable legacy protocols and outdated compatibility options in
    Active Directory

Sponsored by: