Results 1 to 5 of 5

Thread: Remove old kernels except the newest to the current one being used.

  1. #1
    Join Date
    Feb 2016
    Beans
    57

    Question Remove old kernels except the newest to the current one being used.

    I like the idea of removing old kernels to save harddisk space, the current procedure removes all but the current one in use. How can I do the same job but leave the previous kernel to the one in use in place? This would be useful for many reasons for unexplained screw ups, malicious attacks (rare but not impossible), or just your stupid self somehow making the system unbootable. Sure, there are tools in Linux to repair your system, but it is just easier and faster just to boot up in a previous image or simply just do a complete install for the majority of us who simply don't have the time for a nitty-gritty system repair. So, how would you go about doing this? Is there a way all ready built in? Can this be done in a script?

  2. #2
    Join Date
    Feb 2008
    Beans
    5,078
    Distro
    Xubuntu 16.04 Xenial Xerus

    Re: Remove old kernels except the newest to the current one being used.

    sudo apt autoremove

  3. #3
    Join Date
    Feb 2016
    Beans
    57

    Re: Remove old kernels except the newest to the current one being used.

    I already use sudo apt autoremove. I take it what I want to do is not possible so I can't leave one of the older images in case of primary image failure.

  4. #4
    Join Date
    Oct 2006
    Beans
    57,617

    Re: Remove old kernels except the newest to the current one being used.

    What do you mean by "current procedure" ?

    sudo apt autoremove will remove all older kernels except for the current and next to last ones, in other words it will do what you want.

  5. #5
    Join Date
    Aug 2011
    Location
    51.8° N 5.8° E
    Beans
    6,085
    Distro
    Xubuntu 20.04 Focal Fossa

    Re: Remove old kernels except the newest to the current one being used.

    sudo apt autoremove does what you want, although I've noticed that after that feature on kernel updates was introduced (was it on 13.10?) it took a while before it worked reliably. It kept kernels that should have been removed. I'm working on a thread where autoremove doesn't work on 14.04. But even then, it's not very hard to manually select the kernel to remove. It's just four packages or so, and you don't have to do it very often.

Tags for this Thread

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
  •