LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Ubuntu (https://www.linuxquestions.org/questions/ubuntu-63/)
-   -   Grub 2, delete unwanted lines from the start menu (https://www.linuxquestions.org/questions/ubuntu-63/grub-2-delete-unwanted-lines-from-the-start-menu-908773/)

cliffd7 10-18-2011 10:04 AM

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

amani 10-18-2011 10:24 AM

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.

cliffd7 10-18-2011 10:46 AM

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

yancek 10-18-2011 01:09 PM

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.

hen770 10-18-2011 02:05 PM

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.

PTrenholme 10-18-2011 02:33 PM

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.

cliffd7 10-19-2011 03:16 AM

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

colorpurple21859 10-19-2011 05:15 AM

Quote:

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

cliffd7 10-19-2011 05:38 AM

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

colorpurple21859 10-19-2011 09:27 AM

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.

cliffd7 10-19-2011 10:19 AM

There is nothing in /boot/grub/grub.cfg.old
Remember we are talking about Grub2 here.
Cliff

PTrenholme 10-19-2011 11:38 AM

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.

cliffd7 10-19-2011 12:38 PM

Thanks PT, I am comfortable with that but where is the editable file that has the lines which appear on the menu?
Cliff

colorpurple21859 10-19-2011 12:53 PM

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.

EDDY1 10-19-2011 01:39 PM

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


All times are GMT -5. The time now is 12:26 PM.