Page 1 of 16 12311 ... LastLast
Results 1 to 10 of 156

Thread: How to: Create a Customized GRUB2 Screen that is Maintenance Free.

  1. #1
    Join Date
    Aug 2009
    Beans
    Hidden!
    Distro
    Xubuntu

    How to: Create a Customized GRUB2 Screen that is Maintenance Free.

    The information from this thread can be found here

    https://help.ubuntu.com/community/Ma...tomGrub2Screen



    Added *Notes for Ubuntu versions that use Grub2 version 1.99 which started at Natty 11.04 and maybe even late Maverick 10.10.
    Enter grub-install -v in terminal and if it says 1.99 pay attention to any line that starts out with Notes as the changes are critical to this working.
    Thanks to Ranch Hand for his help and valuable knowledge.
    Thanks to Riskable for finding a way to make the font larger.
    Thanks to Drs305 for his invaluable help with Grub.

    I recently installed Ubuntu 12.04 into a separate partition.
    So, since I wanted Ubuntu 10.04 to be my main OS, I booted into Lucid and entered in terminal sudo grub-install /dev/sda which is where Lucid is.
    Then I simply had to replicate the custom entries in /etc/grub.d/06_custom and change the menu text, (hd0,3) to (hd0,5) and sda3 to sda5.

    This can be adapted for any version of Ubuntu that uses GRUB2.
    Note: I have not added any quotes around the commands as there may be quotes in the commands themselves.
    I have just made the commands bold and avoided placing periods after the commands also. Do not modify or add any lines except these mentioned.

    This will setup a customized GRUB2 menu with a background picture for just Ubuntu or Dual Booting Ubuntu and Windows that is totally maintenance free.
    The only time you may have to modify something is when GRUB files are updated via system update.

    1) To change the default line number, timeout and the resolution of the GRUB2 screen,bring up a terminal and enter this gksu gedit /etc/default/grub
    GRUB_DEFAULT=4 means to default on the 5th line from the top. (0 is first). If you only have Ubuntu, set this to 0.
    If you dual boot and want Ubuntu as your default set this to 0, if you want Windows as default set it to 2.
    I tri-boot so, I have the default set to windows 7 so I set this to 4. If you tri-boot and want your 2nd 'buntu as default, set this to 2.
    GRUB_TIMEOUT=60 means Grub2 screen displays for 60 seconds before defaulting. You can set this to whatever you want.
    GRUB_GFXMODE=1920x1200-24 means screen resolution is 1920x1200 and 24 is the color bit depth. The -24 on the end is not absolutely required.
    *Specifying the bit depth of 24 is a high quality picture.

    The resolution and bit depth is dependent on your video card/driver.
    If the last line is incorrect, you will have a black and white or blue grub screen.
    (Note: Do not make the GRUB_GFXMODE to a higher resolution than your monitor's native resolution.)
    Resolutions available to GRUB 2 can be displayed by typing vbeinfo in the GRUB 2 command line.
    The command line is accessed by typing "c" when the main GRUB2 menu screen is displayed.
    Make sure there is no # to the left of these 3 commands.
    Also make sure there is a # beside this #GRUB_HIDDEN_TIMEOUT=0

    *Note if you are using Grub2 version 1.99, all you need to change in 05_debian_theme is the colors as shown in step 2 and that is all.
    The custom wallpaper must be edited with Gimp (see the green note below).
    Then you need to move 1 and only 1 picture to /boot/grub/ e.g. sudo cp rain.jpg to /boot/grub/ and enter sudo update-grub.
    If you change the picture be sure and remove the previous one because it looks for the first one it finds.

    2) To add a custom wallpaper background for your GRUB2 menu, you will need to move at least one picture that is the exact dimensions as your GRUB_GFXMODE says to this location:
    /usr/share/images/desktop-base/ This is the directory to store your pictures in and you will have to open that directory as root to be able to put them there.
    If you do not have Ubuntu Tweak installed, it can be found in the Ubuntu Software Center (Applications > Ubuntu Software Center).
    You can open Ubuntu Tweak (Applications > System Tools > Ubuntu Tweak. Then click on Nautilus Settings and put a check mark beside Open Folder with root privileges.
    This will enable you to right click on the directory /desktop-base/ and click on Open as Administrator. Then you can copy and paste your pictures into that directory.
    When you have moved your picture (mine is called “rain.tga”), you should right click on it and go down to the properties tab and put a check mark next to Execute (Allow executing file as a program).
    If you do not make the picture executable, it may not be displayed upon boot. Recently it doesn't seem to matter but, I still make it executable.

    Note: If you have a high quality picture, the picture may need to be edited with Gimp. If it is listed when you enter sudo update grub but, does not appear at boot time.
    Edit the picture with Gimp and click on Image and then Scale Image and verify that the picture is the correct size.
    Then if Quality interpolation says "cubic" change it to "linear".
    Then click "scale" at the bottom right. Then click File and Save and a little box will open. Move the quality slider to 100% and then click on Advanced options.
    Change the Subsampling to "Best Quality" and then click save and it goes though a conversion process.


    This has always made the picture work and it should list your picture when you enter sudo update-grub.

    And then you will need to edit this file with this command gksu gedit /etc/grub.d/05_debian_theme
    Any time you wish to change the picture you will have to edit this file and place the
    name of it here:
    For grub version 1.98 prior to Natty only:
    WALLPAPER="/usr/share/images/desktop-base/rain.tga" They can be png, tga, jpg or jpeg.
    You will add this after the first else at the top of the file if there is not one already there and make sure there is no # to the left of it.
    Then the colors are right after the above line. Here are my current colors:
    This is for grub version 1.98 prior to Natty:
    Code:
    COLOR_NORMAL="light-cyan/black"  
    COLOR_HIGHLIGHT="white/black"

    This is for grub version 1.99 Natty through Precise:
    At line 98 of 05_debian_theme where you see the 1st line add the two lines after that and save the file:
    Code:
    echo "if background_image `make_system_path_relative_to_its_root "${1}"`; then"
    echo " set color_normal=light-cyan/black"
    echo " set color_highlight=white/black"
    if [ -n "${2}" ]; then
    These colors work on my dark background, but they are up to you.
    Just make sure you do not change the 2nd color of black to anything else as this will cause the line to be transparent.
    You can see what colors are available here. Just scroll down several pages.

    Always enter sudo update-grub or sudo update-grub2 after changing a file.


    3) To make your GRUB2 screen maintenance free bring up a terminal and enter sudo grub-mkconfig.This will Generate a grub config file that tells where everything is coming from.
    Then copy this output and paste it into a gedit (or any text file) and save it for future reference.

    Each of the grub files involved will be displayed with a beginning and end line that looks like this:

    ### BEGIN /etc/grub.d/00_header ###

    ### END /etc/grub.d/00_header ###

    If you just have Ubuntu or are dual booting, open up this file for editing with this command: gksu gedit /etc/grub.d/40_custom

    You will see this:

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

    Make sure you enter all of the following custom entries below the last line in the file.

    *Note if you are using Grub2 version 1.99, you will need to change the line above to this: exec tail -n +4 $0

    The following hard drive and partition that is needed for the Ubuntu entries will be contained between the lines that mention
    ### BEGIN /etc/grub.d/10_linux ### and ### END /etc/grub.d/10_linux ###
    in the output of the sudo grub-mkconfig command above, which should be saved. Simply copy the lines below and change the red to suit your needs.
    Or you can use the command sudo blkid to determine what to put as sdax below (where x is a,b,c, etc.).
    If you are dual windows, this command will also provide the UUID (in the red characters after --set below in the windows 7 entry). It will be the first line that has TYPE="ntfs" beside of it.

    There will be 8 lines for each line for Ubuntu and 9 lines for each Windows entry you wish your GRUB2 to display (starting with echo and ending with EOF).

    Keep in mind what is displayed on the echo and menuentry lines can be whatever you want them to be.
    But, everything else must be exactly as below once you have changed the red part to match your system.

    However, what is between the quotes should be changed to suit your flavour of Ubuntu (2 lines per entry).
    And whatever you put between the quotes is totally up to you as you will be the only one seeing it.


    *Note if you are are using Grub2 version 1.99, you will want to use the following with the echo command only at the top:

    Code:
    echo "Adding Ubuntu Lucid Lynx 10.04, Precise Pangolin 12.04 and Windows 7" >&2 
    menuentry "Lycid Lynx 10.04" {
        set root=(hd0,3)
            linux /vmlinuz root=/dev/sda3 ro quiet splash
            initrd /initrd.img
    }
    (Delete the cat << EOF line and the EOF lines)

    *Note
    instead of this:

    Code:
    echo "Ubuntu Lucid Lynx 10.04" >&2 
    cat << EOF
    menuentry "Ubuntu Lucid Lynx 10.04" {
        set root=(hd0,3)
            linux /vmlinuz root=/dev/sda3 ro quiet splash
            initrd /initrd.img
    }
    EOF
    My Ubuntu Lucid Lynx is on disk 0 partition 3 (hd0,3). And sda3 is partition 3 of hard drive 0.
    Just change what you see in red above to match wherever yours is and make sure and not change anything else.

    Then if you want a recovery mode as a 2nd line, enter this just after the EOF above:
    What goes where the red is will be exactly as above.

    *Note if you are are using Grub2 version 1.99, your 2nd entry will look like this:

    Code:
    menuentry "Lycid Lynx 10.04 (Recovery Mode)" {
        set root=(hd0,3)
            linux /vmlinuz root=/dev/sda3 ro single
            initrd /initrd.img
    }
    *Note instead of this:

    Code:
    echo "Ubuntu Lucid Lynx 10.04 (Recovery Mode)" >&2 
    cat << EOF
    menuentry "Ubuntu Lucid Lynx 10.04 (Recovery Mode)" {
        set root=(hd0,3)
            linux /vmlinuz root=/dev/sda3 ro single
            initrd /initrd.img
    }
    EOF
    If you tri-boot enter these entries based on which partition they are on:

    *Note if you are are using Grub2 version 1.99, each subsequent entry will look like this:

    Code:
    menuentry "Ubuntu Precise Pangolin 12.04" {
        set root=(hd0,5)
            linux /vmlinuz root=/dev/sda5 ro quiet splash
            initrd /initrd.img
    }
    *Note instead of this:

    Code:
    echo "Ubuntu Precise Pangolin 12.04" >&2 
    cat << EOF
    menuentry "Ubuntu Precise Pangolin 12.04" {
        set root=(hd0,5)
            linux /vmlinuz root=/dev/sda5 ro quiet splash
            initrd /initrd.img
    }
    EOF
    *Note and this:

    Code:
    menuentry "Ubuntu Precise Pangolin 12.04 (Recovery Mode)" {
        set root=(hd0,5)
            linux /vmlinuz root=/dev/sda5 ro single
            initrd /initrd.img
    }
    *Note instead of this:

    Code:
    echo "Ubuntu Precise Pangolin 12.04 (Recovery Mode)" >&2 
    cat << EOF
    menuentry "Xbuntu Precise Pangolin 12.04 (Recovery Mode)" {
        set root=(hd0,5)
            linux /vmlinuz root=/dev/sda5 ro single
            initrd /initrd.img
    }
    EOF
    Skip this part and go to step 5 below if you just boot into Ubuntu only.


    4) If you are dual booting Windows as I am, you will add this below the above 2 entries after the “EOF”:

    *Note if you are using Grub2 version 1.99, you will be add this:

    Code:
    menuentry "Windows 7" {
        insmod ntfs
        set root='(hd0,1)'
        search --no-floppy --fs-uuid --set 1cfc7a8dfc7a60c6
        chainloader +1
    }


    *Note instead of this:

    Code:
    echo "Windows 7" >&2 
    cat << EOF
    menuentry "Windows 7" {
        insmod ntfs
        set root='(hd0,1)'
        search --no-floppy --fs-uuid --set 1cfc7a8dfc7a60c6
        chainloader +1
    }
    EOF


    The red numbers above will need to be changed to match the drive, partition where you windows install is.
    And the UUID red characters after --set above will need to match the characters contained on a similar line between these 2 lines in the output of sudo grub-mkconfig.
    ### BEGIN /etc/grub.d/30_os-prober ###

    ### END /etc/grub.d/30_os-prober ###
    or see the output of the sudo blkid command mentioned in step 3 above.


    5) Then after all of that is entered below the last line in /etc/grub.d/40_custom, save the file as /etc/grub.d/06_custom
    It is very important to save the file as /etc/grub.d/06_custom and not /etc/grub.d/40_custom, so the custom entries appear first.
    Each file is executed in numerical sequence. If you save the custom entries in /etc/grub.d/40_custom, you will still need to modify the default line every time a kernel is installed, which defeats the purpose of this tutorial.

    Then the last thing is to make /etc/grub.d/06_custom executable with this command:
    sudo chmod +x /etc/grub.d/06_custom

    Then of course sudo update-grub to make the changes “stick”. If you ever make a change to any of these files and do not remember to enter this command upon reboot, you will not see your changes.

    Then after you have this setup like you want it, you can make only those 2 or 3 lines appear on your Grub screen. But, I would recommend waiting a little while and maybe let a kernel update come in and see if the new top option picks the new kernel.
    You can enter sudo uname -a to see which version of kernel you are using. When you are confident that all is working as it should you can eliminate the other lines as desired and it will be maintenance free.

    As it is, it will list your custom entries at the top and the other entries for what normally displays below that.


    6) If and when you are satisfied with the customized screen, you can make the other lines disappear like this:
    (The following are simply suggestions and if you want to see the other lines you do not have to follow the next steps.)
    But, the default line and the lines you have added at the top will now be maintenance free,

    To make the memtest86+ lines so that they do not display enter:
    sudo chmod -x /etc/grub.d/20_memtest86+

    To make the other Ubuntu kernel lines so that they do not display enter:
    sudo chmod -x /etc/grub.d/10_linux
    *Note: It is highly recommended that you keep at least 2 kernels installed.
    If you encounter issues with the latest kernel, enter sudo chmod +x /etc/grub.d/10_linux && sudo update-grub
    to make all of the kernels selectable.

    If you are dual-booting windows and want to make the duplicate windows entries go away enter this: sudo chmod -x /etc/grub.d/30_os-prober
    If you are dual booting or triple booting with another OS, you may not want to modify the 30_os-prober file.

    And always remember to enter sudo update-grub after any changes (sudo update-grub2 does the same thing).

    Now you will have a GRUB2 screen that does not change or require any modification even when a new kernel is installed.

    Example picture

    7) Now to make the font larger and more readable.

    *Note enter gksu gedit /etc/default/grub to see if it already contains the GRUB_FONT= line. If it is, skip this, if not, continue.

    sudo grub-mkfont --output=/boot/grub/DejaVuSansMono.pf2 \
    --size=24 /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf


    *Note if you are using Grub2 version 1.99- You will probably get errors like the ones below while making the font, but just ignore them.

    Code:
    Unknown gsub feature 0x63636d70 (ccmp)
    Unknown gsub feature 0x646c6967 (dlig)
    Unsupported substitution flag: 0x9
    Unsupported substitution flag: 0x9
    Unknown gsub feature 0x6c6f636c (locl)
    Unknown gsub feature 0x6c6f636c (locl)
    Unsupported substitution flag: 0x9
    This will copy and resize the font DejaVuSansMono.ttf and put it into a format and location that GRUB will use.

    Then edit this file gksu gedit /etc/default/grub and add the line below near the top of the file.

    GRUB_FONT=/boot/grub/DejaVuSansMono.pf2

    And enter sudo update-grub

    Example picture with bigger font

    The picture above is fairly dark and has cyan/black (normal) and white/black (highlight) for colors in /etc/grub.d/05_debian_theme.


    Another example with white snow background and blue/black (normal) and magenta/black (highlight) colors in /etc/grub.d/05_debian_theme.

    Here is my current tri-boot grub screen:





    Last updated: June 25, 2012
    Added *Notes for Ubuntu versions that use Grub2 version 1.99 which started at Natty 11.04 and possibly late Maverick 10.10.
    Added a note above step 2 that simplifies the background for Grub2 version 1.99
    More updating for Grub2 version 1.99 starting with note before step 2 through step 2.
    Last edited by Elfy; November 20th, 2012 at 07:25 PM. Reason: Added the green *Note lines for versions Natty Narwhal up through the latest version that use grubb 1.99

  2. #2
    Join Date
    Aug 2010
    Beans
    40

    Exclamation Re: Grub 2 Basics

    Quote Originally Posted by Cavsfan View Post
    In case anyone wants to have a maintenance free GRUB2 screen, check out my tutorial on how to do so.
    Ranch Hand showed me everything contained in it, I am just sharing it with anyone that wants it.

    drs305, there will still be plenty of need for your tutorial here as you probably forgot more than I'll ever know about GRUB2!

    And I hope you don't mind me posting this here. I am kind of excited!

    http://ubuntuforums.org/showthread.php?t=1542338

    Thanks!
    After I have done what you said; "Then click on Nautilus Settings and put a check mark beside Open Folder with root privileges." I keep on getting this...

    andrey@andrey-desktop:~$ update-grub
    /usr/sbin/grub-mkconfig: You must run this as root

    Is there a fix? What happened that this occurred?

  3. #3
    Join Date
    Aug 2009
    Beans
    Hidden!
    Distro
    Xubuntu

    Re: Grub 2 Basics

    Quote Originally Posted by SkulblakaSama View Post
    After I have done what you said; "Then click on Nautilus Settings and put a check mark beside Open Folder with root privileges." I keep on getting this...

    andrey@andrey-desktop:~$ update-grub
    /usr/sbin/grub-mkconfig: You must run this as root

    Is there a fix? What happened that this occurred?
    If you are referring to my tutorial, which looks like you are, you should post at the bottom of that thread.
    Some where in Ubuntu Tweak it should have asked you for a password in order to put the check mark in Nautilus Settings
    or else it did not take effect. You should put 'sudo' before either update-grub or grub-mkconfig. No matter about the checkbox, these have to be run as root.
    That is what the error you are getting is.
    And please post in the correct thread. If you are working with my tutorial, post questions there.

  4. #4
    Join Date
    Aug 2010
    Beans
    40

    Re: Grub 2 Basics

    Quote Originally Posted by Cavsfan View Post
    If you are referring to my tutorial, which looks like you are, you should post at the bottom of that thread.
    Some where in Ubuntu Tweak it should have asked you for a password in order to put the check mark in Nautilus Settings
    or else it did not take effect. You should put 'sudo' before either update-grub or grub-mkconfig. No matter about the checkbox, these have to be run as root.
    That is what the error you are getting is.
    And please post in the correct thread. If you are working with my tutorial, post questions there.
    My apologies, I realized that but didn't take action. Thank you for the tutorial and the solution.

  5. #5
    Join Date
    Aug 2009
    Beans
    Hidden!
    Distro
    Xubuntu

    Re: Grub 2 Basics

    Quote Originally Posted by SkulblakaSama View Post
    My apologies, I realized that but didn't take action. Thank you for the tutorial and the solution.
    You are most welcome! I just didn't want to waste Drs305's time on my stuff.
    By all means if you have any problems about my tutorial, post questions there.
    Thank you

  6. #6
    Join Date
    Aug 2010
    Beans
    40

    Re: How to: Create a Customized GRUB2 Screen that is Maintenance Free.

    Quote Originally Posted by Cavsfan View Post
    The following hard drive and partition that is needed will be contained between the lines that mention
    ### END /etc/grub.d/10_linux ### in the output of the grub-mkconfig command above, which should be saved. Simply copy the 8 lines below and change the red to suit your needs.
    I didn't understand this part, what 8 lines did you mean?

    These are my 10 lines below "### END /etc/grub.d/10_linux ###"

    ### BEGIN /etc/grub.d/20_memtest86+ ###
    Found memtest86+ image: /boot/memtest86+.bin
    menuentry "Memory test (memtest86+)" {
    insmod ext2
    set root='(hd0,5)'
    search --no-floppy --fs-uuid --set 1609e458-e91e-4866-bb71-65e544e681ae
    linux16 /boot/memtest86+.bin
    }

    Stupid question, do I count the white space, and "### BEGIN /etc/grub.d/20_memtest86+ ###" or just the 8 lines below "### BEGIN /etc/grub.d/20_memtest86+ ###"?

  7. #7
    Join Date
    Aug 2009
    Beans
    Hidden!
    Distro
    Xubuntu

    Re: How to: Create a Customized GRUB2 Screen that is Maintenance Free.

    Quote Originally Posted by SkulblakaSama View Post
    I didn't understand this part, what 8 lines did you mean?

    These are my 10 lines below "### END /etc/grub.d/10_linux ###"

    ### BEGIN /etc/grub.d/20_memtest86+ ###
    Found memtest86+ image: /boot/memtest86+.bin
    menuentry "Memory test (memtest86+)" {
    insmod ext2
    set root='(hd0,5)'
    search --no-floppy --fs-uuid --set 1609e458-e91e-4866-bb71-65e544e681ae
    linux16 /boot/memtest86+.bin
    }

    Stupid question, do I count the white space, and "### BEGIN /etc/grub.d/20_memtest86+ ###" or just the 8 lines below "### BEGIN /etc/grub.d/20_memtest86+ ###"?

    The 8 lines are in the first 2 boxes Starting with echo and ending with EOF and they must be copied exactly as they are.
    If you are dual booting windows, the 3rd box actually is 9 lines long but, starts and ends with the exact same thing.

  8. #8
    Join Date
    Aug 2010
    Beans
    40

    Re: How to: Create a Customized GRUB2 Screen that is Maintenance Free.

    Quote Originally Posted by Cavsfan View Post
    The 8 lines are in the first 2 boxes Starting with echo and ending with EOF and they must be copied exactly as they are.
    If you are dual booting windows, the 3rd box actually is 9 lines long but, starts and ends with the exact same thing.
    Ahh, I see, I had to copy that code that was in the box, then modify the red found in grub-mkconfig.

  9. #9
    Join Date
    Aug 2009
    Beans
    Hidden!
    Distro
    Xubuntu

    Re: How to: Create a Customized GRUB2 Screen that is Maintenance Free.

    Quote Originally Posted by SkulblakaSama View Post
    Ahh, I see, I had to copy that code that was in the box, then modify the red found in grub-mkconfig.
    Yes, exactly! Let me know how it comes out! And thanks for doing this!

  10. #10
    Join Date
    Aug 2010
    Beans
    40

    Re: How to: Create a Customized GRUB2 Screen that is Maintenance Free.

    Quote Originally Posted by Cavsfan View Post
    Yes, exactly! Let me know how it comes out! And thanks for doing this!
    One more question, are the numbers the same? This is what I have;

    echo "Adding Ubuntu Lucid Lynx 10.04" >&2
    cat << EOF
    menuentry "Ubuntu Lucid Lynx 10.04" {
    set root=(hd0,5)
    linux /vmlinuz root=/dev/sda5 ro quiet splash
    initrd /initrd.img
    }
    EOF

    I couldn't find the "sda#" part, so I assumed both numbers have to be the same. Is that correct?

Page 1 of 16 12311 ... LastLast

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
  •