Tuesday, October 4, 2011

Grub manipulation

Recently, I installed Fedora 15 on my laptop alongside Windows 7. The Grub screen was as provided by fedora, and I wanted to make some changes to it to suit my needs and pleasure.

Here I have discussed how I went about it.

It should be noted that my methods work in fedora, but should work on other linux distibutions as well with a few minor changes. In case of any doubts or suggestions, please contact me at nardz07@gmail.com.



First of all, open your terminal:





and type the following command to open the grub menu in a text editor for easy editing:

sudo gedit /boot/grub/grub.conf

Remember to login as root using su command.

Now, let us see what all we can do by editing these lines, one by one:

default=0
timeout=05
splashimage=(hd0,7)/boot/grub/111.xpm.gz
hiddenmenu
title Fedora 15
    root (hd0,7)
    kernel /boot/vmlinuz-2.6.40.4-5.fc15.i686.PAE ro root=UUID=b5c39e5f-a7cb-485b-bff0-f3c985e94369 rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=us rhgb quiet
    initrd /boot/initramfs-2.6.40.4-5.fc15.i686.PAE.img
title Windows 7
    rootnoverify (hd0,0)
    chainloader +1

In the above coding, we see that my laptop has only two OS entries - fedora and Windows. The line default = 0 suggests that the first item on the menu should be loaded by default in case of lack of any prompt by the user. So, here, Fedora 15 is loaded by default. To change this and set it to windows, I simply make it default = 1. So. the general formula will be

default = n-1

where n is the entry number of said OS.

The order in which the OSs are displayed can easily be changed by reordering them in this file the way you like.

The keyword timeout = 05 used here means that the user must prompt the grub within 5 seconds, or else the default entry will be loaded. So, to edit it, we can simply change the value, or we can comment said line, to force the user into a prompt.

We can comment a line by simply prefacing it with a #.

hiddenmenu asks grub menu to remain hidden in case fedora is the only OS, or if not, then stay in hiding till the user prompts it. To make sure you pass through the menu every time, simply comment the line.

Now, once we write the display name of each OS behind the keyword title, we need to define the partition where the OS is situated. Although a specific name to the partition may not be directly leading, we use a chainloader to show the sequence of OS definition.

SplashImage is the image shown on the background of the grub menu. By default fedora provides us with its custom image, but we can edit it if we want. How, is explained below:
  1. Select the image you want. Open it in GIMP.
  2. The grub can only handle 640x480pixels. So go to image > scale image and set the pixels to 640x480. The click scale.
  3. The grub image must not have more than 16 colours. So, go to image > modes > indexed and set colours to 16.
  4. Now save the image as .xpm (xpicMap image)
  5. Go to the file browser and compress this image as a .gz package.
  6. Now open the terminal and go to the holding folder.
  7. Send the image to the grub folder by the following command: sudo mv 111.xpm.gz /boot/grub/111.xpm.gz
  8. Once moved, now open the grub menu, either with GEDIT as shown above, or using the telnet(terminal) screen using the following command: sudo nano /boot/grub/grub.conf
  9. Now change the image name to the present package name as shown, and press Ctrl + X. Press Y and exit: 

Now restart your computer to see the magic of your new grub Loader.

So long for now, more posts coming up soon. For any suggestions, or doubts Please contact me at the aforementioned email id. Also, if there is any specific topic that you would like to know about please ask freely. If you know a few neat tricks in computing, I would be mor=st enthusiastic to learn them, so please contact me.

So long, au revoir!

1 comment:

  1. For ubuntu users...

    You lucky people do not need to touch the code itself, as you have an application provided by the ubuntu repositories itself. Just go to your terminal and enter

    sudo apt -get install startupmanager

    this should install the manager, and you can visually change your grub settings. If there are still some of you who want to edit via code, the method i have mentioned above is still useful. Just open menu.lst instead of grub.conf. Type

    sudo nano /boot/grub/menu.lst

    ReplyDelete