Automating the process of starting and stopping virtual machines on VMware ESX (850)
This article explains how to configure the virtual machines to start and stop automatically when powering an ESX Server host on and off. These settings are set on a per host basis. If you vMotion the virtual machine off the host, the settings are not retained.
ESX 4.x and ESXi 5.0
VMware vCenter 4.x and 5.x includes the ability to configure startup ordering. To configure these startup options:
Note: The Virtual Machine Startup and Shutdown (automatic startup) feature is disabled for all virtual machines residing on hosts that are in (or moved into) a VMware HA cluster. Automatic startup is not supported when used with VMware HA.
This issue is resolved in vCenter Server 5.0 Update 1.
- Access the settings:
- Give focus to the host in vCenter.
- Select the Configuration tab.
- Select Virtual Machine Startup / Shutdown under Software.
- Click Properties in the upper right hand side of the window.
- Select the options you want:
- In order to be able to configure any options, enable Allow virtual machines to start and stop automatically with the system.
- Enter a value for the Default Startup Delay, in order to delay the startup activity for a period of time after the boot process completes.
- Enter a value for the Default Startup Delay, in order to delay the startup activity for a period of time after the boot process completes. Select which Shutdown Action you want to occur:
- Guest Shutdown, to shut down the guest gracefully. This requires up to date VMware Tools to be installed in the guest.
- Power off, to abruptly stops power to the virtual machine, like pulling the power cord on a physical machine
- Suspend, to pause the virtual machine at that moment in time, like hibernating a physical machine
- To start up the virtual machines in a particular order, configure the three
- Automatic: This category allows you to choose the sequence, by moving machines into this category, then arranging them in order.
- Any order: In this category, the machines are started in whatever sequence the host prefers (more or less randomized).
- Manual: In this category, the default, the machines are not automatically restarted. You must power them on manually.
- Click OK when finished.
VMware ESX 3.0 and 3.5
You can manage startup and shutdown options using the VMware Infrastructure or vSphere client.
To manage virtual machine startup and shutdown options:
- Log into the client and select an ESX host from the inventory.
- Click the Configuration tab.
Virtual Machine Startup/Shutdown, configure your virtual machine startup options, as required.
Using vmware-cmd for ESX Server 2.1 and 2.5
Starting with ESX Server 2.1, the Management Interface provides start and stop options for virtual machines. The script vmstartstop.pl was also removed and the functions provided by that script were incorporated into vmware-cmd.
For more information, see Setting Startup and Shutdown Options for a Virtual Machine in the ESX Server 2.5 Administration Guide.
The VMware Scripting API User's Manual discusses vmware-cmd command syntax. For more information, see www.vmware.com/support/developer/scripting-API/.
Using vmstartstop.pl for ESX Server 2.0.1 and earlier versions
To automatically start virtual machines, add one of these configuration options to the virtual machine's configuration (.cfg or .vmx) file:
autostart = true
autostart = poweron
autostart = resume
poweronsettings are treated the same.
- Use the
resumesetting if you have suspended the virtual machine and want it to resume automatically.
The vmware init script calls
/usr/sbin/vmstartstop.pl script. This script looks for virtual machines listed in vm-list that contain one of the above options in their configuration files.
If you want to automatically shut down or suspend the virtual machine as well, add one of these configuration options to the virtual machine's configuration file:
autostop = suspend
autostop = poweroff
To stagger the startup of virtual machines, add this option to each virtual machine's configuration file:
autostart.delay = n
n is the number of seconds ESX Server waits after powering on this virtual machine before it proceeds to the next virtual machine.
Example: If you add the option
autostart delay = 60, ESX waits one minute after it starts this virtual machine before starting the next virtual machine.
The same is true for automatically stopping the virtual machines. Use this configuration option:
autostop.delay = n
- You can set a maximum delay of two minutes (120 seconds) between stopping each virtual machine.
- The stop script loops for up to a maximum of five minutes, until all virtual machines are stopped.
- This information is documented in the comments in the