GNU Grub2 Command Help/Config Editor - Version: 2.01

openSUSE 12.2 and 12.3 is using Grub2 by default and Grub2 has a whole new command set to learn. In order to help us all better use Grub2, I have put together a small script that shows all 24 commands I have found. When a command is selected, its default help, if present, will be displayed for you. You can then enter any command options for that command and press the enter key for them to be executed, as root, or just press the enter key to look at another command. In addition, I have found and allow you to view the included Grub2 manuals if you select Help. Grub2Cmd will detect if you have Grub2 or Grub2-efi installed and use the properly located menu file.

And Now, you have the option to edit any of the grub2 configuration files from the following menu. Your desktop will be determined, the correct SU command used and the proper Text Editor will be selected. I have added the ability to add a new script, to be executed on each update of your grub.cfg file. You can also delete a script file if you wish, but be careful to not delete existing script files here.

I have added a new function that allows you to select the default Grub 2 boot menu selection, even if it is included in the Advanced menu section. When changing the default Grub 2 boot selection, I have made some assumptions. The value “GRUB_DEFAULT=” can only exist once in the /etc/default/grub text file with no commented out duplicate entries that contain this same string value. I assume you still have/use the Advanced openSUSE grub 2 menu and have not removed it. Any grub 2 Linux Kernel menu entry used for Recovery can not be set as the default. Finally, when reverting back to the openSUSE grub 2 default for menu option 1, “GRUB_DEFAULT=saved” will be used.

The main menu allows you to determine just what framebuffer video modes are supported by grub 2. If you select the same and final resolution as used by your desktop, some slight speed up will be noticed. This is a list of fram buffer modes supported on my PC.

If you are not using a GPT Disk to boot Grub 2 in EFI mode and you still have an installed copy of Windows, you can use my new option to create a custom Windows boot menu option for Grub 2. Your hard disk(s) will be scanned for bootable NTFS partitions using fdisk.

So, if you are running openSUSE 12.2 and grub2 is detected as being installed, you can use the grub2cmd helper bash script I have written. This bash script I call grub2cmd can be obtained from SUSE Paste. I have written the grub2cmd bash script to reside in the ~/bin folder. Select the Download option in the top right using the link shown below and select open with Kwrite or another text editor. Then save the following text into the file called grub2cmd (as in /home/username/bin/grub2cmd):

GNU Grub2 Command Help/Config Editor - Version: 2.01

It is possible to directly download the script from SUSE Paste using the following commands (You must delete the old version of grub2cmd first should one exist). Just open up a terminal session and copy the text from any code block show here and past it after the terminal prompt and then press enter:

rm ~/bin/grub2cmd
wget -nc http://paste.opensuse.org/view/download/58627662 -O ~/bin/grub2cmd

Next, you need to mark the file grub2cmd as executable with the following command:

chmod +x ~/bin/grub2cmd

You can add all three commands above and run it as one. Just copy and paste the following command into a terminal session:

rm ~/bin/grub2cmd ; wget -nc http://paste.opensuse.org/view/download/58627662 -O ~/bin/grub2cmd ; chmod +x ~/bin/grub2cmd

To use grub2cmd run the terminal command:

grub2cmd

Grub2Cmd now creates a desktop icon if it finds you are running the KDE desktop and a KDE menu icon. Settings for these icons exist at the top of the script should you wish to disable them.

In my grub2cmd bash script I have the frame buffer command there to determine what is supported. You then go into YaST / System Boot loader, or use the same option from my bash script, then Boot Loader Options, and enter the VGA mode number in the VGA Mode number block (I use 0x034d), right after the number of seconds the menu is to wait. Then on the bottom left, I enter the equivalent Console Resolution number, I am using 1920x1200, that equates to the mode number. I use the highest resolution the Frame Buffer command finds, which may not be the highest supported by your monitor if you are then loading a Proprietary Video Driver I have found. But, it must be a supported Frame Buffer Mode on your setup to work properly. Following this method allows the Plymouth display to work I have found.

The new openSUSE 12.2 Documentation has a nice write up on using Grub 2 that is worth reading which you can find here:

