14 Replies Latest reply on Nov 21, 2011 5:37 AM by LucD

    force VM to pxe boot?

    fleeb Enthusiast

       

      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

       

       

        • 1. Re: force VM to pxe boot?
          dmn0211 Hot Shot

           

          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.

           

           

          1 person found this helpful
          • 2. Re: force VM to pxe boot?
            fleeb Enthusiast

             

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

             

             

            • 3. Re: force VM to pxe boot?
              LucD Guru
              User ModeratorsCommunity WarriorsvExpert

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

              See also Specify the boot devices for a virtual machine.

               

              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.

              • 4. Re: force VM to pxe boot?
                fleeb Enthusiast

                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?

                • 5. Re: force VM to pxe boot?
                  LucD Guru
                  User ModeratorsCommunity WarriorsvExpert

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

                  Good idea !

                  • 6. Re: force VM to pxe boot?
                    fleeb Enthusiast

                    Thanks Luc, this gave me what I was after.

                    • 7. Re: force VM to pxe boot?
                      piaroa Master

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

                       

                      Thanks!

                      • 8. Re: force VM to pxe boot?
                        LucD Guru
                        User ModeratorsvExpertCommunity Warriors

                        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)
                        }

                         

                        • 9. Re: force VM to pxe boot?
                          MadMax1980 Enthusiast

                          Hi

                           

                          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

                          • 10. Re: force VM to pxe boot?
                            LucD Guru
                            Community WarriorsUser ModeratorsvExpert

                            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.

                            • 11. Re: force VM to pxe boot?
                              continuum Guru
                              Community WarriorsvExpertUser Moderators

                              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

                              • 12. Re: force VM to pxe boot?
                                LucD Guru
                                vExpertUser ModeratorsCommunity Warriors

                                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.

                                • 13. Re: force VM to pxe boot?
                                  continuum Guru
                                  Community WarriorsvExpertUser Moderators

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

                                  • 14. Re: force VM to pxe boot?
                                    LucD Guru
                                    Community WarriorsUser ModeratorsvExpert

                                    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.