This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes Editing the grub.cfg file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Editing the grub.cfg file" Watch "Editing the grub.cfg file" New topic
Author

Editing the grub.cfg file

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9353
    
    2

Guys,

I have installed Ubuntu 9.10 alongside Windows 7 and I would like to know how to remove some of the menu entries that appear when I boot up the system. I tried changing the grub.cfg but it says that it is not editable even under sudo access. Please suggest me how to get this done?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9353
    
    2

Is there really a way to do this?? I have around 7 entries during boot up and I need only two of them and I'm now trying to remove every other ones other than Ubuntu and Windows 7 loaders.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16022
    
  20

Yes there is. Actually, grub.cfg is one of several aliases for /boot/grub/grub.conf. Unlike LILO, you don't have to "compile" that file to make it work. Changes are seen the next time it's read (meaning when you boot up).

It's possible that you have selinux denying access for your editing. Ubuntu/Debian isn't as good about breaking out logs by product, but if there's an selinux violation, it's probably being reported in either /var/log/audit or /var/log/messages.

And, of course, you do need something like "774" for access rights to the file.


Customer surveys are for companies who didn't pay proper attention to begin with.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9353
    
    2

Will have to try changing the file permissions. I remember doing that but let me confirm this today again.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

If you look at the comment at the start of menu.cfg you will see that is refers to:

a) templates in directory /etc/grub.d
b) setting in file /etc/default/grub

Looking at the templates in /etc/grub.d, it appears that they are scripts which dynamically construct the Grub 2 menu based on what the scripts find. For example, the 10_linux script will find all kernel versions installed. Thus I assume that one way to remove a kernel version form the grub menu is to delete the /boot/initrd.img-* file for each entry you do not want.

I applaud the Grub developers for automating what used to be an error-prone task. I am, on the other hand, appalled by how difficult it is now to tweak the boot menu.


JBoss In Action
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9353
    
    2

Peter,

Thanks for the reply. But now is there a way to edit this file to get rid of the unwanted OS menu entries during startup?
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9353
    
    2

Are you sure by deleting "/boot/initrd.img-*", I can get rid of the unwanted OS lists that appear during boot up time?
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

Yes, as far as I know. If the script is looking for those files, and they are absent, then it can't very well add them to the menu, can it?

And why did you even have to ask? You could have simply renamed or moved the file and tried it out. Then the total time to get an answer to your question would have been 5 minutes instead of 5 hours. And you would have learned something that you can then impart to others. Don't be so afraid to experiment and try things - that is how you learn.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9353
    
    2

I would try that today. It has been a while since I even turned my machine on. Will do that today.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Editing the grub.cfg file