openSUSE 12.2: Chapter 8. The Boot Loader GRUB2

We have some additional Great Articles about Grub 2 you can find here:

Booting openSUSE on UEFI BIOS with ELILO and Grub2 (part I)

AND

Booting openSUSE on UEFI BIOS with ELILO and Grub2 (part II - Windows dual-boot )

AND

Re-install Grub2 from DVD Rescue

If you have any questions or comment about using the bash script grub2cmd, just leave me a comment here.

Thank You,

Blogs: asroot : Bash : Packet Filter : C.F.U. : GPU’s : fewrup : F.S.M. : H.I. : nVIDIA : LNVHW : N.S.F. : S.A.K.C. : MMCHECK
S.A.S.I. : S.C.L.U. : S.G.T.B. : S.K.I.M. : S.L.A.V.E. : S.L.R.C. : S.T.A.R.T. : S.U.F.F. : SYSEdit : systemd : YaST Power

Booting from ISO Image:

You can boot from an ISO image with a new menu option, shown at the bottom of the grub 2 menu. First, select an ISO image to use. For openSUSE 13.1, we have the new Rescue image:

32-BIT: http://download.opensuse.org/pub/opensuse/distribution/13.1/iso/openSUSE-13.1-Rescue-CD-i686.iso

64-BIT: http://download.opensuse.org/pub/opensuse/distribution/13.1/iso/openSUSE-13.1-Rescue-CD-x86_64.iso

Next, after the download, I placed the ISO image into the folder /boot, which is on my root / partition. I then used the grub2cmd bash script to edit the file /etc/grub.d/40_custom as root. I placed the following code in this file:

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

menuentry "openSUSE 13.1 Rescue-CD x86-64 DVD" {
  insmod loopback
  insmod udf
  insmod iso9660
  insmod gzio
  insmod part_msdos
  insmod ext2set root=(hd0,3)
# full path to iso image, I placed it in the root boot folder.
  set isofile=/boot/openSUSE-13.1-Rescue-CD-x86_64-Build0091-Media.iso
# Where is your Root Partition?  hd0=1st disk and 3=3rd Partition. !Important!
  set root=(hd0,3)
  loopback loop $isofile
# .../linux "install" it may contain install, upgrade, rescue - install start installation process
 linux (loop)/boot/x86_64/loader/linux install=hd:$isofile
  initrd (loop)/boot/x86_64/loader/initrd
}

Notice the line “set isofile=/boot/openSUSE-13.1-Rescue-CD-x86_64-Build0091-Media.iso”, as it must be right. Next, notice the line that says " set root=(hd0,3)" as it must be modified to point to your root partition. Once you add the right code, go back to the grub2cmd main menu and select " 3) Update grub.cfg Menu (For All Changes!)" to lock in your new 40_custom file into you grub menu. The new menu option will say “openSUSE 13.1 Rescue-CD x86-64 DVD”, shown at the bottom.

Thank You,

OK 2 questions possible dumb one 1st

  1. Can/is this meant for 12.2 Tests?
  2. Did I read that~/bin right that is the /home/bin not a typo?
    I don’t want or mean to sound trite I just want to be sure. Sometimes I don’t see as well as used to.

[QUOTE=Sagemta;bt456]OK 2 questions possible dumb one 1st

  1. Can/is this meant for 12.2 Tests?
    Yes this is intended for openSUSE 12.2
  2. Did I read that~/bin right that is the /home/bin not a typo?
    Yes, you put this in the ~/bin folder as suggested. Another location for all users might be /usr/local/bin/ if you wish.
    I don’t want or mean to sound trite I just want to be sure. Sometimes I don’t see as well as used to.[/QUOTE]

Sorry for the late response as I have been busy this week.

Thank You,

Grub2 Command has a minor update to version 1.60 to fix a couple of commands that did not work properly, to allow you to have a null command and to remove the dbus-launch command I had been using, apparently for no good reason. As always, if you have a comment, I would love to hear what it is. Happy scripting to you!

Thank You,

