Results 1 to 10 of 53

Thread: Grub 2 - 5 Common Tasks

Threaded View

  1. #1
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Grub 2 - 5 Common Tasks

    GRUB 2 - 5 Common Tasks


    This is a simple guide for handling some of the most common tasks a user might wish to perform. For detailed information on Grub 2, refer to the Ubuntu community documentation at https://help.ubuntu.com/community/Grub2 or post comments/questions on the sister page on this forum at Grub 2 Basics

    Grub Customizer:
    For those who would prefer a GUI app, I highly recommend Grub Customizer. It can accomplish all the tasks detailed in this guide. Here is the link to a post with installation instructions and how to use it.
    HOWTO: Grub Customizer


    1. Unhide/Hide the Menu
    2. Menu Default Entry
    3. Menu Resolution
    4. Timeout
    5. Add a Splash Image


    Note: Line to edit (XX) - XX is the approximate line number.


    1. Unhide/Hide the Menu
      File: /etc/default/grub
      Line to edit (5):
      GRUB_HIDDEN_TIMEOUT=0
      Example to unhide the menu: # GRUB_HIDDEN_TIMEOUT=0 and DEFAULT_TIMEOUT=X

      By default, if no other operating system is found on the system, GRUB 2 will not display the menu. The system will boot directly into the default entry.

      To display the menu:
      • Place a comment symbol (#) at the start of the "GRUB_HIDDEN_TIMEOUT=X" line.
      • Make sure the "DEFAULT_TIMEOUT=X" entry is a positive integer. X is the number of seconds the menu will be displayed.
        # GRUB_HIDDEN_TIMEOUT=0
        GRUB_HIDDEN_TIMEOUT_QUIET=true
        GRUB_TIMEOUT="10"


      Code:
      gksu gedit /etc/default/grub
      Save the file, then update the menu:
      Code:
      sudo update-grub
      To hide the menu on boot:
      There should be no # symbol at the start of the line: GRUB_HIDDEN_TIMEOUT=0 line. "0" in both entries (GRUB_TIMEOUT & GRUB_HIDDEN_TIMEOUT) above should boot the system without a timeout. A positive integer will leave a blank screen for that number of seconds, allowing the user time to press "ESC" or "SHIFT" to display the menu. The splash screen will still display during the timeout.

    2. Menu Default Entry
      File: /etc/default/grub
      Line to edit (4):
      GRUB_DEFAULT=0
      Example: GRUB_DEFAULT=1 # (The second "menuentry" item).

      Natty / Grub 1.99 Note:
      If you want to use an entry in a submenu, the way to designate the number in the DEFAULT_GRUB line is different. Please refer to this thread about Grub 1.99 submenu's for instructions:
      http://ubuntuforums.org/showthread.p...6#post10720316


      There are several ways to update the default selection in GRUB 2. Below are choices for using a simple GUI app to make the change for you, a manual way via editing the GRUB 2 files. Another method, using the command "grub-set-default" does not appear to work in GRUB 2 with Ubuntu at this time.

      1. Boot Repair: Boot Repair is an excellent utility designed to fix booting problems. It can also run the boot info script, which is invaluable in providing helpers with information needed to provide targeted assistance. For purposes of the this section though, Boot Repair can easily set the default boot option under the "Advanced" > "Grub Location" options. Boot Repair is my recommendation for setting the default OS. Visit the Boot Repair site at:
        [Boot-Repair] Graphical tool to repair the PC boot in 1 click!

      2. Grub Customizer: Grub Customizer is a GUI app designed for Grub 2. It is a great tool for accomplishing most of the tasks found on this page. Here is a link on how to install and use Grub Customizer:
        Grub Customizer

      3. StartUp-Manager: For those who prefer a GUI app to change the default selection.
        If you want a simple, GUI-based app that can change the default entry, you can install and run StartUp-Manager. This app was written for Grub legacy but still works for this option in Grub 2. Click on the "SUM" link in my signature line for instructions on how to install and an explanation of the various settings you can change with StartUp-Manager.

      4. "sudo grub-set-default"
        If the /etc/default/grub "GRUB_DEFAULT=" setting is set to "saved", you can change the default setting at any time by running:
        Code:
        sudo grub-set-default X
        with X being either the menuentry position (the first menuentry is 0), or with the exact menu string from the menuentry. For more details, refer to Grub 2 Basics.
        Examples: sudo grub-set-default 3 or sudo grub-set-default "Ubuntu, Linux 2.6.31-14-generic"

      5. Edit the Files: Get to Know GRUB 2

        If you prefer to change the GRUB 2 files manually:

        You can see the current "menuentry" items listed in the /boot/grub/grub.cfg by running this command:
        Code:
        grep "menuentry" /boot/grub/grub.cfg
        Counting starts with zero (0). The first "menuentry" item is "0", the second is "1", etc. The third visible "menuentry" would be 2.

        Determine the number you wish to make the default, and enter it in /etc/default/grub. Make the change and save the file.
        Code:
        gksu gedit /etc/default/grub
        The user can also select "saved" as an option, which will use the last successfully booted kernel/OS as the default selection.
        Examples:
        • GRUB_DEFAULT=0
          GRUB_DEFAULT="Microsoft Windows XP Home Edition"
          GRUB_DEFAULT="saved"

        If using the exact title, use the title exactly as it appears in the menuentry for that item in /boot/grub/grub.cfg
        GRUB_DEFAULT=1
        Save the file, then update the menu:
        Code:
        sudo update-grub


    3. Menu Resolution
      File: /etc/default/grub
      Line to edit (18):
      # GRUB_GFXMODE=640x480
      Example: GRUB_GFXMODE=1280x1024

      Change the value to the resolution you wish to use for the Grub 2 menu display. This setting effects only the Grub menu resolution. Run "update-grub" after saving the file to update the menu.

      Make sure the resolution is supported before the operating system is loaded, especially if you intend to use a non-standard resolution.
      If you are not sure of the resolutions available from your monitor during the initial boot: From the Grub menu, type "c" to enter the Command Line mode, then type "vbeinfo". This will list the resolutions available to Grub 2 during boot. Not all resolutions available after your system boots may be available to GRUB 2.

      Add the new line.
      Leave this line alone for reference: #GRUB_GFXMODE=640x480
      Code:
      gksu gedit /etc/default/grub
      Save the file, then update the menu:
      Code:
      sudo update-grub
    4. Timeout
      File: /etc/default/grub
      Line to edit (7):
      GRUB_TIMEOUT=10
      Example: GRUB_TIMEOUT=3

      Change the value to the number of seconds you wish the menu to be displayed.
      Code:
      gksu gedit /etc/default/grub
      Save the file, then update the menu:
      Code:
      sudo update-grub
      • If you want to see the menu, make sure the "GRUB_HIDDEN_TIMEOUT" line begins with a comment (#) symbol. (# GRUB_HIDDEN_TIMEOUT=)


      Command Line Bonus:
      If you want to change it very quickly and are a trusting sort, just run the following command to replace the timeout value and run update-grub. Change the value in dark red to the timeout value you desire. The command below changes the timeout to 5 seconds.
      Code:
      sudo sed "s/GRUB_TIMEOUT=[0-9]*/GRUB_TIMEOUT=5/g" -i /etc/default/grub && sudo update-grub
    5. Add a Splash Image
      File: /etc/grub.d/05_debian_theme
      Grub 1.97~beta (Karmic) and Grub 1.98 (Lucid and later) use different instructions to set the background image.

      Image Information:
      • May be a tga, png or 8-bit jpeg image.
      • Must be RGB. Indexed color foramtting is not allowed.
      • It helps if the image is the same size as the resolution you are setting.
      • The "console" mode must be disabled in /etc/default/grub (default setting).
      • You can see the resolutions available to Grub 2 from the Grub menu during boot. Press "c" and at the grub prompt type vbeinfo



      Grub 1.98 (Lucid)
      Line to edit (10):
      WALLPAPER="/usr/share/images/desktop-base/moreblue-orbit-grub.png"
      Example: WALLPAPER="/home/drs305/my-images/really-great-background.png"



      Grub 1.97~beta (Karmic)
      Line to edit (16):
      for i in {/boot/grub,/usr/share/images/desktop-base}/moreblue-orbit-grub.{png,tga} ; do
      Example: for i in {/boot/grub,/usr/share/images/desktop-base,/usr/share/images/grub}Moraine_Lake_17092005.{png,tga} ; do

      Note that the filename ends with a period, before the brackets for the extension.


      Ubuntu's repositories provide a standard selection of Grub backgrounds. To add a standard Grub 2 splash image:
      1. Download the GRUB 2 splash image package:
        Code:
        sudo apt-get install grub2-splashimages
      2. Determine the image you wish to use. The grub2-splashimages are downloaded to /usr/share/images/grub
      3. Open the /etc/grub.d/05_debian_theme file for editing:
        Code:
        gksu gedit /etc/grub.d/05_debian_theme
      4. Edit the file as described previously, using the instructions for the version of Grub 2 you are using.



      Save the file, then update the menu *:
      Code:
      sudo update-grub
      * While the file is running, if the splash image was successfully imported you will see "Found Debian image <image-name>" among the terminal outputs.

      Other splash images or locations can be used. Refer to the community documentation for more information.


    LINKS:
    Here is a collection of scripts which automate many Grub 2 tasks, courtesty of Herman:
    Herman's Grub 2 Scripts Useful scripts for many Grub 2 tasks.
    Last edited by drs305; July 5th, 2012 at 12:14 AM. Reason: Boot Repair for setting Default OS
    Back to Xorg...

    Retired.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •