Jump to content











Photo

Install Windows from unmodified Windows install ISOs by using grub2 and wimboot

grub2 windows install

  • Please log in to reply
26 replies to this topic

#1 steve6375

steve6375

    Platinum Member

  • Developer
  • 6996 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 21 January 2019 - 01:34 PM

By using wimboot from the iPXE project it is possible to directly MBR-boot to grub4dos or grub2 from a USB drive and install Windows onto a target system by just using unmodified Windows install ISOs.

 

It is also possible to specify any unattend.xml you wish (optional).

 

Instead of running Setup.exe as shown in the examples, you could use WinNTSetup or DISM or some other method without needing to modify the ISO.

 

Follow my blog post here to Tutorial 145 for more details.


Edited by steve6375, 21 January 2019 - 02:38 PM.

  • wimb and devdevadev like this

#2 Rootman

Rootman

    Frequent Member

  • Advanced user
  • 295 posts
  • Location:USA

Posted 22 January 2019 - 12:00 AM

Steve I tried this and it works wonderfully.  However I have a question.  Since Grub4DOS is booting the ISO it's booted into legacy mode.  For a 64 bit Windows 10 OS, is it then possible to install it to an unprepared disk as EFI / GPT?   What about a on a disk that was previously legacy boot?  Can it change it to EFI / GP without too much fuss?

 

I unfortunately didn't have time to test this out. 



#3 steve6375

steve6375

    Platinum Member

  • Developer
  • 6996 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 22 January 2019 - 09:17 AM

It only boots to Windows and runs Setup.exe in the normal way - i.e. you get the same limitations as when you normally MBR-boot to Windows Setup.

 

However, you could inject a winpeshl.ini into it which causes WinNTSetup.exe to run instead of Windows Setup.exe.

 

Then you could make GPT partitions and install a UEFI-based installation of Windows. WinNTSetup even allows you to run a Diskpart script so you don't have to make the partitions manually, or you can use WinNTSetup in a script to automate everything.


  • wimb likes this

#4 steve6375

steve6375

    Platinum Member

  • Developer
  • 6996 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 3 weeks ago

According to this:

 

https://github.com/a1ive/grub/issues/2

 

iPXE wimboot should now work with grub2 for UEFI booting of Windows PE????

 

This means that it should be possible to UEFI boot to grub2 and then UEFI boot from a Windows Install ISO file. The winpeshl.ini can be injected as well as batch files which will then run ImDisk and load the ISO file as a virtual DVD in the same way as it is done for MBR-booting to grub2 (or grub4dos).

 

This means you can add lots of different Windows Install ISOs to a UEFI-bootable USB drive with a grub2 menu system.

 

There is a wimboot.mod file here

 

Also, I am not clear if it has the ability to insert extra files into X:\windows\system32 such as winpeshl.ini or mybatch.bat - this would be essential for Windows Install ISOs to work.

 

[Edit] According to developer you can - there is also a -j option (according to 'help wimboot' command in grub2) to specify a different folder to inject the files into other than X:\Windows\System32![/Edit]

 

Has anyone looked at this?

wimboot [--gui] [--rawbcd] [--rawwim] [--pause] [--index=n] @:boot.wim:/path/to/test.wim @:bootmgfw.efi:/path/to/test.efi @:bcd:/path/to/bcd @:boot.sdi:/path/to/boot.sdi
   * params:
   *         --gui or -g  Display graphical boot messages.
   *         --rawbcd or -b Disable rewriting .exe to .efi in the BCD file.
   *         --rawwim or -w Disable patching the wim file.
   *         --pause or -p
   *         --index=n or -i n Use WIM image index n.

Edited by steve6375, A week ago.

  • erwan.l likes this

#5 steve6375

steve6375

    Platinum Member

  • Developer
  • 6996 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted A week ago

This does work for MBR and UEFI now if you use A1ive's grub2 build.

See here.

Windows Installs are now possible from an unmodified Win ISO (both MBR and UEFI-boot) using grub2.



#6 erwan.l

erwan.l

    Platinum Member

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

Posted A week ago

Hi Steve6375,

 

I just "played" with latest grub 2.05 and wimboot.mod in pxe and uefi mode.

Ipxe+wimboot works well in UEFI but i am not sure, just like you (i.e not tested yet) if grub2+wimboot works well in UEFI.

 

grub2+wimboot.mod in UEFI works perfect and is now part of Tiny PXE Server.

 

However, and possibly deviating from this topic (apologies...), downloading a wim file via tftp takes for ever (as expected).

When using MS boot loader, one can tweak the bcd files to improve tftp speeds.

Any idea how to improve tftp performances with grub2 (if any possible) ?

 

Cheers,

Erwan



#7 steve6375

steve6375

    Platinum Member

  • Developer
  • 6996 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted A week ago

Sorry, no. Maybe ask a1ive ?



#8 erwan.l

erwan.l

    Platinum Member

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

Posted A week ago

Sorry, no. Maybe ask a1ive ?

 

Good point, I'll do that !

Thanks mate.



#9 erwan.l

erwan.l

    Platinum Member

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

Posted A week ago

Just sharing, I looked further and it appears there is a http grub2 module (which you can either build into the grub image or load via insmod).

 

So the below grub2.cfg will actually load wim files at the speed of light :)

set timeout=15
set default=0 # Set the default menu entry
#set root='(tftp)'
set root='(http)'

menuentry "GRUB4DOS" {
	linux /grub.exe --config-file=/menu.lst
}	

menuentry "Wimboot EFI64" {
#loopback /something.iso
insmod wimboot
wimboot \
  @:boot.wim:/sources/x64/boot.wim \
  @:bootmgfw.efi:/efi/boot/bootx64.efi \
  @:bcd:/efi/microsoft/boot/bcd  \
  @:boot.sdi:/boot/boot.sdi
  boot
}


#10 steve6375

steve6375

    Platinum Member

  • Developer
  • 6996 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted A week ago

So can you make it work for a Windows ISO file using loopback?

If you inject a winpeshl.ini and startup.bat and a null.cfg to hold the ISO path, startup.bat could contain net commands to gain access to the ISO - but is it then possible to mount the iso as a virtual DVD drive across the network?

If so, it makes it really simple to add any number of Win install ISOs into PXE with no need to modify the ISO or extract files from it each time you want to add a new one...



#11 erwan.l

erwan.l

    Platinum Member

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

Posted A week ago

Loopback over http works (i.e i seem to be able to use file in my iso from grub2) but i dont see any extra drive (a cd/dvd drive?) once I get under winpe (loaded via wimboot over http).

 

I am not very familiar with grub2 (ipxe is more my think) : is there something i need to apart from the "loopback lopp /my.iso" grub2 command before wimbooting?

 

In ipxe i would use memdisk or sanboot and un grub4dos i would use a map command.



#12 steve6375

steve6375

    Platinum Member

  • Developer
  • 6996 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted A week ago

see my tutorial 145

 

you just mount ISO as loop in grub2 and use that for wimboot.

The startup.bat file will run when winpe boots.

Startup.bat will then connect to server as n/w driver and you use ImDisk to mount ISO file from network drive as Y: (not sure if this is possible - maybe need to use sandisk?).

Then run setup once Y: is mounted. using wimboot it is easy to inject winpeshl.ini, startup.bat and null.cfg into the X:\Windows\System32 drive.

 

See the examples in the tutorial.


Edited by steve6375, A week ago.


#13 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14821 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted A week ago

I'll throw this on the table (and quickly hide my hand behind my back ;)).

Wouldn't good ol' httpdisk be useful?

https://www.acc.umu.se/~bosse/

 

:duff:

Wonko



#14 steve6375

steve6375

    Platinum Member

  • Developer
  • 6996 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted A week ago

From install.txt...

Copy the driver (httpdisk.sys) to %systemroot%\system32\drivers\.
Optionally edit httpdisk.reg for automatic or manual start and
number of devices.
Import httpdisk.reg to the Registry.
Reboot. If using an unsigned driver and running on the 64-bit version
of Windows press F8 and select "Disable enforce driver signing".
Use the program httpdisk.exe to mount and umount disk or CD/DVD
images.

Don't like the sound of 'Reboot' !  From a WinPE environment?

 

I have seen a few comments that ImDisk will mount an ISO from a network drive, so that should do the job.



#15 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14821 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted A week ago

From install.txt...



Copy the driver (httpdisk.sys) to %systemroot%\system32\drivers\.
Optionally edit httpdisk.reg for automatic or manual start and
number of devices.
Import httpdisk.reg to the Registry.
Reboot. If using an unsigned driver and running on the 64-bit version
of Windows press F8 and select "Disable enforce driver signing".
Use the program httpdisk.exe to mount and umount disk or CD/DVD
images.

Don't like the sound of 'Reboot' !  From a WinPE environment?

 

I have seen a few comments that ImDisk will mount an ISO from a network drive, so that should do the job.

Well, generally speaking importing a .reg to Registry often needs a reboot, BUT devcon (as an example) often allows drivers to be installed without a reboot.

 

:duff:

Wonko



#16 steve6375

steve6375

    Platinum Member

  • Developer
  • 6996 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted A week ago

maybe, but no need.

 

The current method uses ImDisk anyway for a local ISO, so it should work once a network drive is set up to point to the server source folder.

net use s: \\PXE-1\TFTPRoot

 

 

null.cfg can be written from the menu to contain both the path+name of the install ISO file (e.g. installiso="\PXE\WindowsIsos\Windows10x64BothUSA_1809.iso") and the name of the network share (e.g. net="\\PXE-1\TFTPRoot").

 

When WinPE Setup runs, startup.bat can parse the x:\windows\system32\null.cfg file to find these two bits of info.

Then use a net use command to connect to the server folder as a drive letter, run ImDisk from the network drive and mount the iso as a drive letter.

 

Then allow Setup to run and it will find the \sources\install.wim on the new drive.

 

This makes the startup.bat file generic. So for each Windows Install ISO, the user needs to:

 

First set up the server folder so it has a copy of ImDisk, null.cfg, winpeshl.ini and startup.bat.

 

For each Windows ISO...

 

1. Copy each Windows Install ISO to the server folder

2. Add a menu entry for each ISO - specify the iso path+name and the server network path (+ logon credentials if required?) in the menu.

 

So adding new ISOs would be very simple for a user to set up.



#17 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14821 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted A week ago

maybe, but no need.

 
Good. :)
However, I rechecked and actually there is not even need of devcon, sc is enough (at least on Windows XP, later may be different), see:
http://reboot.pro/to...ole-waik-first/
http://reboot.pro/to...first/?p=114118
 
 
 
 

Tested here (with the /cd switch) on XP.

Works NICELY. :)

I feel allowed to : :hi: ;) ;)

Additional, you need NOT to reboot to install it.
...


 
:duff:
Wonko

#18 erwan.l

erwan.l

    Platinum Member

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

Posted A week ago

 

 

I have seen a few comments that ImDisk will mount an ISO from a network drive, so that should do the job.

 

Note that you can also use vmount to mount an iso over a network drive.

no install needed : simply call vmount attachvhd path_to_iso.



#19 erwan.l

erwan.l

    Platinum Member

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

Posted A week ago

I'll throw this on the table (and quickly hide my hand behind my back ;)).

Wouldn't good ol' httpdisk be useful?

https://www.acc.umu.se/~bosse/

 

:duff:

Wonko

 

May be i have introduced confusion : what i am looking for is to "map" (pardon the eventual wrong wording) a file (say an iso) from grub2 and either :

-boot from it (like memdisk)

-find that "grub2 mapped" file in my os once i have booted it (like sanboot)



#20 steve6375

steve6375

    Platinum Member

  • Developer
  • 6996 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted A week ago

sure - look at Tutorial 145

 

Here is how to map an ISO and use it with wimboot

 

UEFI grub2 menu:

menuentry "Boot Winx64.iso EFI" {
set isoname="/WINISOS/Winx64.iso"
loopback loop "${isoname}"
set pp=
if test -f (loop)/x64/sources/boot.wim; then set pp=/x64; fi
if $EFI32; then
if test -f (loop)/x86/sources/boot.wim; then set pp=/x86; fi
fi
set installiso="${isoname}"
save_env -f /wimboot/null.cfg installiso
#NOTE: ORDER IS IMPORTANT! May get 0xC000000f error if order is wrong!
wimboot \
@:startup.bat:/wimboot/startup.bat \
@:winpeshl.ini:/wimboot/winpeshl.ini \
@:null.cfg:/wimboot/null.cfg \
@:boot.wim:(loop)${pp}/sources/boot.wim \
@:bcd:(loop)${pp}/efi/microsoft/boot/bcd  \
@:boot.sdi:(loop)${pp}/boot/boot.sdi
boot
}

basically just use loopback to mount the ISO.

 

wimboot will create a ramdrive for X: and load boot.wim, boot.sdi and bootmgfw.efi etc. into it and then boot to it.

 

null.cfg is a special 1024 byte file which is required for save_env - we save the path of the ISO into it first using save_env.

 

winpeshl.ini and startup.bat are also local files which are injected into X:\Windows\System32 by wimboot so that when the boot.wim boots to WinPE, it runs startup.bat. In your case these files would be in the pxe folder.

 

So the code in startup.bat maps a network drive and then uses ImDisk to mount the ISO as a virtual drive - e.g. Y:.

 

We don't load the ISO in grub2 - it would be slow and we can't easily use it once we boot to WinPE anyway - we just load the ISO under WinPE from the server.

 

See Tutorial 145.

 

 



#21 erwan.l

erwan.l

    Platinum Member

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

Posted A week ago

Agreed but to me the grub2 loopback in your tutorial is only there to serve files to grub2 (which will be used by wimboot) and then this loopback will fade away when wimboot takes over.