I have updated grub2cmd to version 1.70 and have modified the program for present existing grub 2 commands, added an option to update the grub.cfg file for any changes made and added an internal check for the file /etc/default/grub so that its permissions can be modified so requested help on some applications like grub2-install can be made without being a root user. Since the present grub2 commands list did change, I have modified grub2cmd to notify you if it is looking for a command no longer present. As always, let me know if you have any problems or requests.

Thank You,

http://paste.opensuse.org/view/download/27307252

If anyone has wondered about the new grub 2 selection menu in openSUSE 12.2 then here is what these two lines mean when selected.

  1. The top line just called openSUSE, will select the most recently installed kernel standard load line when selected. Each time a new kernel is installed from any source, the top line will load it.
  2. Advanced options for openSUSE, will list all installed kernels and their recovery modes when selected. This will include the same kernel to which the top openSUSE line refers to.
  3. By default, the first entry called openSUSE will be used after five seconds has expired if nothing else is selected. Press the up or down arrow once to stop the default kernel load timer.
  4. If you select the Advanced options for openSUSE and change your mind, just press the ESC key to return back to this original menu.

Thank You,

I have updated Grub2Cmd to version 1.72 and added an internal check for the file /etc/default/grub for chmod 755 so that its permissions can be modified so requested help on some applications like grub2-install can be made without being a root user. Grub2Cmd now creates a desktop icon if you use the KDE desktop. I have added two main menu commands to determine allowable desktop resolutions and to run the YaST boot loader module.

Thank You,

I have raised Grub2Cmd to version 1.75 with some internal stuff including the ability to run grub2cmd with no desktop loaded at all as a normal user from your /home folder. I have modified the text that asks permission to modify the /etc/default/grub permissions. I change grub2cmd to install the KDE desktop icon only if you are found to be running grub 2 and the KDE desktop. The two sub menus now expect a a M for the Main menu though Q still does work. Other internal fixes have also been made.

Thank You,

Grub 2 error which was discovered using openSUSE 12.2 RC2 during the boot up process.

http://paste.opensuse.org/view/download/66496603

This is what the error message is saying.

You can open up a terminal session and run this command:

sudo cp /boot/grub2/locale/uk.mo /boot/grub2/locale/en_US.mo

Just using the UK file instead of the missing one. This is likely a bug which should be reported.

http://paste.opensuse.org/view/download/91316786

This is what it said after I copied the file over and created the one Grub 2 is looking for.

EDIT: This is not really a fix. It eliminates the error, but the file is not for English. So, don’t use the fix as it is posted here.

Thank You,

After a recent forum post about trying to skip a restore partition from the openSUSE Grub 2 OS selection menu, I have come up with a patch you can use to allow the skipping of any partition from the automatic menu generation. Below is a patch, to be applied to the file /etc/grub.d/30_os-prober as root. Save the following patch file (inside the code tags) as the text file I am calling “30_os-prober.patch”

--- /Software/grub/30_os-prober.org    2012-09-02 04:22:34.512661000 -0500
+++ /etc/grub.d/30_os-prober    2012-09-02 08:06:05.233988062 -0500
@@ -21,6 +21,11 @@
 exec_prefix="/usr"
 datarootdir="${prefix}/share"
 
+# Patch to prevent some partitions being autodetected. Add just the partition
+# name(s) like sda1 between quotes,leaving a space between if more than one.
+GRUB_SKIP_DEVICE=""
+# End of patch
+  
 export TEXTDOMAIN=grub2
 export TEXTDOMAINDIR="${datarootdir}/locale"
 
@@ -113,6 +118,13 @@
   LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
   BOOT="`echo ${OS} | cut -d ':' -f 4`"
 
+  # Patch to prevent some partitions being autodetected
+  PARTITIONNAME="`echo ${DEVICE} | cut -c 6- 2> /dev/null`"
+  if  "`echo ${GRUB_SKIP_DEVICE} | grep -e ${PARTITIONNAME} 2> /dev/null`" ] ; then
+    continue
+  fi
+  # End of patch
+  
   if  -z "${LONGNAME}" ] ; then
     LONGNAME="${LABEL}"
   fi

