aguslr / multibootusb

A collection of GRUB files and scripts that will allow you to create a pendrive capable of booting different ISO files
https://mbusb.aguslr.com
GNU General Public License v3.0
576 stars 156 forks source link

windows10Educational not recognized #6

Open fengggli opened 8 years ago

fengggli commented 8 years ago

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

aguslr commented 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.

vKnmnn commented 7 years ago

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.

aguslr commented 7 years ago

@vKnmnn, does that work with any Windows ISO or just for Windows10 Educational?

vKnmnn commented 7 years ago

I have tried with win 7,8 and 10, worked for all of em

aguslr commented 7 years ago

Ok, great! I'll test this out see if we can find a way to make it work.

vKnmnn commented 7 years ago

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

vKnmnn commented 7 years ago

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)

aguslr commented 7 years ago

@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.

aguslr commented 7 years ago

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.

vKnmnn commented 7 years ago

@aguslr your code works for me. I have two suggestions.

  1. use search -n --file $filename to find the file
  2. do not use setup.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.

aguslr commented 7 years ago

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.

gilcu3 commented 6 years ago

@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.

vKnmnn commented 6 years ago

@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.

mtfurlan commented 6 years ago

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 dding 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?

vKnmnn commented 6 years ago

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.

mtfurlan commented 6 years ago

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?

vKnmnn commented 6 years ago

can you confirm, if qemu truly boots in EFI mode? Check $grub_platform variable to do so.

mtfurlan commented 6 years ago

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.

comnuoc commented 6 years ago

Hi @vKnmnn , @aguslr ,

I’m using Uefi system with secure boot disabled. I created usb as the following steps:

  1. Ran makeUSB.sh -b -e /dev/sda ntfs 22G
  2. Usb could not boot. I changed this line in makeUSB.sh:
    # 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)

  3. USB could boot Linux isos.
  4. I created a partition: format: ntfs, boot flag, esp flag.
  5. Copied windows 10 iso (https://www.microsoft.com/en-us/software-download/windows10ISO) content to new partition.
  6. Used the config from https://github.com/aguslr/multibootusb/pull/129.
  7. USB could boot, but when chainloaded to windows 10, error occured. Error message: "error: can not load image".

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.