Grub2 - How do I specify the root partition for my old boot entries?

I’ve just gone through the network installation and set up an openSUSE 12.3 system on an empty partition. I deliberately left the openSUSE 12.2 partition untouched so that I can boot back into the familiar environment until everything is working properly with 12.3. Grub2 does a nice job of enumerating the other openSUSE versions strewn around my partitions. But when I pick the 12.2 entry and boot it, the root device is that of 12.3! I can edit the entry before booting (by pressing e) and can change the partition by hand which boots up the correct 12.2 OS.

I could edit the /boot/grub2/grub.cgf file and could correct the partition id there but the first line sternly says “DO NOT EDIT THIS FILE”.

I gather this file is built by the /etc/grub.d/30_os-prober script. This looks rather involved and doesn’t seem to give me a nice and easy way to say “Use partition /dev/sdc5 for openSUSE 12.2 and use partition /dev/sdc6 for 12.3”.

Skipping through the script I see there is something called os-prober which does correctly identify my OSs:

hosti:/etc/grub.d # os-prober
[snip]
/dev/sda3:Windows Vista (loader):Windows:chain
/dev/sda5:openSUSE 12.1 (x86_64):SUSE:linux
/dev/sdc2:openSUSE 12.2 (x86_64):SUSE1:linux
/dev/sdc5:openSUSE 12.2 (x86_64):SUSE2:linux

Perhaps the problem is coming from the linux-boot-prober script?

host:/etc/grub.d # linux-boot-prober /dev/sdc5
/dev/sdc5:/dev/sda6:openSUSE 12.3:/boot/vmlinuz-3.7.10-1.1-desktop:/boot/initrd-3.7.10-1.1-desktop:root=UUID=b2e4c669-d225-4a7a-ac65-75f89044313a resume=/dev/disk/by-id/ata-ST3500620AS_9QM6RXV9-part1 splash=silent quiet showopts
/dev/sdc5:/dev/sda6:openSUSE 12.3, with Linux 3.7.10-1.1-desktop:/boot/vmlinuz-3.7.10-1.1-desktop:/boot/initrd-3.7.10-1.1-desktop:root=UUID=b2e4c669-d225-4a7a-ac65-75f89044313a resume=/dev/disk/by-id/ata-ST3500620AS_9QM6RXV9-part1 splash=silent quiet showopts
/dev/sdc5:/dev/sda6:openSUSE 12.3, with Linux 3.7.10-1.1-desktop (recovery mode):/boot/vmlinuz-3.7.10-1.1-desktop:/boot/initrd-3.7.10-1.1-desktop:root=UUID=b2e4c669-d225-4a7a-ac65-75f89044313a showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset x11failsafe
/dev/sdc5:/dev/sda6:openSUSE 12.3, with Linux 3.4.33-2.24-desktop:/boot/vmlinuz-3.4.33-2.24-desktop:/boot/initrd-3.4.33-2.24-desktop:root=UUID=b2e4c669-d225-4a7a-ac65-75f89044313a resume=/dev/disk/by-id/ata-ST3500620AS_9QM6RXV9-part1 splash=silent quiet showopts
/dev/sdc5:/dev/sda6:openSUSE 12.3, with Linux 3.4.33-2.24-desktop (recovery mode):/boot/vmlinuz-3.4.33-2.24-desktop:/boot/initrd-3.4.33-2.24-desktop:root=UUID=b2e4c669-d225-4a7a-ac65-75f89044313a showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset x11failsafe
/dev/sdc5:/dev/sda6:openSUSE 12.3, with Linux 3.4.6-2.10-desktop:/boot/vmlinuz-3.4.6-2.10-desktop:/boot/initrd-3.4.6-2.10-desktop:root=UUID=b2e4c669-d225-4a7a-ac65-75f89044313a resume=/dev/disk/by-id/ata-ST3500620AS_9QM6RXV9-part1 splash=silent quiet showopts
/dev/sdc5:/dev/sda6:openSUSE 12.3, with Linux 3.4.6-2.10-desktop (recovery mode):/boot/vmlinuz-3.4.6-2.10-desktop:/boot/initrd-3.4.6-2.10-desktop:root=UUID=b2e4c669-d225-4a7a-ac65-75f89044313a showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset x11failsafe

The /dev/sda6 partition is my ext4 /boot partition but the UUID=b2… partition is /dev/sdc6 instead of /dev/sdc5 which starts with f5…

Is the script buggy or should I be doing something different? Could it be that the mentioned difference between Grub and Grub2 of adding 1 to the partition number is hitting me here?

Regards,
Richard

So you did not install the openSUSE 12.3 grub2 but you are using grub2 from openSUSE 12.2? You can lodge a bug report on openSUSE 12.2 I guess, but you kind of need to use the 12.3 grub2 I would guess to lodge a bug report for it. Your install is not exactly normal, though I did not say it could not work. I have a bash script useful to work with grub2 here: GNU Grub2 Command Listing Helper with --help & Input - Blogs - openSUSE Forums

Thank You,

Is /boot shared between 12.2 and 12.3?

/boot is shared between 12.2 and 12.3.
I believe grub2 from 12.3 reinstalled itself on the machine. The graphics and menu all look snazzier.
I do think the issue is with the grub.cfg file that is built and populated with the wrong partition.
I’ll check out the grub2cmd in the evening.

Thanks,
Richard

Is it realy possible to share a /boot between different systems?

And when yes (maybe only in certain strict defined combinations) is it realy advisable? Beacuse when it is possible to do in some combinations and under strict rules. one easily deviates from those rules (either by forgetting to kep to those rules, or by installing something (kernel?) on one of the sysytems involved that does not keep to those rules…

That does not work. os-prober checks which root system has this /boot in /etc/fstab and assumes this is operating system that owns everything. Also it means you have a single copy of grub.cfg so two systems will overwrite it every time bootloader configuration is changed.

That’s the problem them.

Though, I don’t necessarily agree that this should be so: Yes, there will only be one grub.cfg but then there is only one computer which wants to boot multiple different operating systems. So, as long as all the entries are correctly defined in the grub.cfg then I can start whichever I choose.

As for sharing /boot: Yes there will be different versions of the kernel lying around in the directory. Again, as long as the right vmlinux, initrd etc. is identified in the grub.cfg there is nothing to hinder coexistance.

The bigger annoyance is that in order to have a multi-boot environment we now don’t just have to have a different partition for each version of the OS but we also have to have an additional partition for /boot as well! (Because /boot can only live on a subset of filesystems (like ext4) and not on btrfs for instance) (Btrfs is attractive because in an environment where you have split up your large disk into a number of small partitions you can just add an extra partition to the filesystem when/if you run out of space.)

Regards,
Richard

Did you try it?