Lets assume you have saved in your $HOME/Documents folder using the name I used above. Once the file is saved, open up a terminal session and run the command:

sudo patch -u /etc/grub.d/30_os-prober $HOME/Documents/30_os-prober.patch

Once the patch is applied, you can use my bash script grub2cmd to edit the newly patched file /etc/grub.d/30_os-prober and add the partition you want to skip. You could modify the following line like this:

GRUB_SKIP_DEVICE="sda1"

and save your modification. Next, you must run the Grub2Cmd option 3) Update grub.cfg Menu File , so your changes will take effect.

Now, when the 30_os-prober is run, it will skip the partition named /dev/sda1, placing no entry found for that partition in your grub 2 OS selection menu. It is possible if you get an update for the Grub 2 package, this update patch shown here will get over written. Just re-run the patch when required, and leave me a comment here if the patch no longer is working and I can make another.

Thank You,

I have updated GNU Grub2 Command Help/Config Editor to Version: 1.80 for mostly cosmetic changes though the password hash program is now run as a regular user, without the extra password request and the ability to run a grub2 command with no options now works properly. As always, I would love to hear of any problems or comments you may have with the usage of grub2cmd.

Thank You,

GNU Grub2 Command Help/Config Editor - Version: 1.82 has been released. In this latest version, Grub2Cmd will create a new KDE menu icon in addition to the desktop one. Settings to Disable/Enable these icons exists at the top of the bash script. I have added in the device.map file as a editable text file in the Grub2Cmd edit menu. As always, I want to hear your suggestions and/or problem reports.

Thank You,

[QUOTE=jdmcdaniel3;bt545]Grub 2 error which was discovered using openSUSE 12.2 RC2 during the boot up process.

http://paste.opensuse.org/view/download/66496603

This is what the error message is saying.

You can open up a terminal session and run this command:

sudo cp /boot/grub2/locale/uk.mo /boot/grub2/locale/en_US.mo

Just using the UK file instead of the missing one. This is likely a bug which should be reported.

http://paste.opensuse.org/view/download/91316786

This is what it said after I copied the file over and created the one Grub 2 is looking for.

[/QUOTE]
I will likely have to take a pic/vid of it just to confirm that its the same – its pretty hard to catch any of the text, as the message appears and is gone so quickly – but I believe I’m seeing the same on 12.2 final as what you’ve reported here for the RC. Don’t know if others have reported the same or not yet.

Yes, it is the same problem. I had to run openSUSE in a Virtual Session and slowed the speed of it way down to get the picture I posted here. The copy command fixes the error message, but actually, the UK file is not for the united Kingdom at all but is ukrainian, so you get Cyrillic text in ukrainian language on boot. It does not seem to effect most users, but all one can say is the authors of grub 2 must not be speaking English at all as the problem can be traced all the way back to the release of version 2 it would seem. Further, trying to reload grub 2 can mess up ones system if not done right. It is my guess that a fix will come to us as a patch, loading only the missing file. But until then, it does not cause any known problem beyond a quickly flashing error message.

Thank You,

I have updated Grub2Cmd to version 1.85 which can be used to create a new script, to be executed when you update your grub.cfg file. Following is such a script you can create. From the Grub 2 File Edit menu, enter an ‘A’ to add a new script file and call it “05_menu_color”. Add the following text to this new file.

#!/bin/sh -e
set -e

prefix=/usr
exec_prefix=/usr

. /usr/share/grub2/grub-mkconfig_lib

COLOR_NORMAL="black/black"
COLOR_HIGHLIGHT="white/black"

if  "${GRUB_TERMINAL_OUTPUT}" = "gfxterm" ] ; then
        cat <<EOF
set color_normal=${COLOR_NORMAL}
set color_highlight=${COLOR_HIGHLIGHT}
EOF
else
  cat << EOF
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
EOF
fi

When you save the file, you will be asked to enter the root password in order to mark this file executable. Now, enter ‘B’ to go Back to the main menu where you enter the command option 3 to update your grub.cfg with the changes you have just made. Basically, this change will allow the Edit menu in the Grub 2 boot loader to be readable in the normal graphics mode. You might want to do this to follow my example here:

