Jump to content











Photo
- - - - -

winpe11 with HyperV WSL2 (Sandbox)

winpe hyperv wsl2

  • Please log in to reply
9 replies to this topic

#1 noel

noel

    Frequent Member

  • Advanced user
  • 178 posts
  • Location:nantes
  •  
    France

Posted 21 January 2022 - 09:24 PM

Hi,

Here's a quick description of the method I used to install HyperV, Sandbox, and WSL2 in winpe11.

Of course, I use the initial Winpe11 that I built with my MicroWinpeBuilder script.
So, it will be difficult to create a script for traditional "builders" and projects like win10Xpe.

 

The method in a few lines:

  • I have a VHD containing a Winpe from my script (ADK+additions) and an ISO from Windows 11.
  • Added the context needed to install the FODs:useful context for OptionalFeatures.exe (useful for controls) ISO Components Hive
  • additions in this hive Components that are from Winpe because the ADK brings some specificities.
  • all files of .. \winsxs\manifests: a sorting would have to be done one day
  • files in CatRoot
  • modification of the SYSTEM hive
    - SYSTEMSetupService Reporting APIBaselines
    - Adding services and drivers (without .INF) not included in the FOD
  • lots of additions in ...\winsxs
  • Added 4 FODs with DISM:
    - Microsoft-Hyper-V-Hypervisor
    - Containers-DisposableClientV
    - Microsoft-Windows-Subsystem-Linux --> only for ADM account !!!
    - VirtualMachinePlatform
  • Installing drivers for HyperV and VirtualNetwork with DISMAdding files that are not brought by DISM: the list is long and it is broken into several points of the script

This allows you to get an idea of the method. The script gives all the necessary details if needed.

 

Why not go further by proposing a script for a traditional "builder"?
Of course, it would be possible to identify all the differences (files, registers) to make a script.
But the usefulness of such a solution is far from proven.
This solution worked since winpe10-20H2. I had already shown HyperV in January 2021.
And no interest was shown.
This is proof that the need does not exist.
So I limit myself to what is called THE POC.

It has kept me busy this winter and it's already a lot.  :smile:

 

Why a VHD?
- During the search:
The development of such a solution requires incessant mofications.
You have to explore various avenues, go back sometimes, add files, modify hives, etc.
I often compare with what I call the "FullFlat" reference.
I use Procmon traces a lot during startup. I often use WinDbg.
With a little practice, we understand that an ISO or a Boot.Wim is not the best media during this research.
But VHD lends itself well to this method which I summarize by "test-failure-comparison-modification".
- While using HyperV:
When everything works well, one could use an ISO file for HyperV because this technology uses little hives.
We find his old VMs if they were stored on an external media.
But it's quite annoying to have to rebuild the virtual network and the missing part of the context.
It is also true that VHD requires a backup of hives that is not "authorized" by MS.
- While using WSL2:
I have never used this feature. And I didn't do a test with winpe in an ISO file.
But I found that many parameters are stored in NTUSER. DAT.
The main EXT4 file. VHDX can be stored on external media.
That's why I use a VHD.

 

I drop here the script to add Hyperv Wsl Sandbox (sandbox is not finished) in Winpe11.
It is very messy because it is a work tool in perpetual evolution.
Note: it creates the VHD (MBR type) only once from the boot.wim file of my winpe.
Then "you" need to manually modify the variable in the script so as not to recreate it.
It's not a "builder", it's a work script, I repeat.

 

The script to make the base winpe
The lack of documentation of my scripts discourages potential testers.
But it is mainly the preparation and construction times that remain a brake and a repellent.
It takes several hours to:
- download and install ISO, ADK, "add-on" winpe,
- "unzip" the "install.wim" file with DISM,
- execute the various scripts,
- create the various vhd.

The choice to use the ADK and refuse the use of "non-MS" programs is a deliberate choice and one that I fully assume.
Computer viruses are numerous.

the script to add HyperV Wsl2 Sandbox
FR_W11_CreateWinpeFlatVhdHypervWslSandBox.7z

 

Yes, I know, very useless. But it's good for keeping my mind healthy.

Attached Files


  • wimb and ZEE like this

#2 wimb

