Howmany option from grub no longer available in grub2

Bug #492995 reported by Drask

This bug report was converted into a question: question #92983: Howmany option from grub no longer available in grub2.

22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
grub2 (Debian)
New
Unknown
grub2 (Ubuntu)
Invalid
Wishlist
Unassigned

Bug Description

Binary package hint: grub2

Ubuntu 9.10
grub-pc 1.97~beta4~1ubuntu4

This isn't so much a bug report as a feature request/suggestion, so if this is wrong place, could you help me report this in the correct place?

I don't really like the default behavior of Ubuntu to continue to add all the kernel updates to my grub boot menu. I never go back and use old kernels (except by mistake) and it just crowds up my boot menu.

In the past, I have used the #howmany option in /boot/grub/menu.lst to limit this to only the most recent kernel. Upon upgrading to grub2, though, this option no longer appears to be available. The general recommendations I am seeing on the internet are to either comment out the entries in /boot/grub/grub.cfg or manually remove old kernel packages using aptitude.

This means that every time a kernel is updated, I either have to manually comment out more and more lines from the grub.cfg file despite many warnings not to edit that file directly, or go into aptitude and find and uninstall the old "linux-image" packages.

I decided to try and add support back in for the #howmany option by adding a GRUB_HOWMANY variable to /etc/defaults/grub. This turned out to be fairly simple, and I think it might make a nice addition for next time.

First, I edited the /usr/sbin/grub-mkconfig file and added GRUB_HOWMANY to the list of optional, user-defined variables being exported at around line 213

# These are optional, user-defined variables.
export GRUB_DEFAULT \
  GRUB_HIDDEN_TIMEOUT \
  GRUB_HIDDEN_TIMEOUT_QUIET \
  GRUB_TIMEOUT \
  GRUB_DISTRIBUTOR \
  GRUB_CMDLINE_LINUX \
  GRUB_CMDLINE_LINUX_DEFAULT \
  GRUB_TERMINAL_INPUT \
  GRUB_TERMINAL_OUTPUT \
  GRUB_SERIAL_COMMAND \
  GRUB_DISABLE_LINUX_UUID \
  GRUB_DISABLE_LINUX_RECOVERY \
  GRUB_GFXMODE \
  GRUB_DISABLE_OS_PROBER \
  GRUB_HOWMANY

then I added some logic to /etc/grub.d/10_linux to check and see if
GRUB_HOWMANY is a number and if not, then convert it to zero.

if [ "x${GRUB_HOWMANY}" = "x" ] || ! [ "x`echo ${GRUB_HOWMANY} | sed
's/^[0-9]\+\(\.[0-9]\+\)\?$//'`" = "x" ] ;then
        GRUB_HOWMANY=0
fi

then a "found" variable to keep track of how many kernels I've added to
the menu

found=0

Last, I add a check to the while loop looping through kernels to stop
after finding GRUB_HOWMANY (unless GRUB_HOWMANY is 0)

while ( [ "x$list" != "x" ] && ( [ "${GRUB_HOWMANY}" -eq "0" ] ||
[ "$found" -lt "${GRUB_HOWMANY}" ] )); do

That's it. Now I get only the number of kernels I want, and I don't have
to do anything after updating to a new kernel.

Thanks!
Aaron Chantrill

Revision history for this message
Drask (drask) wrote :
Revision history for this message
Seth Hikari (sethhikari) wrote :

Yes this is not a bug report but this question can be filed under "Answers"

Changed in grub2 (Ubuntu):
status: New → Invalid
Revision history for this message
Felix Zielcke (fzielcke) wrote : Re: [Bug 492995] Re: Howmany option from grub no longer available in grub2

Am Sonntag, den 06.12.2009, 00:13 +0000 schrieb Seth Hikari:
> Yes this is not a bug report but this question can be filed under
> "Answers"

It is a valid feature request. And we already got that in Debian, with a
patch but it seems like the reporter didn't bother to submit it
upstream.

--
Felix Zielcke
Proud Debian Maintainer and GNU GRUB developer

Changed in grub2 (Ubuntu):
status: Invalid → Confirmed
Changed in grub2 (Debian):
status: Unknown → New
Colin Watson (cjwatson)
Changed in grub2 (Ubuntu):
status: Confirmed → Triaged
importance: Undecided → Wishlist
Revision history for this message
sam fielder (srf10130) wrote :
Revision history for this message
sam fielder (srf10130) wrote :
Revision history for this message
sam fielder (srf10130) wrote :

The three patches here will allow users to set the variable GRUB_MAX_KERNELS in /etc/default/grub to reflect the desired number of kernel entries being displayed. hopefully this helps some people out.

Revision history for this message
shanen (Shannon Jacobs) (shanen) wrote :

Congratulations on figuring out the new hoops to jump through to report a bug. I couldn't figure it out, but at this point I don't care enough about Ubuntu to worry about it. I'm just stalling and waiting for a better alternative, perhaps Chrome? (My employer favors RHEL, but I can barely stand it... I tried a bunch of other distros, and for a while Ubuntu WAS the very best, but in a very strong sense of WAS.)

Anyway, here is the bug I would have reported if I could have figured out how to do so. It comes closest to matching this bug report of the ones I could find:

Fresh install of Lucid Lynx in it's very own partition. I made the change in /etc/default/grub to save default so it is supposed to report to the last booted partition. Works fine on one machine (a Sharp notebook) and absolutely refuses to work on another machine (an IBM/Lenovo R53). Looking in /boot/grub/grub.cfg seems to show the proper code has been added to save the default, but something is not working--AND I DON'T REALLY CARE ANYMORE.

I have already wasted a lot of time with this supposedly improved version of Ubuntu. Based on prior experiences with Ubuntu, my two most heavily used machines are both running OLD versions of Ubuntu and I have NO plans to upgrade them for worse functionality.

Hint (on the theory that there is some Ubuntu so-called staff person who cares): Making the reporting of bugs more difficult does NOT make Ubuntu better. It does not reduce the number of bugs or improve the quality of the software. It simply makes Ubuntu more like Microsoft Windows.

P.S. I hate Microsoft and now I'm beginning to hate Ubuntu. That is NOT progress. Apple is no better, and Google will probably go completely evil before Chrome is released... I don't believe the world is really going to hell in a hand-basket, but things only improve on the long-term average, and I seem to be living in the short term.

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

This release of Ubuntu is no longer receiving maintenance updates. If this is still an issue on a maintained version of Ubuntu please let us know.

Changed in grub2 (Ubuntu):
status: Triaged → Incomplete
Revision history for this message
shanen (Shannon Jacobs) (shanen) wrote :

Not sure why it's marked incomplete at this late date, but if I remember correctly the problem was fixed not long after I reported it.

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Thanks for the update Shannon. Sorry you were left hanging!

Changed in grub2 (Ubuntu):
status: Incomplete → Fix Released
Changed in grub2 (Ubuntu):
status: Fix Released → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.