How to Start openSUSE 12.2 with Grub 2 into Run Level 3 - Blogs - openSUSE Forums

The example code shown above was taken from here:

http://forums.opensuse.org/english/get-technical-help-here/install-boot-login/478535-where-give-one-time-boot-options-2.html

And was written by please_try_again. Grub2Cmd also has other changes to the command section where I continue to (try to) get that working properly.

Thank You,

I have updated GNU Grub2 Command Help/Config Editor to Version: 1.90 and have added in a new feature that allows you to select the default Grub 2 boot selection upon time out and it can be selected from the Advanced menu or a Windows entry if either exists. I have added in a new config to view and edit called /etc/sysconfig/bootloader. It was kind of interesting that I was able to add the default grub 2 boot menu selection by using code sections from fastboot, to read your grub 2 menu entries and from make-swat, to allow the changing of a single line from a text file. Some changes did need to be made of course.

When changing the the default Grub 2 boot selection, I have made some assumptions. The value “GRUB_DEFAULT=” can only exist once in the /etc/default/grub text file with no commented out duplicate entries that contain this same string value. I assume you still have/use the Advanced openSUSE grub 2 menu and have not removed it. I assume if you have Windows installed, its menu option will contain the word “Windows” and will not be located in the Advanced menu. Any grub 2 Linux Kernel menu entry used for Recovery can not be set as the default. Finally, when reverting back to the openSUSE grub 2 default for menu option 1, “GRUB_DEFAULT=saved” will be used. As always, if you run into any other issues, I need to know just what they are.

Thank You,

GNU Grub2 Command Help/Config Editor has been updated to Version 1.94 which includes two new commands and the removal of anything extra needed to work with grub2-efi as it now has a link that points to the existing grub.cfg file and so no need to do anything special to work with it.

Thank You,

Hello
I just brand new in opensuse and all Linux distributions I have some questions if you don’t mind . by the way i tried to post my Questions in separate blog or thread but i don’t know how!!
1- there was a windows 7 in my computer then I have installed Opensuse from DVD the Windows 7 still appear in the booting options but when i choose it it didnt work. why it still there as an option ??
2- I want to access grub2 menu.lst but i didnt find in inside the grub2 folder
3- as in your blog you have mention under the bin/ there is a file or folder called grub2cmd !! It is not exist in my laptop !!
4- after i have install Xen the internet wireless icon has disappear :’(

What should I do? sould I re installed opensuse again or what:question::question:

please advise im really disappointed

[QUOTE=emanali;bt668]Hello
I just brand new in opensuse and all Linux distributions I have some questions if you don’t mind . by the way i tried to post my Questions in separate blog or thread but i don’t know how!!
1- there was a windows 7 in my computer then I have installed Opensuse from DVD the Windows 7 still appear in the booting options but when i choose it it didnt work. why it still there as an option ??
2- I want to access grub2 menu.lst but i didnt find in inside the grub2 folder
3- as in your blog you have mention under the bin/ there is a file or folder called grub2cmd !! It is not exist in my laptop !!
4- after i have install Xen the internet wireless icon has disappear :’(

What should I do? sould I re installed opensuse again or what:question::question:

please advise im really disappointed[/QUOTE]

  1. Grub2cmd is a free bash script you can download right here. It is not included in openSUSE by default. Reread this entire Blog before you do anything else.
  2. If a Partition is detected by Grub 2 as being a Windows boot partition it is added to the Grub 2 menu. It is hard for me to know if it still works, but perhaps it does not. Need more info to help. Consider asking for help with this in the standard openSUSE forum.
  3. Grub 2 no longer uses a menu file called menu.lst. The whole purpose of my bash script Grub2cmd, is to assist in switching over to using Grub2.
  4. I would not have installed the xen kernel. We suggest you use VirtualBox as your VM. Xen is for VERY experienced users only and you don’t know how Grub 2 works yet. YOu need to use kernel-desktop to start openSUSE.

I highly recommend you use the openSUSE forum for openSUSE problems while this blog is for comments about using my bash script grub2cmd.

Thank You,