[opensuse] grub2 chainloading
Hello: It will be a little bit long to explain what I want to do. I have several linux OS-es on a hard disk. Each OS has its own boot loader installed on the OS's root partitition. The MBR has also a boot loader. This boot loader chainloads the other boot loaders on the root partitions. This makes easy to completely separate different boot menus for different OS-es. For the management of the above scenario at least one of the OS-es must have 2 different boot loader install configurations, one for the mbr boot loader (chainloader) and one for the OS's own boot loader on the root partition. This can be easily done by using legacy GRUB boot loader by making two separate directories for the chainloader and the other configuration. Each directory contains all the files necessary to install and make work GRUB boot loader. Legacy GRUB has command option --prefix which enables to use different GRUB config files for different GRUB installations. Here's an example: To install MBR grub chainloader: In grub shell I use: setup --force-lba --prefix=/boot/grub.chainload (hd0) (hd0,0) # in this case config files in /boot/grub.chainload dir are used. And to install the OS's own boot loader on the root partition: setup --force-lba (hd0,0) (hd0,0) # here the default /boot/grub is used. Now my question: how can I do the same with GRUB2? I would like to have a main GRUB2 menu/loader on the MBR which chainloads GRUB2 loaders on the different root partitions. Since GRUB2 configuration files are spotted at different places (/etc/default/grub, /boot/grub2/grub.cfg, /etc/grub.d/* scripts), I don't know how I could make different configuration files for the different install locations, not to mentions how I could install the different GRUB2 loaders to different locations (to mbr and to the root partition). I would appreciate any help in this matter. Thanks in advance, Istvan ps: Please don't ask me why I do want to do this and please do not suggest that I use one GRUB2 menu to load all of the different OS-es. I want to do it because I could do it with legacy GRUB and I expect that it is doable with the advanced GRUB2 too, and anyway I got used to do it that way. Thanks. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2018-07-20 00:02, Istvan Gabor wrote:
Hello:
It will be a little bit long to explain what I want to do.
I have several linux OS-es on a hard disk. Each OS has its own boot loader installed on the OS's root partitition. The MBR has also a boot loader. This boot loader chainloads the other boot loaders on the root partitions. This makes easy to completely separate different boot menus for different OS-es.
Me too.
For the management of the above scenario at least one of the OS-es must have 2 different boot loader install configurations, one for the mbr boot loader (chainloader) and one for the OS's own boot loader on the root partition.
I don't do that.
ps: Please don't ask me why I do want to do this and please do not suggest that I use one GRUB2 menu to load all of the different OS-es. I want to do it because I could do it with legacy GRUB and I expect that it is doable with the advanced GRUB2 too, and anyway I got used to do it that way. Thanks.
Then I will not say how I do it :-) -- Cheers / Saludos, Carlos E. R. (from 42.3 x86_64 "Malachite" at Telcontar)
20.07.2018 01:02, Istvan Gabor пишет:
Hello:
It will be a little bit long to explain what I want to do.
I have several linux OS-es on a hard disk. Each OS has its own boot loader installed on the OS's root partitition. The MBR has also a boot loader. This boot loader chainloads the other boot loaders on the root partitions. This makes easy to completely separate different boot menus for different OS-es.
For the management of the above scenario at least one of the OS-es must have 2 different boot loader install configurations, one for the mbr boot loader (chainloader) and one for the OS's own boot loader on the root partition.
This can be easily done by using legacy GRUB boot loader by making two separate directories for the chainloader and the other configuration. Each directory contains all the files necessary to install and make work GRUB boot loader.
Legacy GRUB has command option --prefix which enables to use different GRUB config files for different GRUB installations.
grub2-install --boot-directory=/master /dev/sda
Here's an example:
To install MBR grub chainloader:
In grub shell I use: setup --force-lba --prefix=/boot/grub.chainload (hd0) (hd0,0) # in this case config files in /boot/grub.chainload dir are used.
And to install the OS's own boot loader on the root partition: setup --force-lba (hd0,0) (hd0,0) # here the default /boot/grub is used.
Now my question: how can I do the same with GRUB2? I would like to have a main GRUB2 menu/loader on the MBR which chainloads GRUB2 loaders on the different root partitions.
Since GRUB2 configuration files are spotted at different places (/etc/default/grub, /boot/grub2/grub.cfg, /etc/grub.d/* scripts),
The only configuration file is grub.cfg. Everything else is used by grub-mkconfig to generate it, but use of grub-mkconfig is in no way mandatory. You are not going to install new OS every day I guess so master grub.cfg will be pretty static and can be created once and then manually adjusted when OS are added/removed.
I don't know how I could make different configuration files for the different install locations, not to mentions how I could install the different GRUB2 loaders to different locations (to mbr and to the root partition).
In principle you could embed grub.cfg into master grub image (assuming you have enough space in post-MBR gap).
I would appreciate any help in this matter.
Thanks in advance,
Istvan
ps: Please don't ask me why I do want to do this and please do not suggest that I use one GRUB2 menu to load all of the different OS-es. I want to do it because I could do it with legacy GRUB and I expect that it is doable with the advanced GRUB2 too, and anyway I got used to do it that way. Thanks.
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 07/19/2018 05:02 PM, Istvan Gabor wrote:
I have several linux OS-es on a hard disk. Each OS has its own boot loader installed on the OS's root partitition. The MBR has also a boot loader. This boot loader chainloads the other boot loaders on the root partitions. This makes easy to completely separate different boot menus for different OS-es.
I do this as well.
For the management of the above scenario at least one of the OS-es must have 2 different boot loader install configurations, one for the mbr boot loader (chainloader) and one for the OS's own boot loader on the root partition.
There's another way. What I do is reserve a small (~256M) ext2 partition just for the "master" GRUB loader. Using /dev/sda5 as an example: mount /dev/sda5 /mnt/grub grub2-install --boot-directory /mnt/grub /dev/sda This installs GRUB to /dev/sda5 and makes the MBR boot it. You'll have to provide your own grub.cfg to chainload to the installed operating systems, but that's largely an exercise in cut 'n' paste from your existing /boot/grub2/grub.cfg. You don't have to worry about /etc/grub.d because you're editing grub.cfg yourself rather than relying on the update-grub2 scripts to magically do it. I also make this "master" GRUB partition bootable: grub2-install --force --boot-directory /mnt/grub /dev/sda5 That way, if the MBR gets trashed, you can just start GRUB from a rescue disk and manually chainload to it from the GRUB command line to get access to all your installed operating systems: set root=(hd0,5) chainloader +1 This is what my "master" GRUB menu looks like: https://www.lyonlabs.org/shoggoth-boot.png I can provide the grub.cfg if you'd like to see it. -- Glenn Holmer (Linux registered user #16682) "After the vintage season came the aftermath -- and Cenbe." -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (4)
-
Andrei Borzenkov
-
Carlos E. R.
-
Glenn Holmer
-
Istvan Gabor