wimb

    Platinum Member

  • Developer
  • 3756 posts
  • Interests:Boot and Install from USB
  •  
    Netherlands

Posted 22 January 2022 - 07:42 AM

Interesting ....

 

More Info: How to Install WSL = Windows Subsystem for Linux   -  available for recent Windows 10x64 21H2 until Windows 11x64

 

Install WSL  and  Manual Install WSL  with PDF

 

What is the UsedSize in GB in your VHD with winpe11 with HyperV WSL2 (Sandbox) ?

 

What is the amount of time to run the script ?

 

Your script requires as Source $srcISO="C:\W11\22000.194\Apply-fr\Windows"  and more parameters ....

Write-host -foreground green "Put HyperV, Sandbox and  WLS in Winpe mode Flat into a new VHD (type MBR)."
Write-host -foreground yellow "Please read the information in the script about creating the BCD file."

#
# modifier version et langue avant utilisation
#
#     les 2 premiers caractères du nom du script fournissent la langue "courte"
#
$version="W11"
$langue="Fr"
$langueLong=$langueLongUs="$langue-$langue"


$scriptName = $MyInvocation.MyCommand.Name
"scriptName = $scriptName (V $versionScrip)"
if ($scriptName -like "En*") { $langue="En"}

# danger avec En-Gb et En-us
if ($langue -like "En"){ $langueLong="En-Gb"; $langueLongUs="en-Us"}

# param 1 : le répertoire source ISO
$srcISO="C:\W11\22000.194\Apply-fr\Windows"

# param 2 : le répertoire de base pour créer le VHD
$vhdBase = "C:\MesVHD"

# param 3 : switch création du VHD
#$createVhd=$true
$createVhd=$false

# modif components -------------------------> $false est utile pour la mise au point seulement
$modifRucheCompopnent=$true
#$modifRucheCompopnent=$false


# param 4 : le répertoire contenant le fichier Boot.wim du winpe de référence
#$SrcBoot_wim     = "C:\Users\noelb\Documents\MicroWinpeBuilder-$version-$langue\build\MEDIA\sources\boot.wim"
$SrcBoot_wim     = "C:\MicroWinpeBuilder-W11-FR\Build\media\sources\boot.wim"

$VhdName = "Winpe-$version-$langue-HypervWslSandbox"
$vhdpath = "$vhdBase\$VhdName.vhd"           # $vhdpath = "C:\VHD\Winpe-20H2-Sandbox.vhd"
$label   = $VhdName                          # label    = Winpe-20H2-Sandbox
$vhdsize = 10GB



#3 noel

noel

    Frequent Member

  • Advanced user
  • 178 posts
  • Location:nantes
  •  
    France

Posted 22 January 2022 - 10:52 AM

Thank you for the information links and for your question.

I don't speak a word of English and I only use an automatic translator.
It is for this reason that I avoid intervening too much in this forum.
It took me a very, very long time to understand the purpose of your project VHD_WIMBOOT.
I did not have the necessary basis because I did not know the "WIMBOOT" technology.
But I like to learn despite my age. Thank you.

 

I guess you'll have a good laugh when I announce the size of the VHD file.
But I guess it's possible to reduce it.... A little.
I copied many "manifest, cat" files certainly useless.

A word first about the base I use: winpe and ADK and the CBs
The size of boot.wim = about 480GB
    $t_packages = @( "WinPE-WMI",
                     "WinPE-Scripting",
                     "WinPE-HTA",
                     "WinPE-MDAC",
                     "WinPE-NetFx",
                     "WinPE-PowerShell",
                     "WinPE-PPPoE",
                     "WinPE-RNDIS",
                     "WinPE-Dot3Svc",
                     "WinPE-DismCmdlets",
                     "WinPE-SecureBootCmdlets",
                     "WinPE-StorageWMI.cab"        # pour Iscsi
                  )

 

Then I add many features. The list goes on.
I simply note the one that was the most complicated to discover: the possibility of using KMF/UMF drivers (more than 1 year of research)
It opens the door to many subsequent additions.
The size of Boot.wim becomes: 1.1GB !!!

Should we talk about loading with PXE? No need to talk about it.

 

