Configure Autostart of VM on VMware ESXi

By default, virtual machines located on VMWare ESXi (Free Hypervisor) or VMWare Workstation is not starting automatically at the host boot. This means that after the ESXi/ Workstation host reboot (planned restart or crash, for example, caused by a power failure), Administrator have to manually start all the virtual machines. In this guide we will show you how to configure Autostart VM on the ESXi and VMWare Workstation host without Administrator intervention.

How to Configure VM Autostart on VMware ESXi?

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

Tip. If your ESXI host is a part of vSphere HA cluster, you can’t configure VM autostart and shutdown settings this way, because HA cluster respond for the availability of VM.

As you can see all of the virtual machines disposed on a given ESXi host are in Manual Startup section. This means that after host rebooting they will have to be started manually.

In order to be booted automatically you need to add VMs manually to the Automatic Startup list.

READ ALSO  Converting Thick Provision Lazy Zeroed Disk to Thin on VMware ESXi

Click the Edit button.

esxi autostart vm

In the dialog Edit VM Startup and Shutdown check on Allow virtual machine to start and stop automatically with the system. It is now possible to configure the auto start settings for VMs.

There are common options of startup and shutdown behavior:

  • Startup delay — How many seconds VMs wait before powering on (by default 120 seconds). This delay allows you to wait for booting of custom services and scripts execution;
  • Shutdown delay — Specifies the time delay before shutdown each virtual machine (by default 120 seconds);
  • Shutdown Action — for each VM available 4 shutdown actions: None, Power Off , Suspend or Guest Shutdown (using opportunities of VMware Tools, that you need to pre-install in the guest operating system). Вy default used action is Power Off.

esxi auto start vm

You can place VM to the one of the following sections:

  • Automatic Startup — all virtual machines in this section are starting automatically after the completion of the ESXi host boot. Administrator specifies a specific boot sequence of virtual machines. For example, domain controller should be booted first, then Exchange servers etc;
  • Any Order — VMs powering on automatically in random order;
  • Manual Startup — Administrator should start these VMs manually.

Select desired virtual machine and use Move up button to move it to Automatic Startup section. Similar action is performed with all the VMs on the ESXi host.

READ ALSO  Change Default OU permissions in Active Directory

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

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

In addition, you can configure autostart 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 autostart priority for virtual machines was configured, after the host server was rebooted, only the first virtual machine was automatically started. 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 autostart 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 problem 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 that 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 which 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) or added to the Windows Startup or run by 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).

Cyril Kardashevsky
Latest posts by Cyril Kardashevsky (see all)

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.