Any grub2 tidbits to pass on ? 12.2 'may' default to grub2

I was reading a discussion on the mailing list, and it appears possible that openSUSE-12.2 ‘may’ default to grub2 as the boot manager.

I’ve never bothered to read up on grub2, but one thing I have learned over the years, is that some familiarity with the old grub1 has saved me countless hours and helped me keep my hair in place. Hence I think it behooves me to learn about grub2.

I think both Fedora and Ubuntu use grub2 … I note a wiki here: GNU GRUB - Wikipedia, the free encyclopedia

… still, are there any tidbits that can be passed by those openSUSE users on our forum who use grub2 on openSUSE-12.1 or 11.4 ?

I think on the mailing list the debate is still in progress, whether grub2 for openSUSE-12.2 will put its boot.img in the MBR or in a partition’s Volume boot record … I’m hoping what ever is implemented, that we as users are given the choice as to where grub2’s boot.img is located. I do know this is a ‘hot topic’ amongst our users, with polarized views on this.

My own preference is not to put anything on the MBR if I can avoid it (other than the original MBR that was on the PC when I procured it, which is typically an MS-Windows MBR).

… but again, my reason for starting this thread is to ask for Grub2 tidbits, that might come in handy with openSUSE-12.2 if grub2 becomes the default boot manager.

So I too would be interested in learning how to use Grub2 and found a couple of other links that look nice here:

GRUB 2 bootloader - Full tutorial

One thing I do a lot of is to compile my own kernel, using my bash script SAKC, which must add in the new kernel load to your Grub menu.lst file. Basically, we need for all things to automatically be added just as before to the Grub2 menu and to have a way to edit that grub menu without being a grub2 master. I hope that such a YaST editor will be present should a switch to Grub2 is made.

Thank You,

I hope that such a YaST editor will be present should a switch to Grub2 is made.

I would hope so too.

FWIW, I think please_try_again’s posts in this thread are of interest.

According to the mailing list, one can refer to the wiki page for current status and information on the grub2 implementation in openSUSE … openSUSE:YaST2 And Perl Bootloader Grub2 Modules Implement - openSUSE

The opensuse-factory mailing list thread is here: [opensuse-factory] Grub2 as default bootloader for installation](

Here is the post that started off the discussion:

That’s educational … but it is a bit heavy going, possibly in part because I’m suffering from a head cold, and possibly (more likely) because I’m simply slow when it comes to new things.

I believe it will take me a while (and some practice) before I can absorb this. … I’m not ready yet to put grub2 on my sandbox PC and explore … but maybe in a couple of months I may be more adventurous.

I found it interesting on how one could have the legacy grub, and grub2, on the same PC, where the legacy grub would boot, and the grub2 code would be in its associated root partition. This section describes it : GRUB 2 bootloader - Full tutorial

In the example, with legacy grub already in place, after then installing a second GNU/Linux version, but this version with grub2 (installing grub2 image on to the sda6 root partition of the new install) when rebooting, one does not see the new GNU/Linux, but only the original Linux on the PC (which uses legacy grub). In the example they then edited the legacy grub’s menu.lst, adding this entry:

title Ubuntu 9.10 Karmic Koala
root (hd0,5)
kernel /boot/grub/core.img

where in this example the new GNU/Linux (Ubuntu 9.10 Karmic Koala) is on /dev/sda6. By making that edit, they then had a selection in the legacy grub, that allowed them to boot from the legacy grub, to grub2, and then to the Ubuntu 9.10 Karmic Koala.

It has me wondering how will this work with openSUSE-12.2 ? I assume we will be given the flexibility to choose where grub2 boot image is installed (ie in the MBR, or in the extended partition, or in the root partition). Will the image file be called ‘core.img’ , or will it have another name ?

Has anyone any insight, tidbits to offer there ?

I am asking as I want to learn (in advance if possible) how to install 12.2 milestones with grub2 (on a PC with multiple operating systems), without touching the existing MBR nor touch the existing legacy grub on that PC.

Do not ever never put grub2 in mbr I did and there is no way to recover. escape on the boot screen puts you into an editor but the grub2 editor is completely different from grub legacy editor

On 2012-03-11 12:06, oldcpu wrote:
> I am asking as I want to learn (in advance if possible) how to install
> 12.2 milestones with grub2 (on a PC with multiple operating systems),
> without touching the existing MBR nor touch the existing legacy grub on
> that PC.

I have seen the same question asked in the factory mail lists. Devs should
tell us what to expect when installing factory with grub 2 on machines that
also have other stable installs.

Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

Like you and others, I do not want to put grub2 in the MBR if I can avoid it.

Still, mistakes can be made, and I can see myself making a mistake if I don’t pay attention.

Hence if I do not learn otherwise, my plan is to use an existing backup of MBR (which I have already made prior to any future effort in installing 12.2 M2 (or M3, or what ever milestone version includes Grub2 as the default boot manager)). I previously backed up MBR from a terminal with:

dd if=/dev/sda of=mbr-sandbox-pc-440 bs=440 count=1

where the file ‘mbr-sandbox-pc-440’ is the backup of my sandbox PC’s MBR without the partitioning information. I have that file kept on a memory stick (and on another PC).

To restore would be to boot to a live CD, insert the memory stick, go to the location where the file is, and send in a terminal:

dd if=mbr-sandbox-pc-440 of=/dev/sda bs=440 count=1

‘dd’ can be a dangerous command, and one needs to be very careful when using it.

Well today, I had my first real encounter with attempting to modify or otherwise make modifications with the grub2 menu in openSUSE 12.2 which does not yet contain a YaST method for Gub2 menu additions I can find. What I did was to use my SAKC kernel compiler to compile the latest release stable kernel 3.3 from My script failed at the end with an error code, which apparently is because no /boot/grub/menu.lst file was found to make changes to I guess. It did actually create the three required kernel files however. So, how might one add that to the grub2 menu I wondered? I found that there is a command called grub2-menulst2cfg that will take an existing menu.lst file and convert it to a grub.cfg file. I do not yet know if a grub.cfg file is obsolete but this file did exist in the folder /boot/grub2, but it was blank and did not contain a thing. So, the instructions I found said you could do the following in terminal:

su -
grub2-menulst2cfg /boot/grub/menu.lst /boot/grub/grub.cfg

In my hand built menu.lst file, which was missing at first, I placed the commands:

# Modified by YaST2. Last modification on Tue Mar 20 17:36:12 CDT 2012
# For the new kernel it try to figure out old parameters. In case we are not able to recognize it (e.g. change of flavor or strange install order ) it it use as fallback installation parameters from /etc/sysconfig/bootloader

default 0
timeout 30
##YaST - generic_mbr
gfxmenu (hd0,1)/boot/message
##YaST - activate

###Don't change this comment - YaST2 identifier: Original name: linux###
title Desktop -- openSUSE 12.2 - 3.3.0-1
    root (hd0,1)
    kernel /boot/vmlinuz-3.3.0-1-desktop root=/dev/disk/by-id/ata-VBOX_HARDDISK_VB9f39229b-b53a511c-part2 resume=/dev/disk/by-id/ata-VBOX_HARDDISK_VB9f39229b-b53a511c-part1 splash=silent quiet showopts vga=0x346
    initrd /boot/initrd-3.3.0-1-desktop

When I ran the grub2-menulst2cfg, I got no output and the command line came back immediately. But low and behold, the /boot/grub2/grub.cfg file was no longer blank. I quickly saved my work outside of the VM openSUSE 12.2 was running in and rebooted. The result was an added menu option that said “previous version”. Humm I thought, so I selected it and then another menu arrived and it was my added kernel 3.3 from above. I selected it and low and behold I am running kernel 3.3 final in openSUSE 12.2. Of course openSUSE 12.2 will contain kernel 3.3 final soon enough and the exercise was to determine if my SAKC script worked and if I could get a new menu in grub2. And the answers are a firm kind of and kind of. I am sure more will be reveled in the future, but at least there is a kluge method that one can use to add a kernel load menu to grub2 in openSUSE 12.2 M2.

Thank You,

This is from the factory mailing list. It solved my dual boot problem with grub2
On Tue, Mar 20, 2012 at 07:45:20PM -0400, Dale Ritchey wrote:
On 03/20/2012 06:24 PM, Ken Schneider - openSUSE wrote: [INDENT]
On 03/20/12 17:03, Dale Ritchey pecked at the keyboard and wrote: [INDENT]
I have sda1 gnome sda2 kde with grub2 I can boot either gnome of kde, but not both. How do I multi boot?
HUH?? Do you mean run both at the same time? [/INDENT]
Not at the same time but either or. for example I grub2’d with kde only kde is bootable. now if I switch to the gnome desktop and use grub2 there then only the gnome desktop shows . I am running sda2 that has kde. /boot/grub2/grub.cfg in part allows me to boot the 2 kernels I have installed on sda2 but there is no entry for booting sda1 [/INDENT]
Hi Dale I think that’s becuase os-prober package is missing in installed system. Try commands below and see if it works for you? $ zypper install os-prober $ grub2-mkconfig -o /boot/grub2/grub.cfg We should fix grub2 package to require os-prober … Btw I filed a bugzilla for this issue. Thanks, Michael

I have created a small bash script to help use and learn about grub2 you can find here:

GNU Grub2 Command Listing Helper with --help & Input - Blogs - openSUSE Forums

As always, I would love to hear any comments you might have or want to make.

Thank You,

If you have more than the two menu selections in the Grub2 boot menu, you might want to select something other than the first one as default, or GRUB_DEFAULT=0 (as in the /etc/default/grub file) or as executed at boot time set default=“0” (as in the /boot/grub2/grub.cfg file). There seems to be several steps required to regain the old equivalent of default=saved & savedefault X used in the old grub legacy menu.lst file. If you have more than a couple of entries, but would just like to set something different than the first (called 0), then do the following in your desktop.

Use this code to edit the /etc/default/grub anytime that is required or requested in this message:

In KDE do Alt F2 and enter: kdesu kwrite /etc/default/grub


In GNOME do Alt F2 and enter: gnomesu gedit /etc/default/grub

Then change the line: **GRUB_DEFAULT=0 **to **GRUB_DEFAULT=X, **where X= the menu option to use, starting at 0 for the first to the number one or higher, based on the actual number of boot entries. If you have two entries in menu one and two entries in sub menu one and you want to use the first entry in sub menu 1, then use **GRUB_DEFAULT=2 **in this example.

main menu
boot option 0
boot option 1
sub menu
boot option 2
boot option 3

Anytime you make a change to the /etc/default/grub file, you must run the following terminal command for it to take effect:

su -

Now suppose we do want the equivalent of default=saved & **savedefault X **that existed in Grub Legacy, how might we do that? Well first, you must make another change to the /etc/default/grub file and further, we need to create a valid grub2 environment block. This environment block does not exist by default. To create this block, you need to do the following in a terminal session:

su -
cd /boot/grub2
rm grubenv
grub2-editenv grubenv create
grub2-editenv grubenv set default=0
grub2-editenv grubenv list

The rm grubenv is there only if a blank or invalid grubenv file exists already and gives an error when no grubenv file exists to remove, which is normal. Now there will be a place to create the saved values for the grub2 menu selection that we use and contains only default=0 for now. Next, we need to edit the ** /etc/default/grub** file as root and shown above. Lets change/add the following lines:


The GRUB_DEFAULT=0 was the default before and GRUB_SAVEDEFAULT=true was not there before. Just as before, for these new settings to take effect we need to open terminal and run the command:

su -

Finally, what if you are like me, and you don’t like your other menu entries to be setup as a sub-menu and prefer them to all exist on a single menu, we can modify one of the script files located in /etc/grub.d to do this. For this modification do the following:

In KDE do Alt F2 and enter: kdesu kwrite /etc/grub.d/10_linux


In GNOME do Alt F2 and enter: gnomesu gedit /etc/grub.d/10_linux

Go to the end of the file and find this:

if  "$list" ] && ! $in_submenu; then
   echo "submenu \"Previous Linux versions\" {"

if $in_submenu; then
  echo "}"

Make all a comment by adding a # as the first entry of all but one of the lines as shown below. Make sure to NOT remark out the done command, else the script will fail to run.

#  if  "$list" ] && ! $in_submenu; then
#    echo "submenu \"Previous Linux versions\" {"
#    in_submenu=:
#  fi

# if $in_submenu; then
#  echo "}"
# fi

Save your changes and exit the edit of the script. Finally, to make your changes work, run the following terminal command:

su -

Please let me know if you have any questions, corrections or suggestions.

Thank You,