LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Grub Question (https://www.linuxquestions.org/questions/linux-newbie-8/grub-question-647634/)

Sunfist 06-07-2008 10:39 AM

Grub Question
 
As the kernel keeps getting updated will grub just keep adding more and more entries to the boot menu? Can I edit the menu.lst and just delete the older ones without hurting anything?

Larry Webb 06-07-2008 10:49 AM

Yes you can edit your menu.lst but why?

John-in-France 06-07-2008 10:52 AM

I'm more used to Fedora but I suspect Ubuntu uses much the same approach. Normally the automatic additions to Grub are limited to the new version and the version it is replacing. Older stanzas are automatically removed.

As to editing the file (\boot\grub\menu.lst or \boot\grub\grub.conf (depending on distro)), "root" can always do that but here, the caveat is "handle with care". If you really try you can end up with an un-bootable system and whilst recreating menu.lst or in a really bad case re-installing grub are both fairly straightforward, neither is really something you want to have to do on a weekly basis.

John

Junior Hacker 06-07-2008 03:05 PM

Quote:

Originally Posted by Sunfist (Post 3177557)
As the kernel keeps getting updated will grub just keep adding more and more entries to the boot menu? Can I edit the menu.lst and just delete the older ones without hurting anything?

In Debian, (same as Ubuntu), when I update a kernel with an extra-version like 2.6.23-1 to 2.6.23-2 (example), there will still only be one entry for that OS in the grub menu, because there's still only one kernel. But if I update to a newer version kernel like 2.6.23-2 to 2.6.24-1 (example again), then there will be an entry for both kernels as they are two different kernels.
If I decide I'll never boot with the older kernel again as is usually the case, I remove the older linux-kernel-image, headers, and linux-kbuild via the package manager like apt or synaptic, and the grub menu.lst will automatically be updated to reflect the changes.

There's no need to edit the grub menu.lst if you don't want to use the older kernel, just remove this kernel that you don't want, and keep your system lean to prevent eventual bloating. You can always re-install it later if you decide you want it back.

alan_ri 06-07-2008 03:28 PM

You can delete any entry that you want but usually it's a good idea to have at least two kernels on your system.So the best solution would be to limit the number of kernels that will be shown in the grub boot menu.To do so edit /boot/grub/menu.lst (gksu gedit /boot/grub/menu.lst), find "#howmany=all" and change it to "#howmany=2",save the file and then run "sudo update-grub".Then you will see only newest two kernels.You can then delete older kernels if you like.

i92guboj 06-07-2008 04:07 PM

Quote:

Originally Posted by John-in-France (Post 3177568)
I'm more used to Fedora but I suspect Ubuntu uses much the same approach. Normally the automatic additions to Grub are limited to the new version and the version it is replacing. Older stanzas are automatically removed.

As to editing the file (\boot\grub\menu.lst or \boot\grub\grub.conf (depending on distro)), "root" can always do that but here, the caveat is "handle with care". If you really try you can end up with an un-bootable system and whilst recreating menu.lst or in a really bad case re-installing grub are both fairly straightforward, neither is really something you want to have to do on a weekly basis.

John

The synxtax of menu.lst/grub.conf is really simple and straightforward.

I can hardly imagine how anyone with a minimal common sense could render unbootable a system by just removing one old kernel from the list (unless the only remaining kernel is a self-compiled and untested kernel, of course).

Besides that, if you screw up your config, reinstalling grub to the mbr is not going to help at all. And, anyway, as long as grub is on the mbr and you have a kernel on your disk, the system is bootable, because grub, unlike lilo, permits manual operation at boot time, so you can edit your kernel lines and boot any kernel that you have on your hard drive, as long as it's into one of the filesystems that grub can read from. You even have a shell-like feeling and tab autocompletion, even an elephant could find a kernel to boot from that way.

Sample grub.conf:

Code:

title foo-2.5.22
  root (hd0,5)
  kernel /foo-2.5.22 root=/dev/hda1

title foo-2.5.23
  root (hd0,5)
  kernel /foo-2.5.23 root=/dev/hda1

title foo-2.5.24
  root (hd0,5)
  kernel /foo-2.5.24 root=/dev/hda1

title foo-2.5.25
  root (hd0,5)
  kernel /foo-2.5.25 root=/dev/hda1

I think that's evident enough what to do if we want to remove 2.5.22 from the boot menu. The sections might be a bit complexer, but that's completely besides the point.

Duck2006 06-08-2008 10:44 AM

In ubuntu go to Synaptic Package Manager and load startup manager, you can clean up your menu.lat from there.


All times are GMT -5. The time now is 07:22 AM.