VMware Cloud Community
fleeb
Contributor
Contributor
Jump to solution

force VM to pxe boot?

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

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
14 Replies
dmn0211
Enthusiast
Enthusiast
Jump to solution

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.

fleeb
Contributor
Contributor
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
fleeb
Contributor
Contributor
Jump to solution

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?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Good idea !


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

Reply
0 Kudos
fleeb
Contributor
Contributor
Jump to solution

Thanks Luc, this gave me what I was after.

Reply
0 Kudos
piaroa
Expert
Expert
Jump to solution

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!
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
MadMax1980
Contributor
Contributor
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
continuum
Immortal
Immortal
Jump to solution

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 VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
continuum
Immortal
Immortal
Jump to solution

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 VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos