Open fengggli opened 8 years ago
Hi lifenggg,
Only the ISOs referenced by files inside the grub.d
directory work. Most are Linux distros or CDs based on Linux (basically those that use Isolinux).
I'm not aware of any way to make it work with Windows ISOs, but then again, I don't use Windows so I haven't tested it.
If you do find a way, please open a pull request with the code and I'll happily merge it.
this only works by adding partitions to the usb-drive. one for each windows installer, where you unpack the images. from the top of my head, it would look like this.
menuentry "Windows installer" {
set root=hd0,gpt4 #better use fs-search uuid for this
chainloader /boot/efi/bootx64.efi
}
Maybe you can make your script scan for more partitions on the drive and add them automagically i have tried this, and it works at least in EFI mode, didnt get around to test CSM.
@vKnmnn, does that work with any Windows ISO or just for Windows10 Educational?
I have tried with win 7,8 and 10, worked for all of em
Ok, great! I'll test this out see if we can find a way to make it work.
I have done some testing today on 2 windows images (8 and 10). this is what i have so far:
set win8uuid=F330-F10F
set win10uuid=09FC-CB67
if [ "x$grub_platform" == "xefi" ]; then
search -nu $win8uuid -s win8
if [ $? -eq 0 ]; then
menuentry 'Windows 8 installer' {
set root=$win8
chainloader /efi/boot/bootx64.efi
}
fi
search -nu $win10uuid -s win10
if [ $? -eq 0 ]; then
menuentry "Windows 10 installer" {
set root=$win10
chainloader /efi/boot/bootx64.efi
}
fi
fi
this boots those OSs successfully in EFI mode.
I can't test BIOS mode, since my copmuter refuses to boot my stick in bios mode, but replacing
chainloader /efi/boot/bootx64.efi
with insmod ntldr; ntldr /bootmgr
should suffice.
The question remains, whether we should even try booting windows 8 and 10 images in CSM mode.
EDIT: Virtualbox and qemu succeed in bios-booting the stick, but not the installers
Booting in BIOS mode is unseuccessful. throws 0xc000000e error on /boot/BCD. I am not sure how ntldr module works, so i can't say how to solve this. The error might be due to the fact, that i did not write the iso's MBR to the partition and seem to be unable to extract it from the iso. Further i am not sure, if an MBR written to the start of a partition is within specifications. One might be able to fix the BCD file by booting a real bios-bootable disc to use repair tools on the partition (which might just overwrite the grub code in the bootsector of our device)
@vKnmnn. This is what I've gotten so far (I've added some comments inside the code):
## Look for setup.exe on the root of each partition
for file in (*)/setup.exe; do
if [ -e "$file" ]; then
## Get the partition name (e.g. hd1,gpt4)
regexp --set=partname "^\((.*)\)" "$file"
submenu "Windows ($partname) ->" "$partname" {
part_name="$2"
## Get the partition UUID (e.g. F330-F10F)
probe --fs-uuid $part_name --set=part_uuid
## Set the partition with that UUID as root
search --fs-uuid --no-floppy --set=root $part_uuid
if [ "x$grub_platform" == "xefi" ]; then
menuentry "Installer (EFI)" {
chainloader /efi/boot/bootx64.efi
}
else
menuentry "Installer" {
ntldr /bootmgr
}
fi
}
fi
done
Now, with this I managed to start the UEFI installation (BIOS mode gives me the same 0xc000000e error). However, it fails when trying to find drivers in the CD. I am testing it in QEMU, not on baremetal, so this might be the problem.
Does this code work for you? The initial lookup (for file in (*)/setup.exe
) might be a bit slow though, so we will need to optimize it.
However, it fails when trying to find drivers in the CD. I am testing it in QEMU, not on baremetal, so this might be the problem.
BTW, this was indeed related to QEMU. Changing the disk interface from virtio to IDE fixed the issue. No BIOS mode installation yet though.
@aguslr your code works for me. I have two suggestions.
search -n --file $filename
to find the filesetup.exe
to match a windows installer. at least not as the only match. searching for .wim files seems like the way to go. they usually reside in /sources or sometimes in SMBB. we will need to check a windows PE image as well, to see which file to match that with.i read about that driver issue somewhere. that's easy to be fixed, but from within that installation environment (only?). looking through my history to find it again.
Please check PR #129, more specifically commit d759ab6.
I've created a new submenu that, for each additional partition in the pendrive, it looks for some common boot files (including /efi/boot/bootx64.efi
) and creates menu entries for each one of those. This way you don't need to specify the partition name or UUID since it detects it automatically and, since it only searches the pendrive, it's relatively fast.
I've tested it with Windows 8, Windows 10 and Windows Server 2012 and it works when using EFI. For now that's good enough but it'd be great to be able to boot in BIOS mode.
Let me know what you think.
@aguslr I have tried to boot a working win 10 iso install, and I get the drivers not found error both with qemu (virtio, don't know how to correctly use ide) and with real pc. Do I have to use gpt partition scheme? I have a typical dos one.
@gilcu3 windows 10 installer needs to be on GPT formatted disk, unpacked iso on an additional partition of your bootstick. @aguslr #129 seems like the way to go. nicely done.
So I was hoping to use the more-menus
branch, but I'm not able to even get the things in this thread to work.
I have a GPT partitioned disk, I made a ntfs partition marked bootable and copied the contents of a windows 7 64 bit iso install iso to it with rysnc -avz /mnt/iso /mnt/partition
.
I tried creating the partition and then dd
ing the files over, but I think it wasn't detected by the find partition stuff in the more-menus
branch so I moved on.
I'm running it qemu, with the virtio driver and the command given on the multiboot website without -enable-kvm
, I haven't figured out why that's turned off and keep forgetting to check when I reboot.
sudo qemu-system-x86_64 -localtime -m 2G -vga std -drive file=/dev/sdb,readonly,cache=none,format=raw,if=virtio
The win7 iso doesn't have the file /efi/boot/bootx64.efi
, but it does have these:
$ ls /mnt/iso/efi/microsoft/boot/
bcd* cdboot.efi* cdboot_noprompt.efi* efisys.bin* efisys_noprompt.bin* fonts/
At the grub prompt, chainloader (hd0,gpt3)/efi/microsoft/boot/cdboot.efi
and (hd0,gpt3)chainloader /efi/microsoft/boot/cdboot_noprompt.efi
result in error: invalid signature
ntldr (hd0,gpt3)/bootmgr
and then boot
gives the same error as mentioned above, 0xc000000e
I did try doing
probe --fs-uuid hd0,gpt3 --set=part_uuid
search --fs-uuid --no-floppy --set=root $part_uuid
chainloader /efi/microsoft/boot/cdboot.efi
and the same with ntldr
to the same results.
Clearly I'm doing something differently, any thoughts?
Some Windows 7 ISOs only have an efi file to boot DVDs. You need to put the right bootloader on the stick. Obtain the correct file from either the .wim image, or an already installed windows 7 edition. The file should reside in c:\Windows\Boot\bootmgfw.efi
. Copy that to the apropriate location and chainload it from there.
That gives me invalid signature
as well. It was found at C:\Windows\Boot\EFI\bootmgfw.efi
.
Any other suggestions or should I just give up for now?
can you confirm, if qemu truly boots in EFI mode? Check $grub_platform variable to do so.
It was not. I've learned a lot of things and gotten it working.
Made a pull request to add the file for win7 to the search path and to show an error if it didn't find a config file on a partition.
Hi @vKnmnn , @aguslr ,
I’m using Uefi system with secure boot disabled. I created usb as the following steps:
# Install GRUB for EFI
[ "$eficonfig" -eq 1 ] && \
{ $grub_cmd --target=x86_64-efi --efi-directory="$efi_mnt" \
--boot-directory="${data_mnt}/${data_subdir}" --removable --recheck \
|| cleanUp 10; }
To:
# Install GRUB for EFI
[ "$eficonfig" -eq 1 ] && \
{ $grub_cmd --target=x86_64-efi --efi-directory="$efi_mnt" \
--boot-directory="${data_mnt}/${data_subdir}" --removable --recheck --no-uefi-secure-boot \
|| cleanUp 10; }
(Add --no-uefi-secure-boot)
What should I do? Thanks.
UPDATED: It's my mistake, the ISO file is corrupted, so the efi can not boot. . Please ignore my comment.
Hi aguslr, I tried to use this tool to create a bootable flash drive with both linux and windows. It works well with linux but it seems not to recognize my windows iso. I placed both iso files in the 'isos' directory Is windows supported by this tool? The iso file i used is windows 10 educational 64bit Thanks