13

I want to do it because I want to install Windows 7 and my BIOS menu doesn't appear; it skips to grub2 menu at start, but that's another story... Is there a way to boot the Windows 7 installation iso directly from grub2?

2
  • 1
    " my BIOS menu doesn't appear" But have you tried to get into the BIOS?
    – Mitch
    Oct 28, 2013 at 7:12
  • What if i format the HDD? Will windows boot then? :)
    – user351688
    Nov 24, 2014 at 15:57

3 Answers 3

8

Booting Windows XP with grub4dos

Booting the actual ISO with grub legacy or grub2 won't work, but with older windows versions (i.e. XP) it is possible to unpack the i386 folder from the ISO to the USB stick, and then use grub4dos to call the bootloader:

title windows installer via setupldr.bin
find --set-root /i386/setupldr.bin
chainloader /i386/setupldr.bin

or

title windows installer via /bootsect.bin
find --set-root /i386/setupldr.bin
chainloader /bootsect.bin

This might not work with newer windows versions or with newer hardware but there is also the option of..

Booting Windows 7 with grub2

With grub2 apparently something like this could work for Windows 7:

menuentry "Windows 7 (bootmgr)" --class windows --class os {
    insmod part_msdos
    insmod ntfs
    insmod ntldr
    ### A: either use this line or the next one, but not both
    set root='(hd0,msdos1)' 
    ### B: 
    ### search --no-floppy --set=root --fs-uuid ____INSERT_PARTITION_UUID_HERE___
    ntldr ($root)/bootmgr
}

Option A assumes your bootable USB stick/HDD is the first device and has a msdos style partition table. Adjust to match your configuration. If your boot device has a GPT partition table, then most likely you'll need to use (hd0,gpt1) (GPT in general is trickier to set up).

Option B uses the drive's unique UUID, which can be seen on Linux with sudo blkid or on OSX with e.g. diskutil info disk0s1 (or Disk Utility > Info).

The final entry might look for example like this:

menuentry "Windows 7 installer" --class windows --class os {
    insmod part_msdos
    insmod ntfs
    insmod ntldr
    search --no-floppy --set=root --fs-uuid 0E239BC6-F960-3107-89CF-1C97F78BB46B
    ntldr /bootmgr
}
3
  • 1
    Nice. I did use --set=root --fs-uuid UUIDHERE (changed order) instead, though (couldn't say whether it was required or not). Thanks Jul 26, 2016 at 0:15
  • @JanKyuPeblik Could you boot from ISO?
    – Anwar
    Nov 21, 2016 at 14:55
  • That is my recollection, yes. I wouldn't have been interested in the other stuff. Nov 21, 2016 at 23:11
7

Yeah, you'd think something like this would work:


menuentry "Boot Windoze" {
  search -f "--set-root /Winblows.iso"
  drivemap "/Winblows.iso" '(hd32)'
  drivemap '--hook' ''
  set root='(hd32)'
  chainloader +1
}

But Windows will just balk at that.

If you happen to have at least 4GB RAM, you can opt to load the whole DVD iso in memdisk and boot off that. To do that, download SysLinux and extract the memdisk file into your boot directory. Then you need to add code to Grub2 something like this


menuentry "Boot Windoze" {
  search -f "--set-root /Winblows.iso"
  insmod memdisk
  linux16 /boot/memdisk iso
  initrd16 /Winblows.iso
}

However, I'm not going to even test the code, as putting 3+ GB of data into RAM is just plain wrong (from an idealogical standpoint). No, I really wanted what you want, but in the end I put the Windows install on a partition on a USB using the Windows 7 USB/DVD download tool and chainloaded to that. Sorry there doesn't seem to be any other way that I can see.

5
  • 1
    First code will boot windows but fail after sometime as windows don't know where the iso is mounted
    – totti
    Feb 18, 2014 at 9:26
  • Second code may not work, as it will not work with iso of Ubuntu
    – totti
    Feb 18, 2014 at 9:28
  • The OP is referring specifically to Windows 7. Been able to test that?
    – Warpspace
    Mar 14, 2014 at 5:28
  • 1
    You may not like Windows, but posting "Winblows" and "Windoze" here is rather unprofessional. -1. Jan 4, 2020 at 20:39
  • 1
    As I'm not a professional bootstrap programmer, I can live with "unprofessional". I think you might have meant "disrespectful". Yeah, that comment was 6 years ago. I have changed a lot since then (and so has Windows)
    – Warpspace
    Jan 11, 2020 at 4:56
5

Technically installing from windows's .iso file can't be possible. You can boot from the .iso using grub but after that Windows will loss contact with the mounted location or it is not capable of it. So both grub & Windows should aware of mount and boot. Currently Windows doesn't support.

So you need to extract/copy the content of .iso to root of a partition and then chain-load into it using grub.

1
  • 3
    good idea to share knowledge, but you could add directly answering the question in technical manner. namely reuse the current text as a disclaimer but then you could expand the "you can boot from the .iso" into menuentries or something. that way you'd make exact which method(s) you imagined to achieve what was asked, although which you know not to work for the assumed purpose. this would also disambiguate the count of solutions that you did consider.
    – n611x007
    Jun 12, 2014 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.