Results 1 to 7 of 7

Thread: Disabling de-installation of previous kernels in automatic kernel upgrades

  1. #1
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,172
    Distro
    Ubuntu 16.04 Xenial Xerus

    Disabling de-installation of previous kernels in automatic kernel upgrades

    Since I upgraded to 14.04 it seems that kernel upgrade N de-installs kernels N-2 and before. One one hand this is nice since this removes the need to clean up /boot periodically by de-installing old kernels. By I'm wondering what will happen if a kernel comes that doesn't work well for me. I can back out to the previous version, but the next version could be just as unusable(*) and will wipe out the only good kernel version I have.

    So is there a way to disable this if needed, typically, by keeping a specific kernel version available?

    (*) On 10.04, 5 or 6 kernel versions in a row made my system rather crash-prone and a trusted kernel version turned out to be rather handy.
    Warning: unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.

  2. #2
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: Disabling de-installation of previous kernels in automatic kernel upgrades

    I actually complained to the maintainers about the old practice. Not deleting stale kernels could make a machine unbootable if /boot were assigned to a separate partition. Usually /boot partitions are fairly small so it was easy to run out of space if stale kernels weren't deleted.

    I suppose you could consider writing a script to back up /boot in case you encounter the problem you describe. Something like
    Code:
    cd /; rsync -av boot /usr/local
    would copy all of /boot to /usr/local/boot for safe keeping. You could put these commands in /etc/rc.local so they would be run at every boot. If there are no new kernels to back up, the command should terminate quickly. As long as you don't use the --delete switch to rsync, /usr/local/boot will contain a complete inventory of all prior kernels and associated files.
    Last edited by SeijiSensei; March 13th, 2015 at 03:28 AM.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  3. #3
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,172
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Disabling de-installation of previous kernels in automatic kernel upgrades

    Having a backup of the kernel doesn't mean that the system can boot it. So if there is no way to disable this I would have to:

    1) keep a backup of the trusted kernel files
    2) notice installation of new kernel
    3) reinstate the old kernels from the backup
    4) run the grub config again

    Can of course be done (everything is doable on Linux...) but if I can avoid it...
    Warning: unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.

  4. #4
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: Disabling de-installation of previous kernels in automatic kernel upgrades

    I must run pretty vanilla machines because I haven't encountered a problem with a kernel update in quite a long time now, probably years. I only use LTS releases these days, though.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  5. #5
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,172
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Disabling de-installation of previous kernels in automatic kernel upgrades

    Quote Originally Posted by SeijiSensei View Post
    I must run pretty vanilla machines because I haven't encountered a problem with a kernel update in quite a long time now, probably years. I only use LTS releases these days, though.
    So have I, but better safe than sorry
    Warning: unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.

  6. #6
    Join Date
    Jul 2013
    Location
    Wisconsin
    Beans
    4,952

    Re: Disabling de-installation of previous kernels in automatic kernel upgrades

    Kernel autoremove is set by the script at /etc/kernel/postinst.d/apt-auto-removal

    The script author, Steve Langasek, gave thought to how many kernels to save, and which kernels to select. See the comments in the script.
    Naturally, patches to improve the script are welcome.

    It doesn't look difficult to hardcode a kernel version you really want to keep.

  7. #7
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,172
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Disabling de-installation of previous kernels in automatic kernel upgrades

    Great. Yes, not difficult to hack if I want to keep a specific version. Thanks for the pointer.
    Warning: unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •