LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 10-18-2011, 10:04 AM   #1
cliffd7
Member
 
Registered: Sep 2010
Posts: 33

Rep: Reputation: 0
Grub 2, delete unwanted lines from the start menu


As you probably know Ubuntu now uses Grub 2.
Over several months I have accumulated a lot of extra lines on the start up menu but I can't work out how to get rid of them.
I have read the Grub 2 Tutorial and just don't understand it
Can anyone help?
Cliff
 
Old 10-18-2011, 10:24 AM   #2
amani
Senior Member
 
Registered: Jul 2006
Location: Kolkata, India
Distribution: Debian 64-bit GNU/Linux, Kubuntu64, Fedora QA, Slackware,
Posts: 2,766

Rep: Reputation: Disabled
Inside your /etc/grub.d you will find many files. Update these and run update-grub2 for modifications.

What unwanted lines? ... grub2 is supposed to find everything bootable.

If you have extra kernels installed, then uninstall them.
 
Old 10-18-2011, 10:46 AM   #3
cliffd7
Member
 
Registered: Sep 2010
Posts: 33

Original Poster
Rep: Reputation: 0
Thanks Amani,
I have 7 extra kernels listed which do not boot. Plus there recovery modes and a couple of MeMTests.
In the original Grub it was easy to # these out but not in Grub 2
However there must be a similar mechanism to get rid of them.
Why do I want to get rid of them?? because they push my other OS boot off the page.
Cliff
 
Old 10-18-2011, 01:09 PM   #4
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,504

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
If you want to disablee the recovery entries, open /etc/default/grub file with sudo in a text editor. There should be a line at the bottom similar to:
Quote:
#GRUB_DISABLE_LINUX_RECOVERY="true"
Uncomment the line by removing the hash mark (#) at the beginning.

To remove the memtest entries, do this after navigating to the /etc/grub.d/ directory:

Quote:
sudo chmod -x 20_memtest86+
The script will not be executable and won't be read by Grub2.

Quote:
I have 7 extra kernels listed which do not boot
Do you know why? Do these kernels exist or have they been removed/deleted? Run sudo update-grub.
 
Old 10-18-2011, 02:05 PM   #5
hen770
Member
 
Registered: Oct 2010
Distribution: Arch
Posts: 136

Rep: Reputation: 7
let's get the big picture here, is anyone know how to delete kernel entries (which they are in grub.cfg, and hasn't been add through 40_custom file) that i don't need ?

it seems that with grub2 things gets complicated, i am not complain about it, but i cannot find a good documentation.
 
Old 10-18-2011, 02:33 PM   #6
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Look in your /boot directory and delete any files related to things you don't ever want to boot and delete them; if you find some that you think you might want, but not now, move then to a "backup" directory. then run grub-mkconfig -o /boot/grub/grub.cfg to recreate your boot menu.
 
Old 10-19-2011, 03:16 AM   #7
cliffd7
Member
 
Registered: Sep 2010
Posts: 33

Original Poster
Rep: Reputation: 0
Thanks to all for input
;
GRUB DISABLE LINUX RECOVERY = TRUE

This is OK but it removes all the recovery entries. I need to retain the one which relates to the current kernel and possibly the one before.

sudo chmod -x20_memtest86+

Gives me the message "no such file or directory. In any case I don't want to remove all MemTests, I would need to retain one.

As for the extraneous kernels; A couple may have been left over from previous updates and at least 2 have been generated when running "Update Manager"
Only the current kernel will boot.

Sudo update-grub does nothing.

Hen770 has given a good understanding of the question but it doesn't provide an answer.

PTrenholme appears to offer a good suggestion but it raises a question------which files?
each kernel has several files, for example;-
abi-2.6.32.....
config-2.6.32.....
initrd.img-2.6.32....
system.map-2.6.32.....
vmcore-2.6.32.....
vmLinuz-2.6.32.....
There is a strong possibility of creating a non recoverable failure.
More help needed.
Thanks
Cliff
 
Old 10-19-2011, 05:15 AM   #8
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,346

Rep: Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589
Quote:
sudo chmod -x /etc/grub.d/30_os-prober
and then update-grub. This might be what you want but not sure.

Last edited by colorpurple21859; 10-19-2011 at 05:19 AM.
 
Old 10-19-2011, 05:38 AM   #9
cliffd7
Member
 
Registered: Sep 2010
Posts: 33

