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 Centos Versions:
- Centos 5.x
- Centos 6.x
Explanation of requirements.
- Working Centos install
- Root access to the system in question
Doing the Work
Basic description of what will be done and what is expected.
- The location of the Grub bootloader conf and menu.1st:
- Custom spash image:
- Copying the newly created image to the proper location so Grub can find it:
- Removing rhgb and quiet from the kernel line and adding vga= to set the terminal color depth and resolution:
- Other boot time options and their descriptions can be found here:
- Renaming your menu items:
- Changing the foreground and background colors:
- Change the timeout (the waiting time before default=n is processed):
- Adding another operating system to the menu:
]# 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.
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
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 Centos 5.2 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 CentOS 5.2 x86_64 2.6.18-92.1.22.el5 root (hd0,0) kernel /vmlinuz-2.6.18-92.1.22.el5 ro root=LABEL=/ initrd /initrd-2.6.18-92.1.22.el5.img title CentOS 5.2 x86_64 2.6.18-92.el5 root (hd0,0) kernel /vmlinuz-2.6.18-92.el5 ro root=LABEL=/ vga=791 initrd /initrd-2.6.18-92.el5.img title Windows XP SP3 rootnoverify (hd0,0) chainloader +1
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.
In the example grub.conf above we see this line: title Fedora 9 Sulphur 184.108.40.206-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 220.127.116.11-55 title Fedora 18.104.22.168-55 title Linux 22.214.171.124-55 title Fedora 9 126.96.36.199-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.
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
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.
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.
- Reboot the system to verify you’ve made the correct changes:
- 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:
From the command line as root issue one of the following commands: ]# init 6 ]# shutdown -r now ]# reboot
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 & Fixes
For tips with troubleshooting or finding other Centos resources:
Any additional information or notes.
We test this stuff on our own machines, really we do. But you may run into problems, if you do, come to #centoshelp on irc.freenode.net