Then I added hyperv/wsl (sandbox is not finished but?) in the VHD, not in boot.wim !
The size used in a VHD without HyperV/WSL = more than 3GB (if my memory is correct).
I don't have the size detail for HyperV alone or for WSL alone.
The size used in the VHD before installing the Linux distribution = 4.3 GB
To this, it will be necessary to add the size of the EXT4 file.
VHDX of the linux distribution after installation: 1.1GB.
This file is contained in winpe's VHD but it could be stored on another media.

 

Note: whether for hyperv and VMs as well as for WSL, the use of the registry is very limited!
We quickly find his VMs after reboots.

 

>"Your script requires as Source $srcISO="C:\W11\22000.194\Apply-fr\Windows"  and more parameters ...."

yes, the script uses DISM /add-feature. And so the elements must be copied from a source.
My main script that creates my boot.wim requires decompressing install.wim to a directory.
It is this last directory that becomes the source for all subsequent additions.
I don't use Non-Microsoft libraries like "wimlib".

 

>What is the amount of time to run the script ?

On my old computer : 11 minutes

I need to specify the steps in my script to explain the 11 minutes:

  • Creating a fixed-size VHD of 10GB or re-using an existing VHD
  • formatting VHD
  • "APPLY" (I don't know a word either in French or English for this action) of boot.wim in the VHD with
    DSIM /APPLY boot.wim .... long time !
  • preparation of the register and copies of the various files (manifest/cat file : long time)
  • adding FODs
  • adding drivers
  • a few additions I haven't moved yet

 

My script is not usable "as is". He is there to show the method... and discuss eventually.

 

So, I agree, this solution is very decorative but does not serve much purpose.
But using procmon and Windbg is good gymnastics for my brain.

 

I wish you a good day.
Noel



#4 wimb

wimb

    Platinum Member

  • Developer
  • 3756 posts
  • Interests:Boot and Install from USB
  •  
    Netherlands

Posted 22 January 2022 - 11:42 AM

Thanks for all the information. Your English (translation) is good enough to understand what you are doing ....

 

The PowerShell script is quite interesting to me and can help me to improve or extend my scripts.

 

Latest results obtained with VHD_WIMBOOT - UsedSize of about 1.5 GB is possible for Mini-10x64 in VHD booting in UEFI Mode from RAMDISK

 

The recent work is about APPLY in Compact LZX Mode and WIMBOOT Mode is Not used in this case.

It means the VHD can work standalone and is Not connected to WIM file as would be the case for WIMBOOT Mode.

 

Actually the WIMBOOT concept (not used in the present case) is quite easy to explain: 

Most files in the VHD are WOF pointers to the real files that are loaded fast without notice from the connected WIM file.

The WOF pointers consume very little space (less than 1 GB) so that such VHD can be loaded fast into RAM for booting as RAMDISK.

 

The present UEFI RAMDISK configuration is tested and working OK for Adding Printer, Bluetooth + Speakers, Activation and Network 

 

Update Manual:   VHD_WIMBOOT.pdf   - Download:  Win10_2004_English_x64.iso  and  Win11_English_x64v1.iso

 

Short Manual: to make Mini-10x64.vhd with UsedSize Less 1.5 GB in 2 GB VHD booting in UEFI Mode from RAMDISK using SVBus driver

 

WinNTSetup in 25 GB VHD + Online Win_Debloat-40 + Offline Win_Reduce_Trusted-60 + VHD_WIMBOOT_Trusted-65 = Mini-10x64.vhd on USB_FORMAT-63

 

By using the programs then such Mini-10x64 is quite easy to make .....



#5 noel

noel

    Frequent Member

  • Advanced user
  • 178 posts
  • Location:nantes
  •  
    France

Posted 22 January 2022 - 01:42 PM

If my script can bring you new ideas, I'm delighted.

 

Please, one last question about your Mini-10x64.vhd because I'm not sure I understood everything about it:
Is it an OS = winpe or an OS = windows?
In my opinion, it is an OS = Windows since you mention in several places the name of Win ToGo that I know.
In case Mini-10x64.vhd works as an OS=Windows, I assume that changes in the registry and in the files are stored in the VHD.
But I prefer to ask you the question because I often understand very badly (even with a translator).

Thanks in advance
Noel



#6 wimb

wimb

    Platinum Member

  • Developer
  • 3756 posts
  • Interests:Boot and Install from USB
  •  
    Netherlands

Posted 22 January 2022 - 02:00 PM

If my script can bring you new ideas, I'm delighted.

 

 

PowerShell scripts are for me rather new, starting to use it in Win_Debloat since december 2021.

So I am happy to learn from your Powershell scripts  :)

 

