Jump to content











Photo
- - - - -

Running Virtual Machines within WinPE

winpe virtual pxe hyperv host

  • Please log in to reply
4 replies to this topic

#1 DanG1T

DanG1T
  • Members
  • 2 posts
  •  
    United Kingdom

Posted 3 weeks ago

Bit of a fun project I'm working on...

 

Running WinPE as a server OS, live from the network.

I have a set of scripts that are dynamically returned depending on the MAC Address of the client requesting them,

essentially bootstrapping what ever app/script is required into WinPE.

If the box dies or the OS reboots, no big deal. The apps I've written are designed to work with this (self-healing etc.)

 

It all works! Looking to take it a step further:

 

Now comes the big ask - Has anybody tried (or even started to try) and get VMs to run inside WinPE with SMB shares mounted for VM disk storage?

 

I've only seen one instance of someone trying to get virtualbox to run with little results.

 

Would be happy to show some of the code I have!

 

5jT6fBg.png


  • Nuno Brito likes this

#2 erwan.l

erwan.l

    Gold Member

  • Developer
  • 2343 posts
  • Location:Nantes - France
  •  
    France

Posted 3 weeks ago

Have look at possible portable versions for virtualbox, vmware workstation, ms virtualserver, etc?

 

Of all virtualisation softwares, QEMU is maybe the easiest one : portable, little or no dependency, etc ...

 

Now question is : why would you run a VM in Winpe?

Is not this easier to "just" boot another machine over the network since you are into booting over the network.

 

About SMB, consider other solutions such as iscsi, aoe, etc to take it lower into the OSI layers and not have to mess with ACL's.

 

Cheers,

Erwan



#3 RoyM

RoyM

    Frequent Member

  • .script developer
  • 416 posts
  • Interests:"Booting and Owning".
  •  
    United States

Posted 3 weeks ago

Below worked fine.
qemu-system-x86_64.exe file version=(2.1.3.0)
qemu-system-x86_64.exe -boot d -m 2048 -cdrom "E:\10PE2\ISO\Win10PESE_x64.iso" -L "E:\Qemu\pc-bios"
 
