Configure Autostart of VM on VMware ESXi

By default, virtual machines located on VMWare ESXi (Free Hypervisor) or VMWare Workstation are not starting automatically at the host boot. It means that after the ESXi/Workstation host reboot (planned restart or crash) the Administrator has to manually start all the virtual machines. In this guide, we will show how to configure Autostart VMs on the ESXi and VMWare Workstation host without Administrator intervention.

How to Configure VM Autostart on VMware ESXi?

At first, open the browser and go to the login screen page of the VMware Web Client. Then log on. In the Web Client console, select ESXi host which you want to configure for VMs autostart. Then go to the following tab Manage > System > Autostart.

Tip. If your ESXi host is managed by the vCenter Server and is a part of the vSphere HA cluster, you can’t configure VM autostart and shutdown settings this way. This is happening because the HA cluster responds for the availability of VMs.

As you can see all the virtual machines disposed on a given ESXi are not configured to start automatically (Autostart order = Unset). It means that after host reboot you will have to start them manually.

vmware autostart vm after power failure

To be booted automatically, you need to enable autostart for VM.

Select VM you want to boot automatically and click Enable.

vmware start vm on boot

The Autostart order field should display a value of 1. This means that this VM will boot first after the ESXi host boots. With the Start later and Start earlier buttons, you can manage the order in which the virtual machines start.

vcenter autostart vm

When configuring autostart for virtual machines, the ESXi host administrator must properly configure the boot order. For example, the domain controller should be booted first, then Exchange servers or you should start the application’ server only after booting MSSQL VM, etc.

You can configure other parameters of VM autostart by clicking the Configure button. In the Configure Autostart window, the following options are available to fine tune the automatic VM startup.

vmware autostart

There are common options for startup and shutdown behavior:

  • Startup delay — how many seconds VMs wait before powering on (by default it’s 120 seconds). After the ESXi host powers up the first VM, the host waits for the specified delay time and then powers up the next virtual machine. This delay allows you to wait for booting of custom services and scripts execution;
  • Shutdown delay — specifies the time delay before shutdown of each virtual machine (by default it’s 120 seconds). If the virtual machine does not shut down within the specified delay time, a hard shutdown command is sent to the virtual machine;
  • Stop Action — for each VM available 4 shutdown actions: System default, Shut Down, Suspend, or Power off. Use the opportunities of VMware Tools that you need to pre-install in the guest operating system. By default used action is Shut down.
  • Wait for heartbeat — if enabled, the power-up sequence continues after the first heartbeat is received from the virtual machine. To do this, the VMWare tools must be installed in the guest OS of the virtual machine. After the ESXi VM boots up, go to the next VM immediately as soon as the VM tools send a heartbeat to signal its startup (instead of waiting for a startup delay interval).

The following Stop Actions are available:

  • System Default — the global Stop Action settings are applied to the VM ( from Host > Manage > Autostart);
  • Power Off — forced shutdown of VM. This is the equivalent of you physically pulling the power cord out of a physical computer. This action immediately kills the VM with no graceful stopping services, saving of files or cache;
  • Suspend — the state of the running virtual machine (including memory, swap, CPU instructions) is saved to files on your datastore. VM can be resumed from a sleep state at exactly the same point later on;
  • Shutdown — performs a graceful shutdown of VM. For this feature to work, the guest OS must have VMTools installed, which sends a command to shut down the OS properly.

Click OK to save your changes and close the dialog box.

You can configure autostart settings that will be applied to all new virtual machines on the ESXi host. To do this, click the Edit Settings button at the top of the Autostart dialog box.

esxi start vm on boot

To enable autostart for all VMs, change the Enabled to Yes. And select start/stop delay and stop action.

Tip. If you have not configured the HA, but it is possible to move VMs between hosts using vMotion, startup settings are migrating to the destination host with VM.

Configure Autostart of VM Using PowerCLI

Also, you can configure the auto-start setting of the VM using PowerCLI.  Display a list of the auto-start action for all VMs on the host:

Get-VM –VMname * | Select-Object VMname, AutomaticStartAction

To enable Automatic Startup for all VMs which name starts with lon-, run the following command:

Get-VM –VMname lon-* | Set-VM –AutomaticStartAction Start

That’s it! You have successfully configured automatic startup for virtual machines on VMWare ESXi or vSphere Center.

In VMWare ESXi 6.0, there was a strange bug. Despite the fact that the auto-start priority for virtual machines is configured, after the host server reboot, only the first virtual machine starts automatically. The second virtual machine stubbornly refuses to boot.

To solve this problem, you need to enable SSH access on the ESXi and connect to the host using any SSH client (for example, Putty).

Get a list of virtual machine IDs:

vim-cmd vmsvc/getallvms

Enable force auto-start feature:

vim-cmd hostsvc/autostartmanager/enable_autostart true

Now check the VMs startup settings:

vim-cmd hostsvc/autostartmanager/get_autostartseq

(vim.host.AutoStartManager.AutoPowerInfo) {

key = ‘vim.VirtualMachine:1’,

startOrder = 1,

startDelay = -1,

waitForHeartbeat = «systemDefault»,

startAction = «powerOn»,

stopDelay = -1,

stopAction = «systemDefault»

},

(vim.host.AutoStartManager.AutoPowerInfo) {

key = ‘vim.VirtualMachine:2’,

startOrder = 2,

startDelay = -1,

waitForHeartbeat = «systemDefault»,

startAction = «none»,

stopDelay = -1,

stopAction = «systemDefault»

}

As you can see, in this case, the first VM with ID 1 is set to autostart (startAction = “powerOn”), while the second one does not (startAction = “none”).

In this case, it is enough to re-register the problematic VM on the host using the commands:

vim-cmd /vmsvc/unregister 2

vim-cmd solo/registervm /vmfs/volumes/VMFS1/Lon-VM1/Lon-VM1.vmx

Check the startup parameters again:

vim-cmd hostsvc/autostartmanager/get_autostartseq

Make sure the startAction value of the new VM has changed to powerOn.

Autostart VMware Workstation Virtual Machines at Boot

The desktop virtualization software VMware Workstation also does not provide the ability to automatically startup the virtual machines at Windows boot. To start the VM from the command prompt, you can use the utility vmrun.exe. It is located in the folder with the installed Workstation.

You can run any virtual machine by creating the following batch file AutoStartVM.bat.

start “C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe” “D:\VM\TestVm1\TestVm1.vmx”

ping 127.0.0.1 -n 40 > nul

start “C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe” “D:\VM\freebsd2\freebsd2.vmx”

The second code line is used to create a 40-second delay before starting the second VM. This bat file can be put on the desktop (and started manually by double click), added to the Windows Startup, or run by the task scheduler job.

You can also convert your virtual machine to a Shared VM (VM > Manage > Share).

Select in the main window Shared VMs > Manage AutoStart VMs.

In the Configure AutoStart window that opens, you can choose which virtual machines will start with the host. You can also change the delay between the start of each virtual machine (in seconds).

I enjoy technology and developing websites. Since 2012 I'm running a few of my own websites, and share useful content on gadgets, PC administration and website promotion.
Cyril Kardashevsky

5 comments

  1. can this be done without vSphere or VCenter? I’m using the free ESXI license for my home lab, and I don’t have VSphere or Vcenter since those are not included. The Web interface lets me enabled autostart, and the guest actions also let you raise or lower the machine’s autostart priority. What it doesn’t let me do is it select which guests are included in autostart. I’ve searched all over the interface and cannot find it.

    Help!

    1. Unfortunately, we have free ESXI installed, but most likely you can manage autostart settings via vSphere Web Host client similarly as in the paid version of ESXi / vSphere:
      Manage->System->Autostart-> Edit settings. And change Enabled to Yes

  2. Isn’t – Shutdown Delay – the maximum time the host will wait before it powers off the VM, and not “Specifies the time delay before shutdown each virtual machine”. I believe its documented on VMware’s website somewhere.

    1. There are 2 conflicting articles on VMWare’s website:

      kb.vmware.com/s/article/1004421

      “Shutdown delay is the maximum time the ESXi host will wait for a shutdown command to complete. If the Virtual Machine does not shutdown within the delay time specified a power off is issued to the Virtual Machine.”

      pubs.vmware.com/vsphere-51/index.jsp?topic=%2Fcom.vmware.vsphere.vm_admin.doc%2FGUID-5FE08AC7-4486-438E-AF88-80D6C7928810.html

      “Shutdown Delay – When you power off the ESXi host, it starts powering off the virtual machines that run on it. The order in which virtual machines are powered off is the reverse of their startup order. After the ESXi host powers off the first virtual machine, the host waits for the specified shutdown delay time and then powers off the next virtual machine. The ESXi host shuts down only after all virtual machines are powered off.”

      It seems correct for us to say that if the VM shuts down before that delay time is reached, the next virtual machine starts shutting down.

      1. Good find and I was confused about the meaning as well. Was somebody able to clarify what the correct meaning of the Shutdown delay is?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.