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 VM 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 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 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 VM.

As you can see all the virtual machines disposed on a given ESXi host are in the Manual Startup section. It means that after host reboot you will have to start them manually.

To be booted automatically, you need to add VMs manually to the Automatic Startup list.

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 possible to configure the auto-start settings for VMs now.

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). 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);
  • Shutdown Actionfor each VM available 4 shutdown actions: None, Power Off, Suspend, or Guest Shutdown. Use the 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 one of the following sections:

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

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

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

Also, you can configure 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).

READ ALSO  Time Configuration for a Virtualized Domain Controllers

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 task scheduler job.

READ ALSO  LZX — new Windows 10 NTFS compression algorithm

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

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.