Save to My DOJO
Virtual Machines running on Hyper-V can be configured to start automatically when Hyper-V Server starts or in case if something goes wrong with the Hyper-V Server and it restarts.
Automatic Start Action
The “Automatic Start Action” feature is very helpful for virtual machines which need to be started first before any other virtual machines can be started. This option is designed by keeping a few IT scenarios in mind. For example, you might want to start a domain controller virtual machine before you start messaging (Exchange Server) virtual machine which requires Active Directory authentication. Similarly, in a “three-tier” architecture, you must make sure clustered database virtual machines are up and running before you start the middleware virtual machines running Internet Information Server (IIS).
There are three options provided with the “Automatic Start Action” feature which can be configured per virtual machine as shown in the below screenshot:
“Nothing” option, as the name suggests, do nothing when the Hyper-V Server starts for this virtual machine particularly.
Option “Automatically start if it was running when the service stopped” can be used if you want Hyper-V Virtual Machine Management Service (VMMS.EXE) to start the virtual machine automatically only if it was running when the Hyper-V Virtual Machine Management Service was stopped.
Well, I think this is not the option organizations would like to go with for any of the production virtual machines. First of all, in any production environment, there is a process defined even for starting up virtual machines either manually or automatically. It depends on the type of virtual machine and how critical it is for the business. For example, this option might not be a good option for virtual machines which are running banking applications which store their data on a clustered virtual machine. In this case, you would always want to start the clustered database virtual machine first before starting the banking application virtual machine. This option might be a good fit for virtual machines which are non-critical and must be started automatically.
By default, all the newly created virtual machines are configured with this option.
“Always start this virtual machine automatically” instructs Hyper-V Virtual Machine Management Service to always start this virtual machine automatically when the Hyper-V server restarts. Use this option only when you think the services offered by the virtual machine are very critical to the business and the virtual machine needs to be up and running as soon as possible. This is actually helpful if Hyper-V Server restarts from an unexpected failure.
The “Startup Delay” option is helpful when you have Root and Child domain controllers set up in a virtual environment. Let’s say, all of a sudden something happens to the Hyper-V Server and it restarts. As part of the initialization process, which is explained later in this article, all the virtual machines will be initialized/started by the Hyper-V Virtual Machine Manager Service. If you have not set “Startup Delay” option then all the Root and Child domain controller virtual machines will start concurrently. This might cause some failures if the Root domain controller virtual machines are not up and running before Child domain controller virtual machines start. In this case, it is necessary to use either “Automatically start if it was running when the service stopped” or “Always start this virtual machine automatically” option with a “Startup Delay” value to make sure Root domain controller virtual machines start first before the Child domain controller virtual machines can be started.
This is more explained in the logic explained below. When the Hyper-V Server is restarted, the following events occur:
- Hyper-V initializes hypervisor code on the hardware.
- Hypervisor creates virtual environment.
- After creating the Virtualization environment, the control is returned to the Parent Partition.
- The Parent Partition, in turn, returns the control to its component called VMMS.exe or Hyper-V Virtual Machine Management Service.
- VMMS.exe is a multi-threaded application. It can initialize and start a virtual machine and get the control back to initialize and start other virtual machines. VMMS.exe does not have to wait for the virtual machine to be up and running before starting the next one. VMMS.exe performs two operations for a virtual machine at start up; (1) initialize the virtual machine to make sure its VHD files and configuration files are intact and (2) Start the virtual machine.
- VMMS.exe initializes and starts the virtual machines based on the following logic:
- Filter all the virtual machines which are set to always start automatically or using “Always start this virtual machine automatically” option.
- Filter all the virtual machines which have been configured with “Automatically start if it was running when the service stopped” option.
- Get the “Startup Delay” value for the virtual machines which are using above two options.
- Get all the virtual machines which are using “Nothing” option.
- Once VMMS.exe has the list of virtual machines, it performs the following logic to start these virtual machines:
- Start all the virtual machines for which “Startup Delay” is set to ZERO. That means do not wait for seconds to elapse and start the virtual machines immediately.
- Initialize all the virtual machines for which “Startup Delay” is set to a value other than ZERO and wait for the seconds to elapse before starting the virtual machines.
- Initialize all other virtual machines which are using “Nothing” option but do not start them.
Automatic Stop Action
Let’s talk about the “Automatic Stop Action”. As shown in the below screenshot, there are three options available even for “Automatic Stop Action”.
“Save the virtual machine state” option instructs Hyper-V Virtual Machine Management Service to save the virtual machine state on the local disk when the Hyper-V Server shuts down.
Option “Turn Off the virtual machine” is used by the Hyper-V Management Service (VMMS.exe) to gracefully turn off the virtual machine.
Option “Shut down the guest operating system” is successful only if the “Hyper-V Shutdown” guest service is running in the virtual machine. The guest service is required to be running in the virtual machine as the Hyper-V VMMS.EXE process will trigger Windows Exit message which is received by the service. Once the message is received by the guest service, it takes the necessary actions to shut down the virtual machine.
Note: “Automatic Stop Action” feature is not helpful if Hyper-V Server goes down due to an unexpected failure. The VMMS.exe process must receive the “Windows Exit” message from Operating System before these options can be useful.
In this article, we learned about the different options available with “Automatic Start Actions” and “Automatic Stop Actions” which can be used by each virtual machine running on the Hyper-V. We saw how these options help achieve the different IT scenarios in a virtual environment. We also learned the logic Hyper-V Virtual Machine Management Service (VMMS.exe) utilizes to initialize and start the virtual machines which are configured to use the “Automatic Start Actions” options.
While I was writing this article, it reminded me to convey a message to the organizations which are running their “critical” business applications in a virtual environment. What I want to convey here is that the Hyper-V Server may also crash. As part of the crash, it impacts all the virtual machines running on the Hyper-V Server which, in turn, impacts the data and applications running inside the virtual machines. So it is always a good practice to perform regular backups of the virtual machines. In case of a sudden failure, you can at least recover your virtual machines and data if you have a good backup copy. Altaro has recently released Altaro Hyper-V Backup 4.0. The new version will not only include the new features but also use the robust algorithm to backup virtual machines running on the Hyper-V which helps in reducing the overall backup size. You download a copy here. It’s a full 30-day trial which lets you back up 2 Hyper-V VMs for free, forever.
Not a DOJO Member yet?
Join thousands of other IT pros and receive a weekly roundup email with the latest content & updates!