Mini-10x64.vhd is indeed OS = Windows so that you can Install anything small and keep the changes in the registry when booting as FILEDISK.

The nice thing is that the OS UsedSize is only 1.5 GB with support to Add devices like Printer and Bluetooth and unknown Network cards.

It is in this aspect more powerful than WinPE ... and still it is small enough to load the Mini-10x64.vhd fast into RAM for booting from RAMDISK.

In this way you have a small powerful portable, always fresh and clean OS useful for servicing purposes ....



#7 noel

noel

    Frequent Member

  • Advanced user
  • 178 posts
  • Location:nantes
  •  
    France

Posted 22 January 2022 - 03:08 PM

Hi Winb

 

>So I am happy to learn from your Powershell scripts

 

I must quickly warn you: my scripts are not examples to follow because they are poorly written drafts.
I do not master the subtleties. And this script has no complexity. 

 

I love this language that manipulates objects and not strings.

The pileline requires gymnastics with the brain.

To write a "big" script, one must keep in mind these two strongly opposed aspects:
speed of writing with few lines of text
versus
speed of execution
Only experience makes it possible to know the best solution because some contexts explode the deadlines!
This language also allows you to include "C#" with all the "dotnet". So you can write/use GUI in the script.
To increase the speed of processing and its "isolation", we can use the "runspace" of PS/C# which are like "threads" of winp32Api.
I stop there with PS.

I do not know if you sometimes consult the site called "enemy" of "others" where I deposit my scripts. It is only to know some more complex possibilities with PS. The downside with my scripts is that I don't take the time to write them properly and changes accumulate without re-writing for more than 5 years.

 

Even if I am not a "guru", maybe I can help you with powershell, do not hesitate to tell me about it.

Best regards.
Noel



#8 wimb

wimb

    Platinum Member

  • Developer
  • 3756 posts
  • Interests:Boot and Install from USB
  •  
    Netherlands

Posted 22 January 2022 - 03:28 PM

Thank you for additional information on using PowerShell script.

 

When reading your script I see already a lot of things that are useful to me.

 

Sure I wil check and need to understand every addition to my scripts and do a lot of testing.



#9 ZEE

ZEE

    Frequent Member

  • Advanced user
  • 104 posts
  •  
    Portugal

Posted 22 January 2022 - 06:57 PM

>> "Yes, I know, very useless. But it's good for keeping my mind healthy." ~> NOT SO FAST!!!

 

Inclusion of WSL is very interesting (also HyperV and iSCSI modules)

 

if you want to use AoE or NBD in windows 10 64bits,

WSL is the only way I know of supplement the lack of recent implementations

of this 2 technologies in Windows...

 

If someone knows of recent 64 bits implentations of AoE and NBD for Windows 64 bits

please let us know... (I'm gonna put this question in the forum when I finish this post ;-))



#10 noel

noel

    Frequent Member

  • Advanced user
  • 178 posts
  • Location:nantes
  •  
    France

Posted 22 January 2022 - 10:53 PM

Thank you for your comment.

Since I read it, I've been looking a bit on the WEB what AOE and NBD are.
And now I have a huge headache because my old brain can't grasp these complex novelties.

 

Winb's Mini-10x64 solution, which "looks a lot" like a WinToGo in a small volume, can be a very good approach.

 

For Winpe, my script remains experimental because it is based only on a winpe that I built without using classic "builders".
Adapting another "builder" is impossible for me because I don't understand the language used.

It would be necessary for specialists of these other builders to make the necessary modifications since I am unable to do so.

Also, outside of a VHD, I don't believe the Winpe/hyperV-WSL pair is effective.

But before that, it would be necessary to check that "my" vhd as it stands meets the need.
Since no one can use my scripts (and I understand it because without documentation....), I can share a large file for a possible test.

 

Thank you again for your comment which taught me a lot of things in a few words.
Kind regards
Noel






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users