Monday, March 8, 2010

Hacking grub2 ---- part 1

Hi,
Ubuntu 9.10 karmic koala ships with Grub2 now, and they have implemented structural changes in the new grub system.

So, i'll be taking u guys along on the journey of discovering this new grub system and modifying it along the way.

The trick we are going to see today lets us play with the boot menu.
By changing names of few file or by replacing some we can change the order of grub boot menu, and even remove some entries from the boot menu.

These file are stored in /etc/grub.d folder

These files are

1. 00_header
2. 05_debian_theme
3. 10_linux
4. 20_memtest86+
5. 30_os-prober
6. 40_custom
7. README

these file are read in order of their names and their entries are created in a read only configuration file for grub
We will get to that file later.

Now by default according to the file names the boot order is

linux kernels
memtest utilities
other os ( windows )
other custom kernels

So if we want windows to be placed before linux in the grub menu
All we have to do is change the name of the file 30_os-prober to something alphabetically smaller than 10_linux

And run update-grub2 as sudo to recreate the grub.cfg file with new settings.

Also if u want to completely remove the windows entry from the boot menu
Open a terminal
Go to the directory /etc/grub.d/
And rename the file 30_os-prober to .30_os-prober, don't forget the "." before the new file name.
This can be done by issuing the command "mv 30_os-prober .30_os-prober"

And don't forget to run update-grub2 command as a root.

To bring back the windows just rename the file back to 30_os-prober and run update-grub2 command.
And you will have your windows back.


Well guys, that's all for this post.
Stay tuned for more.

No comments:

Post a Comment