You are not logged in.

#1 2013-02-08 17:11:29

beatgammit
Member
Registered: 2012-04-25
Posts: 18

Why is installing GRUB2 to a partition's boot sector discouraged?

I am am multi-booting Arch, Fedora and Windows. I don't use Windows much, and I only keep Fedora around as backup.

Since Fedora needs to change its GRUB entry every time it gets a new kernel, I have Fedora controlling the boot sequence. Since I primarily use Arch, it seems a little silly for Fedora to own GRUB, especially since I am more likely to replace Fedora than Arch (and then I'd have to set up GRUB all over again).

I was thinking about chain loading GRUB2. Arch would own GRUB and include an option to chain load Fedora's GRUB. If I replace Fedora, I would just need the new distro to install GRUB to it's partition and I wouldn't have to touch a thing in Arch. For example:

Arch's GRUB entries:

Arch Linux
Windows
Other (chain load)

Fedora's GRUB entries:

Fedora
Windows

If I break Arch's GRUB, I can boot into a live CD, reinstall GRUB to point to Fedora and fix everything else from Fedora.

However, I read on the Arch wiki that this is not supported and may cause stability issues in GRUB.

What does that mean exactly? Is there a better way to have Arch own GRUB, but also let Fedora update its own entries when it gets a new kernel? It would be awesome if I could load additional entries from another partition's grub.cfg...

Offline

#2 2013-02-08 19:31:35

henk
Member
From: Weert, Netherlands
Registered: 2013-01-01
Posts: 334

Re: Why is installing GRUB2 to a partition's boot sector discouraged?

Hi,
The problem that may occur is stated on the same page:

grub-bios relies on embedded blocklists in the partition bootsector to locate the /boot/grub/i386-pc/core.img file and the prefix dir /boot/grub. 
The sector locations of core.img may change whenever the filesystem in the partition is being altered (files copied, deleted etc.)

The workaround:

The workaround for this is to set the immutable flag on /boot/grub/i386-pc/core.img (using chattr command as mentioned above) 
so that the sector locations of the core.img file in the disk is not altered.

I've done this now several times with Arch, using Xubuntu's Grub to multiboot. the only problems I had:
-I never seem to have an i386-pc directory in /boot/grub. I always have to copy it from /usr/lib/grub.
-Xubuntu's Grub never sees Arch rightaway. I have to mount the "Arch"-partition" under /mnt (in Xubuntu) , and then I can add it to the Grub menu (Grub Customizer)
Apart from this, no problems booting.

Offline

#3 2013-02-09 07:15:54

beatgammit
Member
Registered: 2012-04-25
Posts: 18

Re: Why is installing GRUB2 to a partition's boot sector discouraged?

I saw that, but I wasn't sure if that's all it meant. I get a little wary when I read something that says it's not supported. It doesn't really seem like an unreasonable workaround, especially since grub works on such a low level.

So, do you actually chain load? I was thinking I'd have grub boot arch's config, chain load to fedora's copy of grub then boot fedora. Do you have the same setup?

Thanks!

Offline

#4 2013-02-09 09:42:19

henk
Member
From: Weert, Netherlands
Registered: 2013-01-01
Posts: 334

Re: Why is installing GRUB2 to a partition's boot sector discouraged?

grub-bios does not encourage installation to a partition boot sector

is what the page tells you. Not encouraging is not the same as not supporting. So if you want to, there is a way to do it. That's what the wokaround is for.

The only thing I chainload is Windows 7. Arch is in the menu just like my other distros:
A piece of Xubuntu grub.cfg

### BEGIN /etc/grub.d/10_linux_proxy ###
menuentry "Xubuntu, with Linux 3.2.0-36-generic" --class ubuntu --class gnu-linux --class gnu --class os {
	recordfail
	gfxmode $linux_gfx_mode
	insmod gzio
	insmod part_msdos
	insmod ext2
	set root='(hd0,msdos6)'
	search --no-floppy --fs-uuid --set=root bf29d81f-773e-4315-af01-b2dc005da815
	linux	/boot/vmlinuz-3.2.0-36-generic root=UUID=bf29d81f-773e-4315-af01-b2dc005da815 ro   quiet splash $vt_handoff
	initrd	/boot/initrd.img-3.2.0-36-generic
}
### END /etc/grub.d/10_linux_proxy ###

### BEGIN /etc/grub.d/11_os-prober_proxy ###
menuentry "Arch GNU/Linux (on /dev/sda8)" --class gnu-linux --class gnu --class os {
	insmod part_msdos
	insmod ext2
	set root='(hd0,msdos8)'
	search --no-floppy --fs-uuid --set=root 2c0edb1a-1b27-4da0-9da0-9e41026bec79
	linux /boot/vmlinuz-linux root=UUID=2c0edb1a-1b27-4da0-9da0-9e41026bec79 ro quiet
	initrd /boot/initramfs-linux.img
}
### END /etc/grub.d/11_os-prober_proxy ###

Offline

#5 2013-02-09 17:45:32

bgc1954
Member
From: Edmonton, AB, Canada
Registered: 2006-03-14
Posts: 1,160

Re: Why is installing GRUB2 to a partition's boot sector discouraged?

Just my 2 cents - I use syslinux as my bootloader for about 8 distros besides arch on one hdd--I just find syslinux more straightforward than grub2.  My other linux distros use grub2 and I always install the others to the root partition with no trouble as they generally have that option and I don't want my Arch syslinux mbr screwed over by another distro's grub.  Every once in awhile I've found that when trying out a new distro there is no option to install grub to a partition and they automagically install to the mbr--then I swear a little and reinstall my syslinux mbr from a live arch cd, and remove that distro from further testing.  Chainloading is fine from grub2 but I just found syslinux more like legacy grub which I preferred--like I said just my 2 cents.  One day I'll have to bite the bullet and give grub2 a real chance.


Time is a great teacher, but unfortunately it kills all its pupils ... - Louis Hector Berlioz

Offline

#6 2013-02-10 12:33:39

nowahn
Member
From: elsewhere
Registered: 2008-12-05
Posts: 75

Re: Why is installing GRUB2 to a partition's boot sector discouraged?

Hi,

The normal way to chainload to another grub in grub-legacy was to install the secondary grub on the boot partition of the secondary system, then to chainload it from the primary grub.

The normal way to do this with grub2 is not to chainload a partition, but to load the secondary grub as a kernel, it is explained in this section of the grub wiki.
The wiki explains very well how to setup the secondary system (--grub-setup=/bin/true option to grub-install), but I had a hard time to figure out how to load the core.img file from the primary grub, so here it is:

set root='whatever' # or with a search command
multiboot /boot/grub/i386-pc/core.img # or whatever path to it

With this setting, you will have the same behavior as with the grub-legacy chainloading setting, which I think is what you want.


take time to daydream, inspiration comes ...

Offline

#7 2015-05-14 08:13:26

p_schott
Member
Registered: 2006-11-23
Posts: 54

Re: Why is installing GRUB2 to a partition's boot sector discouraged?

Hi,

Another option to do what you want may be "configfile inclusion" as described here or here.

To "chainload" to my Fedora installation, I simply added

menuentry "Fedora" {
        configfile (hd0,1)/boot/grub2/grub.cfg
}

in /etc/grub.d/40_custom (and run again grub-mkconfig -o /boot/grub/grub.cfg, see ArchWiki)

Of course you have to adapt (hdX,Y) and the path to grub.cfg.

Offline

#8 2015-05-14 08:23:53

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,788
Website

Re: Why is installing GRUB2 to a partition's boot sector discouraged?

Hi p_schott, necrobumping your account is fine, but please let dead topics rest in peace.

https://wiki.archlinux.org/index.php/Fo … bumping.22

Closing,.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

Board footer

Powered by FluxBB