Contributor
Contributor

force VM to pxe boot?

Jump to solution

Is it possible to use the VI Toolkit for windows to force a VM to pxe boot at first (or next) boot time? If it were as simple as changing the boot sequence that would be ok.

Thanks

0 Kudos
1 Solution

Accepted Solutions
Leadership
Leadership

I think using the bios.bootDeviceClasses option in the .vmx file is a bit easier.

See also .

You could execute this script:

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.extraConfig += New-Object VMware.Vim.OptionValue
$spec.extraConfig[0].key = "bios.bootDeviceClasses"
$spec.extraConfig[0].value = "allow:net"
 
(get-view (Get-VM -Name "TestPC").ID).ReconfigVM_Task($spec)

It will only allow a boot from the network card, in other words a PXE boot.

Afterwards you reset the allowed boot devices with a similar script.

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.extraConfig += New-Object VMware.Vim.OptionValue
$spec.extraConfig[0].key = "bios.bootDeviceClasses"
$spec.extraConfig[0].value = "allow:hd,cd,fd"
 
(get-view (Get-VM -Name "TestPC").ID).ReconfigVM_Task($spec)

Note1: the abbreviations for the bios.bootDeviceClasses parameter are:

  • fd floopy drive

  • hd hard disk

  • cd cdrom drive

  • net network card

Note2: this option does not change the boot order, it only changes the list of devices that the VM is allowed to boot from.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
14 Replies
Enthusiast
Enthusiast

You may have already seen this, but here is a link about copying the nvram file that stores the boot order information.

http://communities.vmware.com/thread/13314

Took a quick peek through the SDK and did not see an obvious way to set/change this value. So maybe using Powershell with Plink to run the cp command.

Contributor
Contributor

Thanks for the reply. We might be able to get that to work.

0 Kudos
Leadership
Leadership

I think using the bios.bootDeviceClasses option in the .vmx file is a bit easier.

See also .

You could execute this script:

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.extraConfig += New-Object VMware.Vim.OptionValue
$spec.extraConfig[0].key = "bios.bootDeviceClasses"
$spec.extraConfig[0].value = "allow:net"
 
(get-view (Get-VM -Name "TestPC").ID).ReconfigVM_Task($spec)

It will only allow a boot from the network card, in other words a PXE boot.

Afterwards you reset the allowed boot devices with a similar script.

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.extraConfig += New-Object VMware.Vim.OptionValue
$spec.extraConfig[0].key = "bios.bootDeviceClasses"
$spec.extraConfig[0].value = "allow:hd,cd,fd"
 
(get-view (Get-VM -Name "TestPC").ID).ReconfigVM_Task($spec)

Note1: the abbreviations for the bios.bootDeviceClasses parameter are:

  • fd floopy drive

  • hd hard disk

  • cd cdrom drive

  • net network card

Note2: this option does not change the boot order, it only changes the list of devices that the VM is allowed to boot from.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
Contributor
Contributor

I think this will work great. I can specify the boot order manually to have pxe first which would propegate down to clones and just change it to either allow or disallow via the script. Correct?

0 Kudos
Leadership
Leadership

That should work, haven't tried it yet that way.

Good idea !


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Contributor
Contributor

Thanks Luc, this gave me what I was after.

0 Kudos
Expert
Expert

Hi LucD, how can I get this to work with a Resource pool instead of per VM?

Thanks!

If this post has been helpful/solved your issue, please mark the thread and award points as you see fit. Thanks!
0 Kudos
Leadership
Leadership

The only way I can see is to make the change for each VM in the resource pool.

The setting is per VM and can, afaik, not be done per resource pool.

So if you move a VM to another resourcepool, the boot settings will stay with the VM.

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.extraConfig += New-Object VMware.Vim.OptionValue
$spec.extraConfig[0].key = "bios.bootDeviceClasses"
$spec.extraConfig[0].value = "allow:net"

Get-ResourcePool MyPool | Get-VM | %{

     $_.Extensiondata.ReconfigVM_Task($spec)
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Contributor
Contributor

Hi Smiley Wink

i have the problem that often the Boot order of the Disk itself are changing. don't know why.

therefore i would like to force the 0:0 to boot.

But it's not working on my side.

$spec.extraconfig[0].key = "bios.bootOrder"

$spec.extraconfig[0].value = "ethernet0"

for the network it's working

but if i make:

$spec.extraconfig[0].key = "bios.bootOrder"

$spec.extraconfig[0].value = "scsi0:0"

the disk is still on 3ird place.

because i have 0:0,  0:1 , 1:0

thx

max

0 Kudos
Leadership
Leadership

The "bios.bootOrder" parameter is afaik only available from Workstation 7 and Fusion 3 onwards.

On ESX the disk boot order is not stored in the VMX file but in the NVRAM file.

You could configure 1 setup manually like you want it and then push that NVRAM file.

But, I don't what else is kept in the NVRAM file, so I have no clue what could break as a result of copying the NVRAM file.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Immortal
Immortal

Hi Luc
afaik the nvram also has some info about the used disks and floppy-drives - so if you copy a nvram file to a VM that uses disks of a different size a new nvram would be created

Do you need support with a recovery problem ? - call me via skype "sanbarrow"
0 Kudos
Leadership
Leadership

I was afraid of that, copying the NVRAM file is not the way to go.

In that case I don't think there is a method to define the boot order of the virtual disks.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Immortal
Immortal

I thought the bios.bootOrder parameter was implemented in esx as well - are you sure it does not work ?

Do you need support with a recovery problem ? - call me via skype "sanbarrow"
0 Kudos
Leadership
Leadership

Tried it against an ESX 4.1U1 server, there it doesn't seem to take the bios.bootOrder keyword.

Will try against ESXi 5 later.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos