0

I've been learning bootloader recently and came up with a strange idea : is it possible to install GRUB2 directly on Windows to override the default MBR and bootloader Windows have so that later if I install Linux on the same disk, I do not have to edit grub configuration files to rescue Windows boot menu?

Besides, I am using MBR partitioning plan so that it's better to install GRUB2 in BIOSBOOT partition. But I don't know how to do that in Windows. Furthermore, will newly installed Linux override existing BIOSBOOT partition? That is to say, will Linux be "smart" enough to detect that a BIOSBOOT partition has already been created so as to avoid overriding?

Finally, to state my question from another perspective, I am just wondering is it possible for me to replace the default Windows bootloader with later manually installed GRUB2? Will Windows forbid that?

  • MBR is not Windows; a bootloader (in Legacy/BIOS) is always installed in the MBR but otherwise independent of the OSes. With Windows only the Windows bootloader is there. In order to install Ubuntu in dual boot, the Windows bootloader is typically replaced by Grub that can boot both OSes. Anything else you're asking makes no sense, at all. – user772515 Jan 10 '18 at 12:09
0

You question as it relates to MBR is quite easy to using the grub-install tool. Windows won't touch the MBR after installation unless you manually reinstall it with bootrec /FixMbr

BIOS BOOT will be used by GRUB any time you run grub-install. Note that this partition was specifically invented for the GRUB boot loader so it will use it if it exists.

GRUB2 relies on a file system on the same device containing /grub or /boot/grub for its configuration files and modules. Grub is not able to read NTFS (Windows) partitions in stage 2 (before its loaded its modules) by default Therefor if you wanted to include these modules they couldn't be part of the Windows partition. They must be embeded in the core.img of grub.

You can use the grub-mkimage command to make a core.img with modules and configuration capable of loading Windows. The core.img could then be written to the bios boot partition.

  • Thanks! To make sure I got it, I restate your answer so you can check whether I am right. First, Windows does not touch MBR, which means Windows is started from the boot loader which is installed in the boot sector in the primary partition with "boot" flag. Second, core.img (stage 1.5 rather than stage 2) of GRUB2 does not recognize NTFS filesystem. So even if GRUB2 is installed on windows, it can not recognize NTFS filesystem, thus it can not read its grub.cfg files, and boot will fail. To fix this, you said that I have to recompile the core.img so that it can recognize NTFS filesystem. – Han XIAO Jan 12 '18 at 4:07
  • @XiaoHan yes. Although if you're using a BIOS boot partition there is no 1.5. It goes straight to stage 2. You would need the, part_mbr, ntfs and search_fs_uuid modules to get things loaded off the Windows partition. – jdwolf Jan 12 '18 at 4:15
  • What is worth noting is that according to the GRUB2 documentation, stage 1,stage 1.5,stage 2 are no more in GRUB2. See here. So the GRUB2 is totally installed in MBR and BIOSBOOT(where images are installed), with some configuration files reside in file system,which, for example, are /boot/grub/ in Linux? – Han XIAO Jan 12 '18 at 4:15
  • @XiaoHan core.img includes a memdisk which contains the modules as files. This memdisk is embeded in core.img which is in the bios boot partition. It then loads further files and configuration from the file system. It doesn't actually have to do this though. You could load everything with a core.img with all the modules and configuration you need. It's just not normally done like that for modularity and updating. – jdwolf Jan 12 '18 at 4:17

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.