Announcement

Collapse
No announcement yet.

Keeping Old Kernels

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Keeping Old Kernels

    Hello. I don't remember since when, but when I install a new kernel, konsole output says that I may remove an old one with autoremove. Since it may be wise to keep at least one old, stable kernel, how can I set it to not be removed and therefore not receive such messages from konsole?

    #2
    If you look at /etc/kernel/postinst.d/apt-auto-removal:

    # Author: Steve Langasek <steve.langasek@canonical.com>
    #
    # Mark as not-for-autoremoval those kernel packages that are:
    # - the currently booted version
    # - the kernel version we've been called for
    # - the latest kernel version (determined using rules copied from the grub
    # package for deciding which kernel to boot)
    # - the second-latest kernel version, if the booted kernel version is
    # already the latest and this script is called for that same version,
    # to ensure a fallback remains available in the event the newly-installed
    # kernel at this ABI fails to boot
    # In the common case, this results in exactly two kernels saved, but it can
    # result in three kernels being saved. It's better to err on the side of
    # saving too many kernels than saving too few.
    #
    # We generate this list and save it to /etc/apt/apt.conf.d instead of marking
    # packages in the database because this runs from a postinst script, and apt
    # will overwrite the db when it exits.
    So it shouldn't suggest autoremoval of all old kernels, it should keep at least currently running (or second latest if currently running is the latest) kernel installed.

    Comment


      #3
      Hello kubicle. I've installed Kernel 3.13.1-pf for testing. And now konsole output says I may remove 3.13.0-23-generic. But isn't it the last stable kernel for Kubuntu 14.04, since the one currently being used is 3.13.0-24-generic?

      Comment


        #4
        Originally posted by geoaraujo View Post
        Hello kubicle. I've installed Kernel 3.13.1-pf for testing. And now konsole output says I may remove 3.13.0-23-generic. But isn't it the last stable kernel for Kubuntu 14.04, since the one currently being used is 3.13.0-24-generic?
        No, the script aims to keep two kernels installed (in your case 3.13.1-pf and 3.13.0-24-generic). 3.13.0-23-generic is "expendable" as you can clearly boot into 3.13.0-24-generic (the currently running kernel). You usually don't need more than one bootable backup kernel (since you can use that kernel to install other kernels if you need to for some reason)

        If you plan to use more than one "test" kernels, you can override autoremoval of specific kernel versions to keep at least one "stable and bootable" kernel from the main repos installed by creating a file /etc/apt/apt.conf.d/02mystablekernel with the contents:
        APT::NeverAutoRemove
        {
        "<regex to match excluded packages>";
        };
        replace <regex to match excluded packages> with a regex that matches a package you wish to exclude from autoremoval, you can see examples of regex matching in
        /etc/apt/apt.conf.d/01autoremove-kernels (don't edit that file because it's automatically overwritten by the postinst script)

        Comment


          #5
          I see. So, should I create a new file replacing every line displayed by that file with the ones I want to keep? I mean, in this case, creating a file that includes the 3.13.0-23-generic besides 3.13.1-pf and 3.13.0-24-generic or just a file that contains regex for 3.13.0-23-generic?

          Comment


            #6
            Originally posted by geoaraujo View Post
            I see. So, should I create a new file replacing every line displayed by that file with the ones I want to keep? I mean, in this case, creating a file that includes the 3.13.0-23-generic besides 3.13.1-pf and 3.13.0-24-generic or just a file that contains regex for 3.13.0-23-generic?
            The latter, the automatically updated /etc/apt/apt.conf.d/01autoremove-kernels will keep at least two fresh kernels from being autoremoved, you should only include the kernels you wish to keep indefinitely in your custom conffile (you can always edit it later when you wish to change the kernel you wish to keep).

            I'd put the latest 3.13.0-24-generic in there, unless there is a specific reason to keep 3.13.0-23-generic instead, this will keep the 3.13.0-24-generic main repo kernel from being autoremoved no matter how many "test" kernels you install (and/or autoremove)...so you'll have one backup stable kernel always installed...you can then periodically change your back up kernel by editing the file if you wish to switch your backup to a newer "stable" kernel.

            Comment


              #7
              Thank you very much, kubicle. I'll try that later.

              Comment

              Working...
              X