Original Poster
Rep: Reputation: 0
The only thing this seems to have done is that it has removed the line which boots my Windows OS, not good news.
Can you now tell me how to reinstate the Windows Boot?

To my mind this question should have a very simple answer.
Somewhere there must be a file which shows the list of items on the Boot Menu, an editable file which allows you to remove items which are no longer required.
On the original GRUB this was simple, why the **** has it been made so complicated???
Cliff
 
Old 10-19-2011, 09:27 AM   #10
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,346

Rep: Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589
copy the entries that you want from /boot/grub/grub.cfg.old to the /etc/grub.d/40_custom or
Quote:
sudo chmod +x /etc/grub.d/30_os-prober
then update-grub then copy the entries you want from /boot/grub/grub.cfg to /etc/grub.d/40_custom then
Quote:
sudo chmod -x /etc/grub.d/10_linux
sudo chmod -x /etc/grub.d/30_os-prober
then update-grub. What this does is allows only the entries from the 40_custom file to show up.

Last edited by colorpurple21859; 10-19-2011 at 09:59 AM.
 
Old 10-19-2011, 10:19 AM   #11
cliffd7
Member
 
Registered: Sep 2010
Posts: 33

Original Poster
Rep: Reputation: 0
There is nothing in /boot/grub/grub.cfg.old
Remember we are talking about Grub2 here.
Cliff
 
Old 10-19-2011, 11:38 AM   #12
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
The file you want to edit is the grub.cfg file. I know that the comments at the start of that file say "do not edit." but that's just advice, not some law you have to follow. (I edit mine all the time.) Just make sure you chmod the grub.cfg so Ubuntu's "helpful" update installer can't modify it, and all you'll need to do is run the grub-mkconfig program with the output file pointed someplace other than grub.cfg, and then pick the parts of that output file you want, and put then in your "real" grub.cfg file.

That way you'll have a "hand made" configuration file with a little automated assist.

You might also want to look at the documentation for the /etc/defaults/grub file. It lets you tune lots of the choices made by the automated configuration script. For your edification, here's the default settings I use on my Fedora 17 virtual test system:
Code:
$ cat /etc/default/grub
GRUB_CMDLINE_LINUX="quiet"
GRUB_DEFAULT="saved"
GRUB_SAVEDEFAULT=true
GRUB_TIMEOUT=10
GRUB_GFXMODE=1440x900
GRUB_DISTRIBUTOR="Fedora"
GRUB_DISABLE_RECOVERY=true
GRUB_PRELOAD="raid"
Obviously some of those settings would not be appropriate for a Ubuntu system. It's just to show you that there's more you can do than turn off the recovery boot option.

By the way, the recovery boot options in the grub.cfg file are, really, unnecessary since you can always edit the "standard" GRUB boot stanza to include the recovery options "on the fly" using GRUB's built-in editor.

Last edited by PTrenholme; 10-19-2011 at 11:39 AM.
 
Old 10-19-2011, 12:38 PM   #13
cliffd7
Member
 
Registered: Sep 2010
Posts: 33

Original Poster
Rep: Reputation: 0
Thanks PT, I am comfortable with that but where is the editable file that has the lines which appear on the menu?
Cliff
 
Old 10-19-2011, 12:53 PM   #14
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,346

Rep: Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589
I didn't know if there was a grub.cfg.old that is why I mentioned to make the 30_os_prober file executable again then rerun update_grub to create a new /boot/grub/grub.cfg to get the menu entries to copy and and past to the /etc.grub.d 40_custom file before makeing both files unexecutable . PTrenholme way of doing things is a good idea too.

Last edited by colorpurple21859; 10-19-2011 at 12:54 PM.
 
Old 10-19-2011, 01:39 PM   #15
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,841

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
Unwanted kernels can be removed via Synaptic Package Manager which may run update-grub after removing them

Last edited by EDDY1; 10-20-2011 at 12:24 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Duplicate Lines in a file, leaving only the unique lines left xmrkite Linux - Software 6 01-14-2010 06:18 PM
to add Mandriva grub boot lines to the main menu.lst file, using 2 hard drives james2b Linux - Newbie 5 10-09-2008 06:20 PM
Why GRUB will not start the menu-interface? alpha1truth Fedora 1 09-26-2007 02:30 PM
Perl adding unwanted lines at EOF? ryedunn Programming 1 09-07-2006 09:35 AM
awk/gawk/sed - read lines from file1, comment out or delete matching lines in file2 rascal84 Linux - General 1 05-24-2006 09:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 02:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration