Page 1 of 6 123 ... LastLast
Results 1 to 10 of 53

Thread: Grub 2 - 5 Common Tasks

  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.

  2. #2
    Join Date
    Mar 2008
    Beans
    115

    Re: Grub 2 - 5 Common Tasks

    Quote Originally Posted by drs305 View Post
    1. Download the GRUB 2 splash image package:
    Code:

    sudo apt-get install grub2-splashimages

    2. Open this file for editing:
    3. Determine the image you wish to use.

    Possibly something is missing at the end of 2nd step...


    Anyway: thank U again for GRUB 2 informations, now it is the time to learn GRUB 2! Congratulation!
    Last edited by sh4d0w808; October 29th, 2009 at 03:20 PM. Reason: Alzheimer
    Being a target means being on the internet. End of line.
    Takedown blog (hungarian)

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

    Re: Grub 2 - 5 Common Tasks

    Quote Originally Posted by sh4d0w808 View Post
    Possibly something is missing at the end of 2nd step...
    Yes indeed. Lost in the ether of the Internet at some point. Rather than wait to see if it ever returns, I have retyped the missing filename. Thanks.
    Back to Xorg...

    Retired.

  4. #4
    Join Date
    Aug 2008
    Location
    South East Montana
    Beans
    6,153

    Re: Grub 2 - 5 Common Tasks

    I have updated my link to Grub2 Basics and added this thread to my links on my Introduction that I posted in the ABT forum.
    Dell 480 XPS 3G ram Quad Core 2.40GHz, Radeon HD 2400 PRO, Audigy1, 3x320G HDD, 320G External, Debian Testing for use, Debian Squeeze for secure use, Debian Sid for FUN

  5. #5
    Join Date
    Nov 2008
    Beans
    42
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Grub 2 - 5 Common Tasks

    Very well written...!! thanks a lot..

    One more point that can be added:

    In the file "05_debian_themeand as 06_custom_theme", we must look at the line which reads "use_bg=false"

    use_bg=false
    if [ "$GRUB_TERMINAL_OUTPUT" = "gfxterm" ] ; then
    for i in {/boot/grub,/usr/share/images/desktop-base}/picture.{jpg,png,tga}
    You have to set the variable "use_bg=false" to true. i.e. use_bg=true

    Then set the path and name of your desired GRUB background image.


    I hope it helps..

    ----------------------------

    One doubt I have:

    Some people say that to change screen resolution of grub2, edit /etc/grub.d/00_header, search for “set gfxmode=640x480” and change it as you like.

    But, you like to edit /etc/default/grub # GRUB_GFXMODE=640x480

    which one to prefer?
    Last edited by 600WPMPO; November 5th, 2009 at 06:26 AM.

  6. #6
    Join Date
    Aug 2008
    Location
    South East Montana
    Beans
    6,153

    Re: Grub 2 - 5 Common Tasks

    For me, that change seems to stop the whole process. Just goes to the default black background.
    Dell 480 XPS 3G ram Quad Core 2.40GHz, Radeon HD 2400 PRO, Audigy1, 3x320G HDD, 320G External, Debian Testing for use, Debian Squeeze for secure use, Debian Sid for FUN

  7. #7
    Join Date
    Jun 2005
    Location
    UK
    Beans
    5
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Grub 2 - 5 Common Tasks

    Quote Originally Posted by 600WPMPO View Post
    You have to set the variable "use_bg=false" to true. i.e. use_bg=true
    Then set the path and name of your desired GRUB background image.
    Don't do that; if you look at the script, you'll see that it sets "use_bg" to true itself, if the image is OK and there is a valid Grub module to read the file.

    One doubt I have:

    Some people say that to change screen resolution of grub2, edit /etc/grub.d/00_header, search for “set gfxmode=640x480” and change it as you like.

    But, you like to edit /etc/default/grub # GRUB_GFXMODE=640x480

    which one to prefer?
    Definitely change the setting in /etc/default/grub, not in /etc/grub.d/00_header. Again, if you look at 00_header, it just uses the value that you define in /etc/grub/default:

    Code:
    if loadfont `make_system_path_relative_to_its_root ${GRUB_FONT_PATH}` ; then
      set gfxmode=${GRUB_GFXMODE}
      ...

  8. #8
    Join Date
    Nov 2008
    Beans
    42
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Grub 2 - 5 Common Tasks

    Quote Originally Posted by 600WPMPO View Post
    One more point that can be added:

    In the file "05_debian_themeand as 06_custom_theme", we must look at the line which reads "use_bg=false"


    You have to set the variable "use_bg=false" to true. i.e. use_bg=true
    Ok, please do not use this option as it is not working. I was wrong in suggesting it. This even gave me an error when doing "sudo update grub".
    More info is from drs305:

    Looking at the script, it appears that the "bg" value in line 14 (false) is reset to the background image value several lines later if the image exists and you are using GFXTERM. Since most users would be using gfxterm making this value "true" would bypass the subsequent section which designates where the bg image resides.
    I apologise for any errors caused by this post.

    -----------------------------------------------------

    2 difficulties I'm facing:

    However, I have not yet succeeded in making my Grub2 display a background image.

    When I follow all the steps as mentioned under "5. Add a Splash Image", it does not give the "Found Debian image xxxxxxx" among the terminal outputs.The resulting Grub background is black.

    Secondly, when I change the Grub resolution, it works fine, but after the boot selection menu, an error message blinks for a second which says something like "vga=792 is deprecated use set gfxpayload=1024x768x24;1024x768 before the linux command"


    How do I correct this?
    Please help gentlemen...

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

    Re: Grub 2 - 5 Common Tasks

    Quote Originally Posted by 600WPMPO View Post
    However, I have not yet succeeded in making my Grub2 display a background image.

    When I follow all the steps as mentioned under "5. Add a Splash Image", it does not give the "Found Debian image xxxxxxx" among the terminal outputs.The resulting Grub background is black.

    Secondly, when I change the Grub resolution, it works fine, but after the boot selection menu, an error message blinks for a second which says something like "vga=792 is deprecated use set gfxpayload=1024x768x24;1024x768 before the linux command"
    The common problems I foresee if you are trying to use the grub2-splashimages is that they are not downloaded to the same folder looked at by G2 by default. If you aren't using the default G2 splash images, make sure the line in 05_debian_theme points to the correct location. Also make sure you have the "." following the graphic filename in the "for i ..." line.

    If you cannot figure it out, post the 05_debian_theme line "for i" concerning splashimages (approximately line 15.


    2. The vga message is because you probably have a "vga=XXX" in your /etc/default/grub settings. For setting the G2 menu resolution (only), use the GFXMODE lines. For setting the system resolution, apparently the vga= method isn't the preferred method any longer as these settings are made by the system as it boots.
    Back to Xorg...

    Retired.

  10. #10
    Join Date
    Nov 2008
    Beans
    42
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Grub 2 - 5 Common Tasks

    Quote Originally Posted by drs305 View Post
    The common problems I foresee if you are trying to use the grub2-splashimages is that they are not downloaded to the same folder looked at by G2 by default. If you aren't using the default G2 splash images, make sure the line in 05_debian_theme points to the correct location. Also make sure you have the "." following the graphic filename in the "for i ..." line.

    If you cannot figure it out, post the 05_debian_theme line "for i" concerning splashimages (approximately line 15.
    Yes, I had checked it and made sure the files are in that folder only

    I downloaded the splashimages from the Ubuntu repositories by

    sudo apt-get install grub2-splashimages

    This installed the splash image package at:

    /usr/share/images/grub/

    Since the code was:
    Code:
    for i in {/boot/grub,/usr/share/images/desktop-base,/usr/share/images/grub}/xxxxxxxx.{png,tga}
    i copied the images to /usr/share/images/desktop-base

    but this didn't help...


    Quote Originally Posted by drs305 View Post
    The vga message is because you probably have a "vga=XXX" in your /etc/default/grub settings. For setting the G2 menu resolution (only), use the GFXMODE lines. For setting the system resolution, apparently the vga= method isn't the preferred method any longer as these settings are made by the system as it boots.
    Ok, so now how do I correct this? Should I put a # before the "vga=XXX" in your /etc/default/grub file ? Will that work ?

Page 1 of 6 123 ... LastLast

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
  •