What I mean there is you wont see you loopack drive in your winpe.

To actually get to your iso in your winpe, you use a windows batch file which will map a network drive and then mount it with imdisk.

 

Wimboot does indeed create a ramdrive but this is independent of your loopback : whether you serve your file from a loopback, tftp or http, this is only under the grub2 context and is volatile.

Your loopback will be lost as soon as you jump into another kernel.

 

What I am looking for is to actually attach a drive from your first loader, keep it while jumping to another loader (winpe for instance) and still enjoy the drive you attached with your first loader.

Currently the only way  I know is iPXE+sanhook (attach a disk and/or dvd)+wimboot OR use grub4dos + specific drivers (like e.g vbus).

I agree that loading is not the way to go and clearly too slow - attaching rather is a nice way to go, when possible.

 

Dont get me wrong, tutorial 145 is really nice and handy and I like the fact that you use a unique iso thru out the whole process (i.e to retrieve the wim file then to launch the setup) :).

I definitely learned a lot from this tutorial 145 as well as this post around grub2 and wimboot.

 

In the meantime, I am playing with loopback over http and am getting mixed results ... the way the http modules handles http range request is peculiar.



#22 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14821 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted A week ago

@erwan.l
That is a problem as old as the egg (or maybe the chicken is older ;)), the bootmanager in real mode passing suitable parameters to a protected mode driver (capable of reading them).

 

The problem (ONLY between grub4dos and Firadisk/Winvblock) was solved because the developers found a way to exchange this info while SVBUS (if I recall correctly) resolved it because it directly looks to BIOS disk/drives.

 

With UEFI (and GRUB2) the matter is very different. 
Most probably (but the good guys that develop GRUB2 for *whatever* reasons seem to ignore the advanced features that grub4dos brought to the original GRUB code, that made it into the flexible bottmanager it is today) it would be trivial to add to GRUB2 (if they aren't already buit are simply not documented) some of the features of grub4dos, including that of creating a small RAM drive to store these exchange info and to have disk/drive mapping/remapping.  

But in the case of a wim/PE which is RAM loaded the approach by Steve6375 (via IMDISK, httpdisk, or *whatever* is "good enough") and has the advantage that the ISO needs not any modification.
 

In the meantime, I am playing with loopback over http and am getting mixed results ... the way the http modules handles http range request is peculiar.

Wait until you get to https ... :w00t: :ph34r:

 

:duff:

Wonko



#23 steve6375

steve6375

    Platinum Member

  • Developer
  • 6996 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted A week ago

Is your issue that you don't want to use net use to connect to your server and you don't want to create a network shareable folder?

 

So you are looking for a WinPE (32-bit and 64-bit) program to attach and mount a virtual drive over http?

 



#24 erwan.l

erwan.l

    Platinum Member

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

Posted A week ago

Is your issue that you don't want to use net use to connect to your server and you don't want to create a network shareable folder?

 

So you are looking for a WinPE (32-bit and 64-bit) program to attach and mount a virtual drive over http?

 

Indeed, although the windows share (both from a client and server perspective) is fine and is a rock solid way of doing, the batching of net use always makes me "tick" because it is many times hard coded (hardcoded ip or servername, sharename, username, password ...) so this is both a possible challenge from a security point of view and/or portability point of view (everyone will have a different windows share).

 

Now I appreciate that this script, thanks to wimboot, no longer sits in winpe but is injected on the fly so it is easy to adapt per case.

 

Furthermore, it is also possible to use "dynamic" variables by either using dns and/or other means to "hide" the username/password.

 

So all in all, nothing wrong with that way of doing nicely illustrated in your tutorial (and probably one of the easiest/most popular nowadays).

 

Another approach thus, and this is where I wrongly understood the (new to me) grub2 loopback keyword, is to attach your disk and/or cd/dvd with your first bootloader (ipxe, grub4dos, ...) and keep it attached while jumping onto your second chained bootloader (winpe/windows) so that you dont have to mount it again (thru net use or thru httpdisk for example).

 

Just 2 different approaches.

 

Regards,

Erwan

 

Side note, if you are about using imdisk on top of net use, you could as well skip net use and use imdisk over the network (thru devio or some other imdisk plugins) : that could bring extra (protocol) alternatives and could spare the use a samba share with possible credentials to share/maintain.

 

Cheers,

Erwan



#25 erwan.l

erwan.l

    Platinum Member

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

Posted A week ago

@erwan.l

Wait until you get to https ... :w00t: :ph34r:

:duff:

Wonko

 

I wont even comment on that one unless you want to see this thread turned into something "different"...

http what? what would I know about this? ;)







Also tagged with one or more of these keywords: grub2, windows install

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users