Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Ubuntu 9.10 is out!!!

When downloading Ubuntu 9.10 please consider using bittorrent to get your copy of Ubuntu.

The Ubuntu Developers Summit for Lucid Lynx will be held the week of 16-Nov-2009 till 20-Nov-2009 in Dallas, TX USA. Visit the the Ubuntu wiki for more information about UDS and how to participate remotely.

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
Thread Tools Display Modes
Old October 10th, 2009   #1
drs305
Ubuntu addict and loving it
 
Join Date: Jan 2007
Beans: 6,016
Ubuntu 9.10 Karmic Koala
Grub 2 Title Tweaks Thread

Grub 2 Title Tweaks

or the


I Don't Want It to Say "Microsoft Windows Vista Home Edition" Thread



Purpose
This thread offers tweaks to the Grub 2 10_linux and 30_os-prober files in /etc/grub.d. The purpose is to change the way Titles are displayed on the Grub 2 menu.

With the exception of the "But First" section, the tweaks in this thread are outside the normal options currently available in Grub 2's /etc/default/grub. As Grub 2 options are incorporated by the developers these scripts will be annotated or removed.

If you are looking for an introduction on how Grub 2 works, please visit Grub 2 (Ubuntu Community Help doc), Grub 2 Basics or Grub 2 Introduction elsewhere on the Ubuntu Forums. This thread also does not discuss custom configuration files such as /etc/grub.d/40_custom although these tweaks could be incorporated therein.

Feel free to post your tweaks but please limit this thread to posts concerning the Grub text you see in the menu. Also suggest improvements to the ones I posted - I'll edit them to keep them udpated. See the end of this post for some suggestions.

Hopefully as the capabilities of Grub 2 are expanded or become better understood many of these tweaks will become unnecessary. In the meantime those truly anal among us who can never leave things alone will have a place of refuge.

Background
Grub 2 displays, unlike Grub, are not controlled by a single file but rather by the settings in /etc/default/grub and a series of script files located in /etc/grub.d/ . These scripts determine, in part, how the menu options are transferred into /boot/grub/grub.cfg and the menu you see on boot.

See Grub 2 Basics for a general overview of Grub 2 and for links to other Grub 2 resources.

