After installing Windows, the primary bootloader became his own.
There is a Linux Mint, so you need to have grub.

However, instead of the standard version, in which grub becomes the primary loader, I want to install grub on a separate partition and set up a command in the Windows loader to transfer control to grub. Naturally, the Windows bootloader should remain primary.

How to install grub to get this configuration?

  • one
    superuser.com/q/187586/454489 - aleksandr barakin
  • @alexanderbarakin, yesterday I came across several pages where a warning was written about such a call, but the answer was that sda1 is not a disk and you need sda . I understand correctly that I will need to specify the --force key --force that it is installed on the partition? - Qwertiy ♦
  • I do not know. check. the documentation says: “If you’re a device file or like a partitioned GRUB’s notation . // the option --force (and similar) in any program, perhaps, should be used if you have a good idea of ​​what you are going to do. - aleksandr barakin
  • one
    but I would be in your place, not for a second bothering with a very dexterous proprietary software, I would put grub (or rather, its “stage 1”) in mbr . he, in my opinion, is much easier to explain that there are other operating systems that I would also like to download. but if you know how to deal with the bootloader from ms , then with grub-ovsky “stage 1” you don’t need to do anything: this is already a matter of the ms loader - load “stage 1” (or “stage 1.5” from /boot/grub ). About stage even in Wikipedia it is popularly written: en.wikipedia.org/wiki/GNU_GRUB - aleksandr barakin
  • @alexanderbarakin, I hope that EasyBCD with the Windows bootloader will figure it out. - Qwertiy ♦

2 answers 2

Pre-notification : the following is very simplified and refers only to the “traditional” (or “old”) disk partitioning scheme called dos partition table ( mbr-based partitioning ) . although probably partly true for the guid partition table ( gpt ) . but definitely not related to the unified extensible firmware interface ( uefi ) .


To put it simply, bios loads the first 512 bytes from the block device specified in its settings into memory, and transfers control to this “piece of code” (in terms of grub, this is called the “first stage loader” - stage 1 loader ).

in addition to the executable code, there is also some information necessary for this code itself. it is clear that in such a meager amount of code, something reasonable is quite difficult to fit, and, in fact, this code only loads another, much larger portion of code ( stage 2 ), and transfers control to it.

where exactly this second portion is taken from, the “first stage loader” finds out from the very information that is written next to it in those same 512 bytes. among other things, there are recorded at least: the address of the block device (after all, stage 2 can be located on another used one) and the address of the sector (s) that (s) must be loaded into memory.

Why is the sector address, and not the file name? because in 512 bytes it is impossible to “put” a code that could work with the file system .

By the way, by the way: in the case of overwriting a file from stage2, its physical location is likely to change, and, accordingly, it will be necessary to adjust the contents of those same 512 bytes of the “first stage loader”.

but the code that was loaded from stage 2 , “understands” both file systems and configuration files can read and display a dialog for the user, based on these configuration files, and the selected program that performs the functions of the kernel, download (the one that loads “Trained”: ntoskrnl.exe , linux , etc., etc.).

The stage2 loader from the ms company is clearly not “trained” to load the linux program, and the stage2 loader grub (as well as lilo and others) is not “trained” to download ntoskrnl.exe .

but they can all load other stage1 loaders (and even stage2 loaders) and transfer control to them .


and then we can only talk about the degree of automation of the settings of this process.

  1. in the case of the bootloader from the company ms , of course, no automation of the settings is envisaged: facilitating the use of a “foreign” operating system is a “low blow”, i.e., to a wallet. as they say, "it's just business, nothing personal."

    To set up, you need to get hold of the “first stage loader”, write these 512 bytes to a file (for example, c:\bootsect.aln ) and add a line to the operating systems section of the configuration file of the c:\boot.ini loader c:\boot.ini content:

      c:\bootsect.aln="alien operating system" 

    do not forget to manually update the contents of this 512-byte file every time after updating the stage2 loader, to the addresses of the sectors with which it (the file) should refer!

    There are, of course, all sorts of “boot managers” (of the type mentioned in the easybcd comments), but if at least one of them has an automatic update account in the stage2 file of the same grub , I don't know. but I suspect that it is unlikely (considering, firstly, there may be much more than one talk with grub , and second, that the “initiative of renewal” comes from the side of grub , which, quite naturally, hardly suspects the existence of any “boot managers”).

  2. in the case of the grub loader, the approach is diametrically opposite: everything (which is possible) is done to simplify the configuration of the boot process of other operating systems. in “normal conditions” everything happens “automagically”: during the installation of the grub program (and when updating files containing stage2 ), the update-grub program (included in the grub package) is called, which (as a rule, quite successfully) “finds” on block devices and their sections other bootloaders, and adds items with them to the boot menu.

which way suits you best - choose for yourself.


ps perhaps it is worth noting that the code for the “second stage loader” of the grub program has long grown to such an extent that developers had to create (albeit not only for this reason) an intermediate loader (which was called stage 1.5 ). This does not change the essence, but it is written about stages 1, 1.5 and 2 even in Wikipedia , and the mention will be appropriate.


addition

about where to put 512 bytes of stage1 , so as not to overwrite mbr : put it not in the mbr disk, but in the vbr partition . there is enough space. bootloader installers know this, and know how to handle it.

  • The purpose of saving the primary Windows bootloader is to enable a one-time reboot to the selected system . EasyBCD is able to search for loaders. He definitely found the grub legacy, which worked normally from Windows - I hope that he will deal with the fresh one. - Qwertiy ♦
  • obtaining the possibility of a one-time reboot into the selected system is that only programmers will not think up, if only one byte in the text file is not overwritten. I'm talking about making the /boot directory in a separate section with fs fat . (you can not even the entire directory /boot , and specifically /boot/grub/ ). - aleksandr barakin

Everything is very simple - ntldr, used to this day, cannot read ext4 and other filesystems that are commonly used for grub. You need to load grub via ntldr - please output grub to the section with fat32 or ntfs. And installing grub without rewriting the boot sector is real, but difficult if you are using debian / ubuntu, because the reboot of the boot sector when installing grub is specified in their packages.

  • I’ve been a bit naughty ... But in general I did it. But I’m not sure which section grub is on now. Probably I should not have asked this question at all, but see the values ​​of the dropdown with the type of bootloader in EasyBCD ... Then I’ll check it separately. - Qwertiy ♦