Howmany option from grub no longer available in grub2
This bug report was converted into a question: question #92983: Howmany option from grub no longer available in grub2.
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/
# These are optional, user-defined variables.
export GRUB_DEFAULT \
GRUB_
GRUB_
GRUB_TIMEOUT \
GRUB_DISTRIBUTOR \
GRUB_
GRUB_
GRUB_
GRUB_
GRUB_
GRUB_
GRUB_
GRUB_GFXMODE \
GRUB_
GRUB_HOWMANY
then I added some logic to /etc/grub.
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-
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
Changed in grub2 (Debian): | |
status: | Unknown → New |
Changed in grub2 (Ubuntu): | |
status: | Confirmed → Triaged |
importance: | Undecided → Wishlist |
Changed in grub2 (Ubuntu): | |
status: | Fix Released → Invalid |
Yes this is not a bug report but this question can be filed under "Answers"