Before You Start
  1. Make copies of the system files you will be altering.
    Note: If you leave the .bak files executable and in the /etc/grub.d folder they will be run by update-grub.
    Code:
    sudo cp /etc/grub.d/10_linux /etc/grub.d/10_linux.bak
    sudo cp /etc/grub.d/30_os-prober /etc/grub.d/30_os-prober.bak
    sudo chmod -x /etc/grub.d/*.bak
  2. Make sure you are working in the correct file, and in the applicable section of that file.
  3. Run "sudo update-grub" to incorporate the changes into Grub 2's menu.
  4. When defining variables, the ` symbol is not a straight quote symbol but a 'grave'. It is often found near the top left of the keyboard.

But First: Popular "Built-In" Tweaks for the / System Partition
  • Turn Off "MEMTEST86+"
    There is no setting to turn off the "memtest86+" option in /etc/default/grub but you can eliminate these entries by turning off the script that searches for them. The following command removes the "executable" bit from the /etc/grud.d/20_memtest86+ file. To restore the setting, change the "-" to a "+":
    Code:
    sudo chmod -x /etc/grub.d/20_memtest86+
    • This effects only the system partition. If you have multiple partitions with Linux installations there is a tweak later that will turn off memtest86+ on them as well.
    • In the Tweaks section there is an explanation of how to boot into the "Recovery Mode" even without a menu option.
  • Turn Off Recovery Mode
    If you don't want to see the Recovery Mode Options for any item, change the setting in /etc/default/grub. While it may be a good idea to have the "Recovery" mode option displayed, if you don't want it, here is how to get rid of it. You can do this by opening the file as 'root' with any text editor and removing the # symbol from the beginning of the line, or by running the following command.
    Code:
    sudo sed s/'#GRUB_DISABLE_LINUX_RECOVERY="true"'/'GRUB_DISABLE_LINUX_RECOVERY="true"'/g -i /etc/default/grub

Grub 2 Files
The basic configuration settings are made in /etc/default/grub. This thread will not deal with those settings.
The two primary files altered by tweaks in this thread are:
  • /etc/grub.d/10_linux
    • This file contains instructions and scripts which deal with linux kernels on the default system partition.
  • /etc/grub.d/30_os-prober
    • This file contains instructions and scripts to deal with kernels and other operating systems found on other partitions.
    • The file contains four sections. Changes must be made in the correct section, as changes in one section will not effect the scripts in the other sections.
      • The four sections are for Windows, other Linux installations, OSX, and Hurd.


1. /etc/grub.d/10_linux - Changing Ubuntu/Linux Titles (on default partition)

Code:
gksu gedit /etc/grub.d/10_linux
  • Defined Variable Examples: ${OS} Ubuntu, Kubuntu, etc.; ${version} 2.6.31-11, 2.6.31-11-generic, etc.
    Added Variable Example: ${codename} karmic
  • Add new variable codename. This list of variables begins at approximately line 87.
    • Code:
      while [ "x$list" != "x" ] ; do
        linux=`version_find_latest $list`
        echo "Found linux image: $linux" >&2
        basename=`basename $linux`
        dirname=`dirname $linux`
        rel_dirname=`make_system_path_relative_to_its_root $dirname`
        version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
        alt_version=`echo $version | sed -e "s,\.old$,,g"`
        linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
      # User-added variable
        codename="`lsb_release -cs`"
      Original Menu Entry: Ubuntu, Linux 2.6.31-11
      This should be located at approximately line 113.
      Code:
      linux_entry "${OS}, Linux ${version}" \
           "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_EXTRA} ${GRUB_CMDLINE_LINUX_DEFAULT}" \
           quiet
      New Format: Ubuntu 2.6.31-11
      Change the original line above to look like the following by removing ", Linux":
      Code:
      linux_entry "${OS} ${version}" \
           "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_EXTRA} ${GRUB_CMDLINE_LINUX_DEFAULT}" \
           quiet
      New Format: Karmic 2.6.31-11
      Ensure the variable ${codename} has been added into the file's variable list.
      The codename returned in this script will always be the current codename of your present Linux OS (i.e. karmic, jaunty, etc.).
      Change the original line above to look like the following:
      Code:
      linux_entry "${codename} ${version}" \
           "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_EXTRA} ${GRUB_CMDLINE_LINUX_DEFAULT}" \
           quiet
  • Run "sudo update-grub" to update the Grub 2 Menu.

2. /etc/grub.d/30_os-prober - Changing Windows or Other Detected OS Titles (including Linux)
  • This file is divided into sections for various types of operating systems. The first section is for Windows (OS), the second Linux (linux), the third OSX (macosx), and finally Hurd (hurd).

    Code:
    gksu gedit /etc/grub.d/30_os-prober
    A. Changing Windows Entries
    • Changes made via this method are best done to OS or kernels which the user does not expect to change. If the system detects a title change the entry in #3 may no longer be correct.

      Original Menu Entry: Microsoft Windows XP Home Edition (on /dev/sda1)

      1. Run this command to get the current Grub 2 menu entries:
      Code:
      sudo cat /boot/grub/grub.cfg | grep "menuentry" | cut -d '"' -f 2
      New Format: Whatever (on /dev/sda7)
      2. This section appears around line 83 of the file. Replace the section in red with the content in #4.
      Code:
      for OS in ${OSPROBED} ; do
        DEVICE="`echo ${OS} | cut -d ':' -f 1`"
        LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
        LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
        BOOT="`echo ${OS} | cut -d ':' -f 4`"
      
        if [ -z "${LONGNAME}" ] ; then
          LONGNAME="${LABEL}"
        fi
      3. Copy the exact title you wish to change (Example: Microsoft Windows XP Home Edition ) and place it between the quotes in the first line below.
      4. Enter the desired title between the quotes in the second line below - in this example, "Windows XP" would replace "Enter Desired New Title Here".
      Code:
      # Original
      # if [ -z "${LONGNAME}" ] ; then
      #    LONGNAME="${LABEL}"
      # fi
      
        if [ "${LONGNAME}" = "Enter Exact Title You Just Copied" ] ; then
          LONGNAME="Enter Desired New Title Here"
        elif [ -z "${LONGNAME}" ] ; then
          LONGNAME="${LABEL}"
        fi
      5. Multiple entries can be made in the same section:
      Code:
        if [ "${LONGNAME}" = "Enter Exact Title You Just Copied" ] ; then
          LONGNAME="Enter Desired New Title Here"
        elif [ "${LONGNAME}" = "Enter Second Title You  Copied" ] ; then
          LONGNAME="Enter Desired Second Title Here"
        elif [ -z "${LONGNAME}" ] ; then
          LONGNAME="${LABEL}"
        fi

    B. Changing Other Linux Installations
    1. Included in the first codeblock below are all the user-defined variables used in this section of the guide. They apply to the "linux" section of /etc/grub.d/30_os-prober file.
      It is only necessary to insert the ones you wish to use. For simplicity and space-saving, they have all been included in the first codeblock below.
    2. Defined Variables Examples: ${LONGNAME} Microsoft Windows XP Home Edition, Ubuntu 9.04 (9.04); ${DEVICE} sda1, sdb6, etc; ${LLABEL} Ubuntu, linux 2.6.31-11
    3. Find the linux section of the file at approximately line 120 (before other additions).
    4. Add the variables you wish to use from the examples below. Following the added variables are examples of possible returned value:
      ${newtitle} Ubuntu 9.04 ;${shortkernel} 2.6.28-15 ; ${nomemtest} memtest86+ ; ${nosingle} single ; shortdevice (sda5) ; ${hidekernel} 2.6.26
      Code:
          ;;
          linux)
            LINUXPROBED="`linux-boot-prober ${DEVICE} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
      
            for LINUX in ${LINUXPROBED} ; do
              LROOT="`echo ${LINUX} | cut -d ':' -f 1`"
              LBOOT="`echo ${LINUX} | cut -d ':' -f 2`"
              LLABEL="`echo ${LINUX} | cut -d ':' -f 3 | tr '^' ' '`"
              LKERNEL="`echo ${LINUX} | cut -d ':' -f 4`"
              LINITRD="`echo ${LINUX} | cut -d ':' -f 5`"
              LPARAMS="`echo ${LINUX} | cut -d ':' -f 6- | tr '^' ' '`"
      # User-added variables
          newtitle=`echo ${LONGNAME} | cut -d " " -f 1-2`
          shortkernel="`echo ${LKERNEL} | cut -d "-" -f 2-4`"
              shortdevice="`echo ${DEVICE} | cut -d "/" -f 3`"           
              nomemtest="`echo ${LLABEL} | cut -d " " -f 1`"
              nosingle="`echo ${LPARAMS} | sed 's/^.* //'`"
              hidekernel="`echo ${LKERNEL} | cut -d'-' -f2`"
      
      Original Menu Entry: Linux, Ubuntu 9.04 2.6.28-15 (on /dev/sda7)
      Modify the entry in red for each section you want to change (approximately line 135 in original file):
      Code:
              cat << EOF
      menuentry "${LLABEL} (on ${DEVICE})" {
      EOF
      New Format: Ubuntu 9.04 2.6.28-15 (on /dev/sda7)
      Code:
              cat << EOF
      menuentry "${newtitle}  ${shortkernel}  (on ${DEVICE})" {
      EOF
      New Format: Ubuntu 9.04 2.6.28-15
      Code:
              cat << EOF
      menuentry "${newtitle}  ${shortkernel}" {
      EOF

    C. Eliminating or Changing "(on /dev/sdX)"
    • There are specific sections for Windows (OS), Linux (linux), and OSX (macosx). Users must find the section(s) they wish to change or do a universal search/replace.
    • Defined Variables: ${LONGNAME} OS title; ${device} Partition location (e.g. sda1, sdb6, etc)
    • Modify the entry in red for each section you want to change.

      Original Menu Entry: Windows XP Home (on /dev/sda7)
      Approximately line 100.
      Code:
      menuentry "${LONGNAME} (on ${DEVICE})" {
      New Format: Windows XP Home (sda1)
      Code:
      menuentry "${LONGNAME}" (${shortdevice}) {
      New Format: Windows XP Home
      Code:
      menuentry "${LONGNAME}" {
      Original Menu Entry: Linux, Ubuntu 9.04 2.6.28-15 (on /dev/sda7)
      Approximately line 136.
      Code:
      menuentry "${LLABEL} (on ${DEVICE})" {
      New Format: Linux, Ubuntu 9.04 2.6.28-15 (sda7)
      Code:
      menuentry "${LLABEL}" (${shortdevice}) {
      New Format: Linux, Ubuntu 9.04 2.6.28-15
      Code:
      menuentry "${LLABEL}" {

    D. Removing MEMTEST+86 and Single User Entries (from other partitions)
    • Grub 2 provides the ability to hide memtest86+ and recovery mode (single user) entries for the default partition without modifying the 10_linux or 30_os-prober files (see later in this section) . I have not found a similar ability to inhibit the display of these entries found by 30_os-prober on other partitions.
    • Refer to the previous section for information on inserting variables. The two variables associated with hiding the memtest86+ and recovery mode (single-user) are ${nomemtest} and ${nosingle}.
    • The conditional statement below tells Grub to skip an entry if it is either a memtest86+ or recovery mode option. While a bit inelegant, when inserted in 30_os-prober it will effectively prevent the applicable options from appearing in the Grub 2 menu.
    • To remove memtest86+ and recovery mode/single user entries for other partitions found by 30_os-prober:
      • Insert the code in green just after the linux variable definitions and before the first "menuentry" in the linux section (approximately line 130 before any additions).
        Code:
                LINITRD="`echo ${LINUX} | cut -d ':' -f 5`"
                LPARAMS="`echo ${LINUX} | cut -d ':' -f 6- | tr '^' ' '`"
        # User-added variables
            newtitle=`echo ${LONGNAME} | cut -d " " -f 1-2`
            shortkernel="`echo ${LKERNEL} | cut -d "-" -f 2-4`"
                shortdevice="`echo ${DEVICE} | cut -d "/" -f 3`"           
                nomemtest="`echo ${LLABEL} | cut -d " " -f 1`"
                nosingle="`echo ${LPARAMS} | sed 's/^.* //'`"
                hidekernel="`echo ${LKERNEL} | cut -d'-' -f2`"
        
        
                if [ -z "${LLABEL}" ] ; then
                  LLABEL="${LONGNAME}"
                fi
        
                
                if [ "${nomemtest}" = "Memory" ] || [ "${nosingle}" = "single" ]; then
               continue 
            fi
        
                cat << EOF
        menuentry "${LLABEL} (on ${DEVICE}" \
        EOF
      • The entry above hides both recovery mode and memtest86+ entries in one line. If desired, they can be divided into 2 separate sections or used singly by removing the applicable conditional statement and the || characters.
    • To inhibit the display of recovery options on the system partition, uncomment or add this line to /etc/default/grub:
      Quote:
      GRUB_DISABLE_LINUX_RECOVERY=true
    • To inhibit the display of memtest86+ entries from the system partition, make the /etc/grub.d/memtest86+ file non-executable by running this command:
      Code:
      sudo chmod -x /etc/grub.d/20_memtest86+
    • Run "sudo update-grub" to incorporate these changes into the Grub menu.


    E. Removing a Specific Kernel (from other partitions)*
    • This section discusses how to hide a specific kernel while allowing os-prober to search other partitions.
      There are two components necessary for this option:
      • The Variable: hidekernel="`echo ${LKERNEL} | cut -d'-' -f2`"
        • Entered into the linux section of /etc/grub.d/30_os-prober. See previous section for location.
      • The Conditional Statement: if [ ${hidekernel} = "X.X.XX" ]; then
        • X.X.XX or X.X.XX-XX example: 2.6.28 or 2.6.28-12
    • To Hide All Instances of a Kernel (Example: 2.6.26):
      • hidekernel="`echo ${LKERNEL} | cut -d'-' -f2`"
      • if [ ${hidekernel} = "2.6.26" ]; then
    • To Hide a Specific Kernel (Example to hide 2.6.26-11):
      • hidekernel="`echo ${LKERNEL} | cut -d'-' -f2-3`"
      • if [ ${hidekernel} = "2.6.26-11" ]; then

      1. Add the variable to the linux variable list (approximately line 130).
      Code:
              hidekernel="`echo ${LKERNEL} | cut -d'-' -f2`"
      2. Determine the kernel you want to hide (Example: 2.6.26 ) and include it in linux section of /etc/grub.d/30_os-prober, at approximately line 140).
      Code:
              if [ -z "${LLABEL}" ] ; then
                LLABEL="${LONGNAME}"
              fi
      
              
              if [ ${hidekernel} = "2.6.26" ]; then
             continue
          fi
      
              cat << EOF
      menuentry "${LLABEL} (on ${DEVICE}" \
      EOF
    * Note: os-prober can be disabled in various ways to prevent Grub 2 from searching any secondary partitions for bootable operating systems. See Grub 2 Basics for more information.


    F. Removing Windows (Vista) Recovery Partition Entry
    • GRUB 2 will find and create a menuentry for the Windows (Vista) Recovery partition. At least in Vista, the menu name is the same as the normal Vista operating partition, the only difference being the parttion designation. To remove the Recovery partition entry from the menu:
      • Backup the existing /etc/grub.d/30_os-prober file, remove the executable bit from the backup so it isn't run during updates, and open the original for editing (the section starts around line 83):
        • Code:
          sudo cp /etc/grub.d/30_os-prober /etc/grub.d/30_os-prober.original  && sudo chmod -x /etc/grub.d/30_os-prober.original
          gksu gedit +83 /etc/grub.d/30_os-prober &
        • Determine the exact title and the Windows recovery partition. These can be located in the /boot/grub/grub.cfg file. Add the highlighted entry below. In the example, the menuentry appeared as "Windows Vista (loader) (on /dev/sda1)". Make sure you select the correct partition as the title may be the same for the normal and recovery titles. The area in bright red should be the exact contents between the quotes in the menuentry for the recovery partition:
        • Quote:
          for OS in ${OSPROBED} ; do
          DEVICE="`echo ${OS} | cut -d ':' -f 1`"
          LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
          LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
          BOOT="`echo ${OS} | cut -d ':' -f 4`"

          if [ -z "${LONGNAME}" ] ; then
          LONGNAME="${LABEL}"
          fi

          # Added to remove Windows Recovery
          if [ "$LONGNAME" = "Windows Vista (loader)" ] && [ "${DEVICE}" = "/dev/sda1" ] ; then
          continue
          fi
          # End Added
        • Save the file, then run:
          Code:
          sudo update-grub


    G. Troubleshooting
    If the tweaks in this section do not work there are several things to check.
    • Are you working with the correct file? Make sure you are making the changes to the file which deals with the item you are trying to hide. Check the grub.cfg file to see which section the entry is appearing in (10_, 30_, etc).
    • Is the variable producing the correct result? The easiest way to check is to either echo the variable results for viewing while update-grub is running or insert the variable in the grub.cfg file for review.
      • Example: The memtest86+ option keeps appearing in the menu, even though you have inserted "nomemtest="`echo ${LLABEL} | cut -d " " -f 1`" into 30_os-prober.
        • Check that the undesired 'memtest86+' menu item is in the 30_os-prober section of grub.cfg
        • Find out what value 'LLABEL' and 'nomemtest' are returning.
        • Alter the following line:
          Code:
           cat << EOF
          menuentry "${LLABEL} (on ${DEVICE})" {
          to
          Code:
           cat << EOF
          nomemtest=${nomemtest} LLABEL=${LLABEL}
          menuentry "${LLABEL} (on ${DEVICE}" \
          A sample entry would now look like this, showing you the values:
          Code:
          nomemtest=memtest86+ LLABEL=Debian GNU/Linux, kernel memtest86+
          menuentry "Debian GNU/Linux, kernel memtest86+" (sda8) {
          Now for each entry, you will have a line directly above displaying the values of nomemtest and LLABEL just before that menu entry was created. With that knowledge, you should be able to tweak the variable to ensure it returns the correct value for the current situation.

3. CUSTOM MENU TWEAKS!
Naming your /etc/grub.d custom folder 06_custom will place the custom menu entries at the top of GRUB 2's menu. Menu items placed in 40_custom will appear the the bottom.

If you use a numbered filename less than 30 you may want to check the "DEFAULT=" line in /etc/default/grub after running sudo update-grub to ensure the correct menuentry item is identified.

  1. This custom entry is based on ranch hand's post #26. It provides an entry for the latest kernel on the system and will remain current even after a kernel update. UUIDs may be used to identify root if desired.

    Code:
    menuentry "Latest Kernel" {
            set root=(hdX,Y)
            linux /vmlinuz root=/dev/sdXY ro quiet splash
            initrd /initrd.img
    }
4. POST YOUR TWEAKS!

Thread Recommendations
  • Tweaks that only alter the text on the Grub 2 Menu.
  • If possible, on the first line post the existing title and how it will change.
  • Original Menu Entry: Microsoft Windows XP Home Edition on sda1 >> New: XP

    To achieve this on the first line, copy/paste the code from the last line of this post and then alter it.


    [size="3"][b]Original Menu Entry: [color="DarkRed"]Microsoft Windows XP Home Edition on sda1[/color] >> New: [color="DarkGreen"]XP[/color][/b][/size]
    [/size]

Last edited by drs305; 2 Days Ago at 07:38 PM.. Reason: Hide Windows Recovery Partition
drs305 is online now   Reply With Quote
Old October 10th, 2009   #2
bapoumba
GMO Free Ubuntu French Roast.
 
bapoumba's Avatar
 
Join Date: Sep 2006
Location: France.
My beans are hidden!
Ubuntu 9.10 Karmic Koala
Re: Grub 2 Title Tweaks Thread

Moved to karmic
bapoumba is offline   Reply With Quote
Old October 10th, 2009   #3
darco
Dipped in Ubuntu
 
darco's Avatar
 
Join Date: Feb 2006
Location: So.San Francisco
Beans: 589
Re: Grub 2 Title Tweaks Thread

Wow, really nice job.....


darco
__________________
Reason: no beans
darco is offline   Reply With Quote
Old October 10th, 2009   #4
woodbj
Just Give Me the Beans!
 
woodbj's Avatar
 
Join Date: Mar 2009
Location: Australia
Beans: 67
Ubuntu Development Release
Re: Grub 2 Title Tweaks Thread

Heaps good.. Very Helpful Thanks
woodbj is offline   Reply With Quote
Old October 10th, 2009   #5
ranch hand
Chocolate-Covered Ubuntu Beans
 
ranch hand's Avatar
 
Join Date: Aug 2008
Location: South East Montana
Beans: 2,126
Ubuntu 8.04 Hardy Heron
Re: Grub 2 Title Tweaks Thread

I surely have not read it all yet but I am subscribed and then I had to read a little.

Looks really good.
__________________
Dell 480 XPS 3G ram Quad Core 2.40GHz 3x320G HDD, 320G External, [ubuntu] Grub2 introduction
ranch hand is offline   Reply With Quote
Old October 10th, 2009   #6
woodbj
Just Give Me the Beans!
 
woodbj's Avatar
 
Join Date: Mar 2009
Location: Australia
Beans: 67
Ubuntu Development Release
Re: Grub 2 Title Tweaks Thread

Alright so I have changed the name of the entries so they come up as

Code:
Ubuntu karmic Koala
Ubuntu, Linux 2.6.31-13-generic (recovery mode)
Ubuntu karmic Koala
Ubuntu, Linux 2.6.31-12-generic (recovery mode)
Memory test (memtest86+)
Memory test (memtest86+, serial console 115200)
Windows Vista
But i can't remove the recovery mode kernels or the Memory test options..
This is my 30_os-prober
Code:
#! /bin/sh -e

# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009  Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.

prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib

. ${libdir}/grub/grub-mkconfig_lib

found_other_os=

adjust_timeout () {
  if [ "x${found_other_os}" = "x" ] ; then
    if [ "x${GRUB_HIDDEN_TIMEOUT}" != "x" ] ; then
      if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
	verbose=
      else
	verbose=" --verbose"
      fi

      if [ "x${GRUB_HIDDEN_TIMEOUT}" = "x0" ] ; then
	cat <<EOF
if [ \${timeout} != -1 ]; then
  if keystatus; then
    if keystatus --shift; then
      set timeout=-1
    else
      set timeout=0
    fi
  else
    if sleep$verbose --interruptible 3 ; then
      set timeout=0
    fi
  fi
fi
EOF
      else
	cat << EOF
if [ \${timeout} != -1 ]; then
  if sleep$verbose --interruptible ${GRUB_HIDDEN_TIMEOUT} ; then
    set timeout=0
  fi
fi
EOF
      fi
    fi
  fi
}

if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
  adjust_timeout
  exit 0
fi

if [ -z "`which os-prober 2> /dev/null`" -o -z "`which linux-boot-prober 2> /dev/null`" ] ; then
  # missing os-prober and/or linux-boot-prober
  adjust_timeout
  exit 0
fi

OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`"
if [ -z "${OSPROBED}" ] ; then
  # empty os-prober output, nothing doing
  adjust_timeout
  exit 0
fi

for OS in ${OSPROBED} ; do
  DEVICE="`echo ${OS} | cut -d ':' -f 1`"
  LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
  LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
  BOOT="`echo ${OS} | cut -d ':' -f 4`"

  if [ "${LONGNAME}" = "Windows Vista (loader)" ] ; then
    LONGNAME="Windows Vista"
  elif [ -z "${LONGNAME}" ] ; then
    LONGNAME="${LABEL}"
  fi

  echo "Found ${LONGNAME} on ${DEVICE}" >&2
  found_other_os=1

  case ${BOOT} in
    chain)

      cat << EOF
menuentry "${LONGNAME}" {
EOF
      save_default_entry | sed -e "s/^/\t/"
      prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"

      case ${LONGNAME} in
	Windows\ Vista*|Windows\ 7*)
	;;
	*)
	  cat << EOF
	drivemap -s (hd0) \${root}
EOF
	;;
      esac

      cat <<EOF
	chainloader +1
}
EOF
    ;;
    linux)
      LINUXPROBED="`linux-boot-prober ${DEVICE} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"

      for LINUX in ${LINUXPROBED} ; do
        LROOT="`echo ${LINUX} | cut -d ':' -f 1`"
        LBOOT="`echo ${LINUX} | cut -d ':' -f 2`"
        LLABEL="`echo ${LINUX} | cut -d ':' -f 3 | tr '^' ' '`"
        LKERNEL="`echo ${LINUX} | cut -d ':' -f 4`"
        LINITRD="`echo ${LINUX} | cut -d ':' -f 5`"
        LPARAMS="`echo ${LINUX} | cut -d ':' -f 6- | tr '^' ' '`"
# User-added variables          
        nomemtest="`echo ${LLABEL} | cut -d " " -f 1`"
        nosingle="`echo ${LPARAMS} | sed 's/^.* //'`"
        hidekernel="`echo ${LKERNEL} | cut -d'-' -f2`"


        if [ -z "${LLABEL}" ] ; then
          LLABEL="${LONGNAME}"
        fi

        if [ ${nomemtest} = "Memory" ] || [ ${nosingle} = "single" ]; then
	   break 
	fi



        cat << EOF
menuentry "${LLABEL}" {
EOF
	save_default_entry | sed -e "s/^/\t/"
	prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
	cat <<  EOF
	linux ${LKERNEL} ${LPARAMS}
EOF
        if [ -n "${LINITRD}" ] ; then
          cat << EOF
	initrd ${LINITRD}
EOF
        fi
        cat << EOF
}
EOF
      done
    ;;
    macosx)
      OSXUUID="`grub-probe --target=fs_uuid --device ${DEVICE} 2> /dev/null`"
        cat << EOF
menuentry "${LONGNAME}" {
EOF
	save_default_entry | sed -e "s/^/\t/"
	prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
	cat << EOF
        insmod vbe
        do_resume=0
        if [ /var/vm/sleepimage -nt10 / ]; then
           if xnu_resume /var/vm/sleepimage; then
             do_resume=1
           fi
        fi
        if [ \$do_resume == 0 ]; then
           xnu_uuid ${OSXUUID} uuid
           if [ -f /Extra/DSDT.aml ]; then
              acpi -e /Extra/DSDT.aml
           fi
           xnu_kernel /mach_kernel boot-uuid=\${uuid} rd=*uuid
           if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then
              xnu_mkext /System/Library/Extensions.mkext
           else
              xnu_kextdir /System/Library/Extensions
           fi
           if [ -f /Extra/Extensions.mkext ]; then
              xnu_mkext /Extra/Extensions.mkext
           fi
           if [ -d /Extra/Extensions ]; then
              xnu_kextdir /Extra/Extensions
           fi
           if [ -f /Extra/devtree.txt ]; then
              xnu_devtree /Extra/devtree.txt
           fi
           if [ -f /Extra/splash.jpg ]; then
              insmod jpeg
              xnu_splash /Extra/splash.jpg
           fi
           if [ -f /Extra/splash.png ]; then
              insmod png
              xnu_splash /Extra/splash.png
           fi
           if [ -f /Extra/splash.tga ]; then
              insmod tga
              xnu_splash /Extra/splash.tga
           fi
        fi
}
EOF
    ;;
    hurd|*)
      echo "  ${LONGNAME} is not yet supported by grub-mkconfig." >&2
    ;;
  esac
done

adjust_timeout
Would you be able to have a look at it and see if I did something wrong.. thanks
woodbj is offline   Reply With Quote
Old October 11th, 2009   #7
VMC
May the Ubuntu Be With You!
 
VMC's Avatar
 
Join Date: Apr 2008
Location: Southern California, USA
My beans are hidden!
Ubuntu Karmic Koala (testing)
Re: Grub 2 Title Tweaks Thread

Quote:
Originally Posted by woodbj View Post
But i can't remove the recovery mode kernels or the Memory test options..
/etc/grub.d/10_linux:
GRUB_DISABLE_LINUX_RECOVERY=true
also
sudo chmod -x /etc/grub.d/20_memtest86+
__________________
Grub2 | Grub2 Introduction
VMC is offline   Reply With Quote
Old October 11th, 2009   #8
autocrosser
Chocolate-Covered Ubuntu Beans
 
autocrosser's Avatar
 
Join Date: Jun 2005
Location: Pacific NorthWest
Beans: 2,361
Ubuntu Development Release
Re: Grub 2 Title Tweaks Thread

Quote:
Originally Posted by VMC View Post
/etc/grub.d/10_linux:
GRUB_DISABLE_LINUX_RECOVERY=true
also
sudo chmod -x /etc/grub.d/20_memtest86+

Should the GRUB_DISABLE be added in the:
Code:
# User-added variable
  codename="`lsb_release -cs`"
__________________
If one talks quietly & with positive reinforcement--mountains can be moved
Linux User#395230
Ubuntu User# 13498
autocrosser is offline   Reply With Quote
Old October 11th, 2009   #9
drs305
Ubuntu addict and loving it
 
Join Date: Jan 2007
Beans: 6,016
Ubuntu 9.10 Karmic Koala
Re: Grub 2 Title Tweaks Thread

Quote:
Originally Posted by autocrosser View Post
Should the GRUB_DISABLE be added in the:
Code:
# User-added variable
  codename="`lsb_release -cs`"
The line below should be added to /etc/default/grub to hide the recovery options.
Code:
GRUB_DISABLE_LINUX_RECOVERY="true"
You can make the 20_memtest86+ file in etc/grub.d/ non-executable, as was mentioned. This will inhibit the display of the installed parittion's memtest86+ option.

It doesn't appear that there is yet a similar entry available in this file to inhibit the display of memtest86+ for other partitions, which is the reason the tweak was added in this guide.

I'll edit the first post in emphasize how to disable memtest86+ and recovery displays in the main partition.

Last edited by drs305; October 11th, 2009 at 08:30 AM..
drs305 is online now   Reply With Quote
Old October 11th, 2009   #10
woodbj
Just Give Me the Beans!
 
woodbj's Avatar
 
Join Date: Mar 2009
Location: Australia
Beans: 67
Ubuntu Development Release
Re: Grub 2 Title Tweaks Thread

Thanks Worked like a charm
I uncommented GRUB_DISABLE_LINUX_RECOVERY="true" in /etc/default/grub but that only got rid of the recovery kernels so I also did sudo chmod -x /etc/grub.d/20_memtest86+ and that got rid of the Memtest's.. Thanks again
woodbj is offline   Reply With Quote

Bookmarks

Tags
grub 2, grub2, title, tweaks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:47 AM.


vBulletin ©2000 - 2009, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. bilberry