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

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,630
Ubuntu Development Release
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. Before you get too deep into editing these scripts, remember you can also simply create a custom menu in which you can use your own titles, include or omit boot options, etc. See meierfra's page for creating a custom menu.

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.

Tweaks This Guide Covers
  • Remove MEMTEST86+
  • Remove Recovery Mode
  • Change Main Partition Linux/Ubuntu Titles
  • Limit Main Partition Linux Entries to Only the Two Latest
  • Changing Windows/Other OS Titles
  • Hiding Specific Kernels
  • Hiding the Windows Recovery Partition
  • Hiding Other Partitions
  • Changing Menu Entry Order
  • Custom Tweaks Provided by Others in This Thread

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.

Remove Older Kernels
If you are just seeing too many versions of the Linux kernel (including the associated recovery option), you can reduce the number by physically removing them from your machine. While it's best to keep at least one older kernel as a backup, others can be removed via Synaptic. Search for "linux-image" and select the lower-numbered kernels you no longer use. An example would be "linux-image-2.6.31-9-generic". You could also remove the "linux-header...." for the same kernel number. Once they are removed, run "sudo udpate-grub" and your menu will be less cluttered.


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/Limiting Ubuntu/Linux Titles (on default partition)
  • A. Changing Linux Titles on Main 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.
    • Note: If you want to capitalize the codename (Hardy, Jaunty, Karmic) see post #38.
  • B. Limiting Main Kernels to Only Two
    When a new kernel is introduced, it is automatically entered into the Grub 2 menu. Over time, the number of kernels listed may become quite long. The number of the current system kernels displayed can be changed via script editing (the kernels remain on the system but not displayed) or physically removing the kernels from the system via APT (command line, Synaptic, etc).


    To limit the number of kernels (including their associated Recovery modes if enabled) to only two, you can simply add a line to /etc/grub.d/10_linux

    Find this section of /etc/grub.d/10_linux:
    Quote:
    if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then
    linux_entry "${OS}, Linux ${version} (recovery mode)" \
    "single ${GRUB_CMDLINE_LINUX}"
    fi

    list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
    done
    and add the highlighted line prior to the last line ("done"), save the file and then update-grub.
    Quote:
    if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then
    linux_entry "${OS}, Linux ${version} (recovery mode)" \
    "single ${GRUB_CMDLINE_LINUX}"
    fi

    list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
    list=`version_find_latest $list`
    done

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. Hiding 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) .
    • kansasnoob has discovered that the memtest86+ entries generated from partitions containing a Grub legacy menu.lst file can be disabled by opening the associated /boot/grub/menu.lst file, finding the memtest86+ entry, and changing it to read:
      Quote:
      # memtest86=false
    • 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. Hiding a Specific Kernel (All Examples use 2.6.26... Substitute the kernel you desire to replace)
    • There are two components necessary for this option:
      • The Variable, entered into either /etc/grub.d/10_os-prober, or the linux section of /etc/grub.d/30_os-prober. For the location of the variables, see Section 1 for main kernel variables or Section 2B for linux variables on other partitions.
      • The Conditional Statement: if [ ${hidekernel} = "X.X.XX" or "X.X.XX-X" or "X.X.XX-X-generic" ]; then # Use the appropriate kernel format.
      • X.X.XX or X.X.XX-XX example: 2.6.28 or 2.6.28-12
    • The dark green items are lines to be inserted into the script. The red items are those which must be tailored by the user. The dark blue items are variables to be inserted in the appropriate area of the script.

    • To Hide a Kernel on the main partition & listed in the 10_linux section of /boot/grub/grub.cfg:
      • The Variable is pre-defined - no additional user entry is required: ${version}"
      • The Conditional Statement: if [ ${version} != "X.X.XX" ]; then
        • X.X.XX or X.X.XX-XX or X.X.XX-X-generic : 2.6.28 or 2.6.28-12 or 2.6.28-12-generic
        • Note the "!=" translates to "Run this unless the entry is equal to the following".
      1. Determine the kernel you want to hide (Example: 2.6.26 ) and change the code below in /etc/grub.d/10_linux at approximately line 118.
      Code:
      if [ ${version} != "2.6.31-14-generic" ]; then
        linux_entry "${OS}, Linux ${version}" \
            "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_EXTRA} ${GRUB_CMDLINE_LINUX_DEFAULT}" \
            quiet
        if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then
          linux_entry "${OS}, Linux ${version} (recovery mode)" \
          "single ${GRUB_CMDLINE_LINUX}"
        fi
      fi
  • To Hide All Instances of a Kernel on Another Partition (Listed in the 30_os-prober section of /boot/grub/grub.cfg :
    • hidekernel="`echo ${LKERNEL} | cut -d'-' -f2`"
    • if [ ${hidekernel} = "2.6.26" ]; then
  • To Hide a Specific Kernel on Another Partition (Listed in the 30_os-prober section of /boot/grub/grub.cfg :
    • 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.

3. Hiding 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

4. Hiding A Partition
You can hide any partition other than the system partition by editing /etc/grub.d/30_os-prober.
  • To hide a partition with linux kernels, insert the additional lines, substituting the correct drive/partition designations (sda3, sdb5, etc):
    • if [ -z "${LLABEL}" ] ; then
      LLABEL="${LONGNAME}"
      fi
      if [ "${LROOT}" = "/dev/sdXY" ]; then
      continue
      fi

  • To hide a Windows partition, insert the additional lines, substituting the correct drive/partition designations (sda3, sdb5, etc):
    • if [ -z "${LONGNAME}" ] ; then
      LONGNAME="${LABEL}"
      fi
      if [ "${DEVICE}" = "/dev/sdXY" ]; then
      continue
      fi



5. Changing Menu Entry Order

Two simple ways to change the basic order of entries appearing in the Grub 2 menu:
  • Create a custom menu. /etc/grub.d/40_custom menus will appear at the bottom of the menu. Rename the file 06_custom and the menu entries will appear at the top of the menu.
  • Rename one (or more) of the existing /etc/grub.d scripts. The scripts are run in order. So if you want the "Other OS" entries found by 30_os-prober to be run first (and placed first in the menu), simply rename 30_os-prober to 06_os-prober, 07_os-prober, etc or rename 10_linux to 99_linux, etc.


6. 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})" {ile allowing os-prob
        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.

7. 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
    }
8. 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 08:57 PM.. Reason: Order menu entries added.
drs305 is offline   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
Has an Ubuntu Drip
 
darco's Avatar
 
Join Date: Feb 2006
Location: So.San Francisco
Beans: 713
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: 78
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
Skinny Extra Sweet Ubuntu
 
ranch hand's Avatar
 
Join Date: Aug 2008
Location: South East Montana
Beans: 3,204
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, Radeon HD 2400 PRO, Audigy1, 3x320G HDD, 320G External, [ubuntu] Grub2 introduction
ranch hand is online now   Reply With Quote
Old October 10th, 2009   #6
woodbj
Just Give Me the Beans!
 
woodbj's Avatar
 
Join Date: Mar 2009
Location: Australia
Beans: 78
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

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 01:16 AM.


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