Howmany option from grub no longer available in grub2
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
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- Ubuntu grub2 Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
This question was originally filed as bug #492995.
Can you help with this problem?
Provide an answer of your own, or ask Drask for more information if necessary.