Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-bootable Windows ISOs #27

Open
JonnyTech opened this issue Jan 6, 2025 · 5 comments
Open

Non-bootable Windows ISOs #27

JonnyTech opened this issue Jan 6, 2025 · 5 comments

Comments

@JonnyTech
Copy link

I was trying to create a pull request and somehow failed...

63781e0

Added the ability to boot Windows PE ISO files that require locations of boot files to be specified ie Symantec_Ghost_BootCD_12.0.0_Win11_x64.iso and others.

# Windows PE ISO's that do not boot normally

iso_pattern="win-noboot/*Win1*.iso"

for isofile in $iso_dir/$iso_pattern; do
	if [ -e "$isofile" ]; then
		regexp --set=isoname "$iso_dir/(.*)" "$isofile"

		menuentry "$isoname" "$isofile" --class=windows {
			if [ "${grub_platform}" != "efi" ]; then
				rmmod iso9660
				drivemap -s (hd0) (hd1)
			fi
			echo Loading boot.wim... This may take some time
			iso_path="$2"
			save_env iso_path
			LOOPBACK "$iso_path"
			$wimboot_kernel /MultiOS-USB/tools/wimboot-*/wimboot.x86_64
			$wimboot_initrd \
							newc:BCD:(loop)/boot/bcd \
							newc:boot.sdi:(loop)/boot/boot.sdi \
							newc:boot.wim:(loop)/sources/boot.wim \
							newc:mountIso.exe:/MultiOS-USB/tools/mountiso/mountiso64.exe \
							newc:grubenv:($dev,1)/grub/grubenv
			echo Loading boot.wim complete, booting...
		}
	fi
done

See the commit message for addition info. Feel free to cherry pick whatever you like.

@Mexit
Copy link
Owner

Mexit commented Jan 6, 2025

Thanks! I will test as soon as I have the opportunity

@JonnyTech
Copy link
Author

Some thoughts on expanding this to fit in with the existing Windows ISO configuration file:

Grub has the test command (https://www.gnu.org/software/grub/manual/grub/html_node/test.html#test)

17.4.74 test
Command: test expression
Evaluate expression and return zero exit status if result is true, non zero status otherwise.
expression is one of:
...
-d file = file exists and is a directory
-e file = file exists
-f file = file exists and is not a directory
-s file = file exists and has a size greater than zero
...

If script tests for the existence of the following files within boot.wim

/Windows/Boot/DVD/EFI/BCD
/Windows/Boot/DVD/EFI/boot.sdi

or

/Windows/Boot/DVD/PCAT/BCD
/Windows/Boot/DVD/PCAT/boot.sdi

then boot the WIM, else extract from the ISO as per OP.

@JonnyTech
Copy link
Author

Not sure how to look inside the .wim for a file.

This is untested: [ -s (loop)/sources/boot.wim/Windows/Boot/DVD/EFI/BCD ] - ie look for the BCD file within the wim within the iso.

Then one script can do both:

# Windows 10, Windows 11
# https://www.microsoft.com/software-download/
# Incuding Windows PE ISO's that boot from USB drive only

iso_pattern="*Win1*.iso"

for isofile in $iso_dir/$iso_pattern; do
	if [ -e "$isofile" ]; then
		regexp --set=isoname "$iso_dir/(.*)" "$isofile"

		menuentry "$isoname" "$isofile" --class=windows {
			if [ "${grub_platform}" != "efi" ]; then
				rmmod iso9660
				drivemap -s (hd0) (hd1)
			fi
			echo Loading boot.wim... This may take some time
			iso_path="$2"
			save_env iso_path
			LOOPBACK "$iso_path"
			$wimboot_kernel /MultiOS-USB/tools/wimboot-*/wimboot.x86_64

			if [ -s (loop)/sources/boot.wim/Windows/Boot/DVD/EFI/BCD ] && [ -s (loop)/sources/boot.wim/Windows/Boot/DVD/EFI/boot.sdi ]; then
						echo Loading bootable boot.wim...
						$wimboot_initrd newc:boot.wim:(loop)/sources/boot.wim \
									newc:mountIso.exe:/MultiOS-USB/tools/mountiso/mountiso64.exe \
									newc:grubenv:($dev,1)/grub/grubenv \
									newc:Winpeshl.ini:/MultiOS-USB/config/windows/Winpeshl.ini
			else
						echo Loading ISO assisted boot.wim...
						$wimboot_initrd \
									newc:BCD:(loop)/boot/bcd \
									newc:boot.sdi:(loop)/boot/boot.sdi \
									newc:boot.wim:(loop)/sources/boot.wim \
									newc:mountIso.exe:/MultiOS-USB/tools/mountiso/mountiso64.exe \
									newc:grubenv:($dev,1)/grub/grubenv
			fi

			echo Loading boot.wim complete, booting...
		}
	fi
done

@Mexit
Copy link
Owner

Mexit commented Jan 11, 2025

Not sure how to look inside the .wim for a file.

As far as I know this is handled by wimboot.

This is untested: [ -s (loop)/sources/boot.wim/Windows/Boot/DVD/EFI/BCD ] - ie look for the BCD file within the wim within the iso.

Unfortunately, it doesn't work that way. From GRUB there is no access to the wim image.

@JonnyTech
Copy link
Author

Is see, so my original approach for now. If I get time then shall look at wimboot code and see if it is possible to make a grub module to list wim file content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants