2

Is it possible to create a multiboot USB with Windows installers from Linux?

Note: this is a self answered question since I want to share my methods with the community. I'm aware of this question but I think my question has nuances that the (possible duplicate) doesn't.

1 Answer 1

3

Using Linux Mint 19 64 bits as host OS. It's quite safe to assume that similar distros and releases, like Ubuntu for example, will behave the same.

We will need:

  • A USB of 16GB.
  • ISO images of Windows, in this case Windows 7 and Windows 10 64 bits.

The process

  1. Install grub-efi-amd64 for GRUB EFI compatibility

    sudo apt install -y grub-efi-amd64
    
  2. Format the USB with msdos partition table. The partitions' size have to be enough to hold the unpacked ISOs. In this case, let's just divide the USB in two halves ~8GB each. Both partitions have to be FAT formatted. Mark the first partition as bootable.

  3. Mount the USB first partition. Take a note of: wich device is, i.e. /dev/sdc1, and the path it is mounted on, i.e. /media/foo/WIN7/. From now on, I will use those two examples for the guide.

  4. Install GRUB:

    dirs=(bin dev etc lib lib64 proc sbin sys usr)
    for dir in "${dirs[@]}"; do
      mkdir /media/foo/WIN7/$dir && sudo mount --bind /$dir /media/foo/WIN7/$dir
    done
    
    sudo chroot /media/foo/WIN7/
    
    # chroot environment
    # first we install grub efi
    
    grub-install --force --removable --target=x86_64-efi --efi-directory=/ /dev/sdc1
    
    # now we install grub 386
    
    grub-install --force --removable --target=i386-pc --boot-directory=/ /dev/sdc
    
    # exit the chroot
    
    exit
    

WARNING!! Be very careful with the next command, since you could remove binded directories. Use tab completion for the paths instead of typing them.

for dir in "${dirs[@]}"; do
  sudo umount /media/foo/WIN7/$dir && rm -rf /media/foo/WIN7/$dir
done
  1. Mount the ISOs, and copy their contents to each USB's partitions: Windows 7 into the first partition (you will get the message that boot directory already exists, just merge them), and Windows 10 into the second partition.

GRUB configuration:

NOTE: Windows 7 will boot on BIOS only and Windows 10 in EFI only

  1. Create under /media/foo/WIN7/grub the file grub.cfg and put the following content there:

    set root='(hd0,1)'
    configfile /boot/grub/grub.cfg
    
  2. Create under /media/foo/WIN7/boot/grub the file grub.cfg and put the following content there:

    menuentry 'Windows 7 installer BIOS' {
      insmod ntldr
      ntldr /bootmgr
    }
    
    menuentry 'Windows 10 64 bits installer EFI' {
      set root='(hd0,2)'
      chainloader /efi/boot/bootx64.efi
    }
    

We are now ready to test if the USB works properly, just boot your machine with the USB attached, and depending on the BIOS/EFI you will have different options to select between BIOS or EFI, or just the option to boot from USB in older machines.

3
  • This sounds great. I tried the same but ultimately failed. Does it work with Windows 10 on a NTFS formatted partition? The images Microsoft provides can contain a install.wim larger than 4 GB. Any explanation on why Windows 10 won't boot on BIOS?
    – Hermann
    Dec 5, 2019 at 21:09
  • 1
    The format FAT is meant for EFI to work. But in fact I should investigate more on the subject, maybe the second partition can be NTFS. Let me try it and I'll come back, edit the answer and ping you. Dec 6, 2019 at 19:12
  • 1
    @Hermann Windows 10 can be booted from BIOS, you just have to change the grub config, that its the same to windows 7: ntldr /bootmgr. But, for the sake of example in the guide (one bios one efi) I deemed not useful to boot a windows 64 image from BIOS since modern hardware is almost EFI. What I've done is create a third partition with windows 10 32 bits BIOS. But nonetheless you can change this in the grub conf, adding as many entries as you want. Dec 6, 2019 at 19:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .