Changing the boot order of a virtual machine on ESXi using virtual machine advanced option
search cancel

Changing the boot order of a virtual machine on ESXi using virtual machine advanced option

book

Article ID: 326326

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

This article provides steps to change the boot device without using the virtual machine's BIOS and its limitation to 8 visible devices.

Environment

VMware vSphere ESXi 6.0
VMware vSphere ESXi 6.5
VMware vSphere ESXi 6.7
VMware vSphere ESXi 7.0.x
VMware vSphere ESXi 8.0.x

Resolution

Option 1 - Configuring the boot order for a virtual machine with on ESXi 6.x / 7.0 or 8.0 using the using the BIOS boot manager:

  1. Shut down the virtual machine.

  2. Click the virtual machine in the Inventory.

  3. Right click Edit Settings.

  4. In the Virtual Machine Properties dialog, click the VM Options tab.

  5. Under Boot Options, select the check box for Force BIOS setup.

  6. Click OK to save the changes.

  7. Power on the virtual machine

  8. Open a VM console and navigate to the BIOS > Boot section

  9. Select the correct boot order selection and save

     

Option 2 - Configuring the boot order for a virtual machine with legacy BIOS using VM advanced options

The boot device can be selected using the virtual machine advanced options bios.bootOrder and bios.hddOrder. These settings will override the previous boot order selection. 

The virtual machine's boot order can be set to any virtual NIC ethernetX, where X is the number of the device. For example, ethernet0 or ethernet5. It can also be set to hdd, cdrom, or floppy. If set to cdrom or floppy there are multiple devices, the virtual machine tries them sequentially until it finds one to boot from. If bios.bootOrder is set to hdd, also need to define bios.hddOrder and set a device (for example, scsi0:3 or ide1:0) to boot from.

To make this change, ensure that the virtual machine is currently in powered off state, then:

  1. Right-click the VM in vSphere Client.

  2. Select Edit Settings.

  3. In the VM Options tab, select Advanced.

  4. Next to Configuration Parameters, click on EDIT CONFIGURATION.

  5. Select [ADD CONFIGURATION PARAMS] to create the new VM advanced parameters:

For example:
  Name    Value
bios.bootOrder
ethernet5,ethernet2,hdd,cdrom,floppy
bios.hddOrder
scsi2:2,scsi0:1,ide1:0
 
  1. Click [OK], then [OK] again to save the change and exit the VM settings wizard.

To configure the list of devices by editing the VMX configuration file. Ensure that the VM is currently powered off for this. When adding the settings in the VMX file, make sure to put the device list(s) into quotation marks and separate the devices with commas.

For example:

bios.bootOrder = "ethernet5,ethernet2,hdd,cdrom,floppy"
bios.hddOrder = "scsi2:2,scsi0:1,ide1:0"

In this example, the virtual machine tries to boot with ethernet5. If there is nothing to boot from, try ethernet2. If that fails, try from the disks (hdd) defined in hddOrder, then all CD-ROMs, and finally from all floppies.

Note: Adding these advanced options will block changing the boot order in the BIOS setup, and to be able to use the BIOS to make boot order changes, remove both options while the VM is in powered off state. The next time the VM is powered on, it will use the boot order which was originally configured in the BIOS setup.

 

Option 3 - Configuring the boot order for a virtual machine with either legacy BIOS or EFI using PowerCLI

 PowerCLI can be used to change the boot order for a virtual machine, using a script like the example below. This is the only way to set a persistent boot order for EFI VMs.

This example assumes the VM is confirmed with a virtual disk and a virtual NIC, and a CDROM, and the VM should boot from the NIC first and then try the virtual CDROM:
$strVMName = "vm-name"
$strBootNICDeviceName = "Network adapter 1"
$strBootHDiskDeviceName = "Hard disk 1"
$viewVM = Get-View -ViewType VirtualMachine -Property Name, Config.Hardware.Device -Filter @{"Name" = "^$strVMName$"}
$intNICDeviceKey = ($viewVM.Config.Hardware.Device | ?{$_.DeviceInfo.Label -eq $strBootNICDeviceName}).Key
$oBootableNIC = New-Object -TypeName VMware.Vim.VirtualMachineBootOptionsBootableEthernetDevice -Property @{"DeviceKey" = $intNICDeviceKey}
$intHDiskDeviceKey = ($viewVM.Config.Hardware.Device | ?{$_.DeviceInfo.Label -eq $strBootHDiskDeviceName}).Key
$oBootableHDisk = New-Object -TypeName VMware.Vim.VirtualMachineBootOptionsBootableDiskDevice -Property @{"DeviceKey" = $intHDiskDeviceKey}
$oBootableCDRom = New-Object -Type VMware.Vim.VirtualMachineBootOptionsBootableCdromDevice
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec -Property @{
    "BootOptions" = New-Object VMware.Vim.VirtualMachineBootOptions -Property @{
        BootOrder = $oBootableNIC, $oBootableCDRom, $oBootableHDisk
    }
}
$viewVM.ReconfigVM_Task($spec)

To verify that the boot order was applied, run the command below.
$vm = Get-VM vm-name; $vm.ExtensionData.Config.BootOptions | Select BootOrder
Expected Outcome:
BootOrder
---------
{4000, VMware.Vim.VirtualMachineBootOptionsBootableCdromDevice, 2000}
The Device Key for NIC is 4000 whereas the Device Key for Hard Disk is 2000.

Note: In addition to updating the boot order in the VM extension data, the script will add the 2 advanced settings bios.bootOrder and bios.hddOrder to its .vmx file. As a result, no modifications to the boot order in the BIOS or EFI setup interface will be allowed.
 
To be able to use the BIOS to make boot order changes, remove both options while the VM is in powered off state.
The next time the VM is powered on, it will use the boot order which was originally configured in the BIOS setup.
 
 


Additional Information

For more information on editing configuration files directly, see Adding/Deleting/Editing a host entry on vCenter server or ESXi host using vi editor.

Note: The virtual machine needs to be powered off and unregistered (removed from the vCenter Server/ESXi inventory) for the .vmx file to be edited safely.

If changes are made to the virtual machine configuration file, register it back with the vCenter Server/ESXi inventory following Registering a virtual machine with the vSphere Web Client.

Note: The settings in this article override the boot order configuration in the BIOS. When adding these settings, changing the boot order in the virtual machine BIOS will be blocked. Therefore, to use the BIOS UI for changing the boot order, the following setting will need to be removed bios.bootOrder and bios.hddOrder if they exist.