My Setup= Toshiba Satellite C655D-S5518 w/6G Ram, 1T SSD, Booting Grub4Dos --> Win10PESE_x64.iso== 2.25G
I also run PeBakery on Toshiba to build the very .iso that it boots from.
The qemu I am using is the one that comes with PeBakery.
(Above is a dedicated field-laptop running Win10_x64 and RTL-SDL's)
 
I currently have an HP Proliant ML150 Gen3, 2 Quad Cpus, with Raid10 Arrays. @16G Ram ECC
That I run a Win7PE_x64 on and use for testing and simple file sharing.
I would be happy to see some of the code you have, In return I can assist.
 
Regards
RoyM

Edited by RoyM, 3 weeks ago.
Added ram specs


#4 DanG1T

DanG1T
  • Members
  • 2 posts
  •  
    United Kingdom

Posted 3 weeks ago

Have look at possible portable versions for virtualbox, vmware workstation, ms virtualserver, etc?

 

Of all virtualisation softwares, QEMU is maybe the easiest one : portable, little or no dependency, etc ...

 

Now question is : why would you run a VM in Winpe?

Is not this easier to "just" boot another machine over the network since you are into booting over the network.

 

About SMB, consider other solutions such as iscsi, aoe, etc to take it lower into the OSI layers and not have to mess with ACL's.

 

Cheers,

Erwan

 

I completely forgot about QEMU! Good shout, I'll take a look next weekend when I have a bit of time :)

 

As for running VMs in WinPE, my project is going to run services anyway, why not make it able to run anything?

 

iSCSI is certainly an option to explore, I know its relatively simple getting iSCSI Initiator in there and I can script it easily.

The problem is at the server end for making iSCSI LUNs on the fly, but its very easy with SMB - I use SMB all the time and can deal with ACLs. Go look at the state machine for iSCSI, fuck building that lol https://tools.ietf.org/html/rfc7143

 

 

 

Below worked fine.
qemu-system-x86_64.exe file version=(2.1.3.0)
qemu-system-x86_64.exe -boot d -m 2048 -cdrom "E:\10PE2\ISO\Win10PESE_x64.iso" -L "E:\Qemu\pc-bios"
 
My Setup= Toshiba Satellite C655D-S5518 w/6G Ram, 1T SSD, Booting Grub4Dos --> Win10PESE_x64.iso== 2.25G
I also run PeBakery on Toshiba to build the very .iso that it boots from.
The qemu I am using is the one that comes with PeBakery.
(Above is a dedicated field-laptop running Win10_x64 and RTL-SDL's)
 
I currently have an HP Proliant ML150 Gen3, 2 Quad Cpus, with Raid10 Arrays. @16G Ram ECC
That I run a Win7PE_x64 on and use for testing and simple file sharing.
I would be happy to see some of the code you have, In return I can assist.
 
Regards
RoyM

 

 

Fantastic to hear! I'll grab that version and throw it in the provisioning script to see if i can get it to boot and auto start a VM.

Next will come network support...

 

As for the code, it starts with a TFTP Server just to boot a rom-o-matic build of iPXE to start the fun stuff.

I'm using a good .NET library called TFTP.net that's very event-y.

It also starts an HTTP Server for all boot files and WIMs, which I'm going to build database interaction into so you can define what you want each client to load and what config to run.

iPXE then pulls down a config depending on the MAC address of the boot NIC:

chain --autofree http://pecloud.hexagon.red/ipxe/${net0/mac}/menu.ipxe || echo ${HTTP_ERR}

I then wrote an HTTP router similar to ExpressJS to handle the same kind of syntax, which in the future when I hook it up to a db should simplify things:

    Sub InitPXERoutes()
        _parentRouter.AddRoute("/boot.ipxe", AddressOf ChainLoader)
        _parentRouter.AddRoute("/boot.cfg", AddressOf BootConfigLoader)
        _parentRouter.AddRoute("/menu.ipxe", AddressOf MenuLoader)
        _parentRouter.AddRoute("/wimboot", AddressOf Wimboot)
        _parentRouter.AddRoute("/windows.ipxe", AddressOf WinLoader)
        _parentRouter.AddRoute("/windows/bootmgr", AddressOf Windows)
        _parentRouter.AddRoute("/windows/boot/bcd", AddressOf Windows)
        _parentRouter.AddRoute("/windows/boot/boot.sdi", AddressOf Windows)
        _parentRouter.AddRoute("/windows/sources/boot.wim", AddressOf Windows)
        _parentRouter.AddRoute("/init.ps1", AddressOf PowerShellInit)
        _parentRouter.AddRoute("/init/:macaddress/init.ps1", AddressOf PowerShell)
        _parentRouter.AddRoute("/ipxe/:macaddress/menu.ipxe", AddressOf IPXEInit)
    End Sub
        Select Case context.Request.Url.AbsolutePath
            Case "/windows/bootmgr"
                HttpRouter.returnFile(context, "C:\Users\Dan\Documents\hbcd\x64\bootmgr")
            Case "/windows/boot/bcd"
                HttpRouter.returnFile(context, "C:\Users\Dan\Documents\hbcd\x64\boot\bcd")
            Case "/windows/boot/boot.sdi"
                HttpRouter.returnFile(context, "C:\Users\Dan\Documents\hbcd\x64\boot\boot.sdi")
            Case "/windows/sources/boot.wim"
                HttpRouter.returnFile(context, "C:\PESE\ISO\TI\WIM\sources\boot.wim")
        End Select

It's very simple at the moment for testing things but I can't wait to build it into something that could deploy a whole farm of servers in a matter of minutes!

 

Arguably I could have done a very similar thing with a linux based OS (which would probably be better for VM Stuff) but my original idea was to run .NET apps native without mono.



#5 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10543 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 3 weeks ago

QEMU is well tested and works OK.

 

Best would be VirtualBox because of the hardware acceleration. It was possible many years ago, not sure if the older scripts would be up-to-date for this task in current days.

 

:cheers:







Also tagged with one or more of these keywords: winpe, virtual, pxe, hyperv host

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users