Personal tools
You are here: Home Team Members opsec | warren Customizing the Grub system bootloader

Customizing the Grub system bootloader

by opsec last modified Jun 16, 2008 08:00 PM
— filed under:

This howto will describe how you can change the background image/color, make a new background/splash image from your existing image, rename the menu, reorder the position of menu items, add extra boot arguments to the kernel, change the default menu item, change the default timeout before the system loads the default menu item, add another operating system to the menu.

Applicable to Fedora Versions

  • Fedora ALL versions

Requirements

Explanation of requirements.
  1. Working Fedora install
  2. Root access to the system in question

Doing the Work

Basic description of what will be done and what is expected.

  1. The location of the Grub bootloader conf and menu.1st:
  2. ]# ls -als /boot/grub | grep grub && ls -als /etc | grep grub
    2 -rw------- 1 root root 860 jun 16 15:58 grub.conf
    1 lrwxrwxrwx 1 root root 11 jun 14 13:49 menu.lst -> ./grub.conf
    0 lrwxrwxrwx 1 root root 22 jun 14 13:49 grub.conf -> ../boot/grub/grub.conf

    We can see here that the /boot/grub/grub.conf file which is read on boot is owned by root. The /etc/menu.1st file is
    linked to the /etc/grub.conf file and has rwx privileges for all. The /etc/grub.conf is linked to the
    /boot/grub/grub.conf file and has rwx privileges for all. Thus, /boot/grub/grub.conf doesn't need to be edited
    directly since the changes will be replicated automatically.
  3. Custom spash image:
  4. In this example my jpg image is called "dark_sun.jpg" which we'll be converting to 640x480 14 color and 16-bit depth.

    Grub splash image requirements:
    1. xpm.gz file type
    2. 640x480
    3. 14 colors only

    I have my image in ~/dark_sun.jpg so I'll issue the command from the same directory as my user:

    ]$ convert dark_sun.jpg -resize 640x480 -colors 14 -depth 16 -normalize -verbose dark_sun.xpm
    dark_sun.jpg=>dark_sun.xpm JPEG 1024x768=>640x480 640x480+0+0 PseudoClass 13c 16-bit 302.25kb 0.570u 0:02

    Now we can see the image was created with the following command:

    ]$ ls -als | grep dark_sun
    76 -rw-rw-r-- 1 warren warren 70445 2008-06-16 16:04 dark_sun.jpg
    308 -rw-rw-r-- 1 warren warren 309504 2008-06-16 16:06 dark_sun.xpm

    Now we need to gzip the image as per the Grub requirements:

    ]$ gzip dark_sun.xpm
    ]$ ls -als | grep dark_sun
    76 -rw-rw-r-- 1 warren warren 70445 2008-06-16 16:04 dark_sun.jpg
    48 -rw-rw-r-- 1 warren warren 47340 2008-06-16 16:06 dark_sun.xpm.gz
  5. Copying the newly created image to the proper location so Grub can find it:
  6. First we need root privileges:

    ]$ su -
    password:
    ]# cp ~/dark_sun.xpm.gz /boot/grub/

    Next, we edit the /etc/grub.conf file:

    ]# nano /etc/grub.conf

    We see below a dual boot configuration with Windows XPSP3 and 2 Fedora 9 kernels. We'll be changing the line that
    starts with "splashimage" to reflect the name of our new image:

    # grub.conf generated by anaconda
    #
    # Note that you do not have to rerun grub after making changes to this file
    # NOTICE: You have a /boot partition. This means that
    # all kernel and initrd paths are relative to /boot/, eg.
    # root (hd0,1)
    # kernel /vmlinuz-version ro root=/dev/sda3
    # initrd /initrd-version.img
    #boot=/dev/sda
    default=0
    timeout=33
    splashimage=(hd0,1)/grub/dark_sun.xpm.gz
    hiddenmenu
    title Fedora 9 Sulphur 2.6.25.6-55
    root (hd0,1)
    kernel /vmlinuz-2.6.25.6-55.fc9.i686 ro root=UUID=198659de-871a-4d6b-ba74-333645337f86 vga=795
    initrd /initrd-2.6.25.6-55.fc9.i686.img
    title Fedora 9 Sulphur 2.6.25-14
    root (hd0,1)
    kernel /vmlinuz-2.6.25-14.fc9.i686 ro root=UUID=198659de-871a-4d6b-ba74-333645337f86 vga=795
    initrd /initrd-2.6.25-14.fc9.i686.img
    title Windows XP SP3
    rootnoverify (hd0,0)
    chainloader +1

  7. Removing rhgb and quiet from the kernel line and adding vga= to set the terminal color depth and resolution:
  8. Grub vga values for terminal color depth and resolution:

    640x480 800x600 1024x768 1280x1024 1600x1200
    ---------------+-------+-------+--------+---------+---------
    256 (8 bit) | 769 771 773 775 796
    32,768 (15 bit)| 784 787 790 793 797
    65,536 (16 bit)| 785 788 791 794 798
    16.8M (24 bit) | 786 789 792 795 799

    rhgb = redhat graphical boot
    quiet = suppresses the verbose boot output (not good if we want to see what our system is doing on boot)

    At the end of the kernel line we'll add: vga=(proper color depth and resolution for your video card/monitor combo)
    In the example above I've set mine to vga=795 which is 16.8 million colors (24bit) and 1280x1024 resolution. You
    will need to consult your documentation first or experiment to find out which one works for you. If it doesn't work,
    you'll see nothing but a black screen until the system boots, at which time you can change it to another value.

  9. Other boot time options and their descriptions can be found here:
  10. Redhat Link #1
    Redhat Link #2
    FedoraProject Link #1
  11. Renaming your menu items:
  12. In the example grub.conf above we see this line:

    title Fedora 9 Sulphur 2.6.25.6-55

    After the word "title" we are free to rename this line to whatever we'd like the option to read at boot time, such as
    the following examples:

    title Fedora 9 2.6.25.6-55
    title Fedora 2.6.25.6-55
    title Linux 2.6.25.6-55
    title Fedora 9 2.6.25.6-55 (with custom foo module)

    You get the idea here. The order these items appear can also be changed by cutting and pasting. Also, the default boot
    item can be changed using the default=n option. Where n= the position in the menu you'd like to boot if you allow the
    timeout limit to run out. For instance, if you've set your timeout to 33 seconds (as in the example above) and you do
    nothing, item 0 (which is actually the first kernel in the list) will boot automatically.

  13. Changing the foreground and background colors:
  14. Add these lines to your /etc/grub.conf file:

    foreground = ffffff
    background = 000000

    These examples are black (000000) and white (ffffff), you can change these values to whatever colors you want from
    the list located here
  15. Change the timeout (the waiting time before default=n is processed):
  16. In the above example we see the line:

    timeout=33

    This value is in seconds, we can change it to however many seconds we'd like grub to countdown before booting the
    default choice in the menu.
  17. Adding another operating system to the menu:
  18. Typically, you'd want to install Windows or your other operating system first before installing Fedora. If you should
    have a "meltdown" and need to reinstall Windows or your other operating system, you may need to re-install Grub and
    verify these settings to make sure everything boots properly.

    title Windows XP SP3
    rootnoverify (hd0,0)
    chainloader +1

    In this example we've added Windows XP and renamed the title above to reflect that ServicePack 3 was installed as well.

Troubleshooting

How to test

Explanation troubleshooting basics and expectations.
  1. Reboot the system to verify you've made the correct changes:
  2. From the command line as root issue one of the following commands:

    ]# init 6
    ]# shutdown -r now
    ]# reboot
  3. Look over this howto again to make sure you haven't missed anything and make sure you haven't inadvertently commented out a line in your grub.conf:
  4. A comment in a conf file is a hash symbol or the pound symbol --> # If you have one or more of these in front of a
    line you want processed, remove it. The hash symbol tells the program "don't process" or "ignore this line".

    Example:

    option 1 argument1 argument2
    # option 2 argument1 argument2

    In this example option 2 is not processed.

Common problems and fixes

For tips with troubleshooting or finding other Fedora resources:

More Information

Any additional information or notes.

Disclaimer

We test this stuff on our own machines, really we do. But you may run into problems, if you do, come to #fedora on irc.freenode.net

Added Reading

Document Actions
Log in


Forgot your password?
New user?