[Bug 492995] Re: Howmany option from grub no longer available in grub2

Marcus Tomlinson marcus.tomlinson at canonical.com
Fri Mar 6 07:33:42 UTC 2020


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

** Changed in: grub2 (Ubuntu)
       Status: Incomplete => Fix Released

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to grub2 in Ubuntu.
https://bugs.launchpad.net/bugs/492995

Title:
  Howmany option from grub no longer available in grub2

Status in grub2 package in Ubuntu:
  Invalid
Status in grub2 package in Debian:
  New

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/492995/+subscriptions



More information about the foundations-bugs mailing list