Page 1 of 1

[SOLVED] purge-old-kernels removed in 19, autoremove not working

Posted: Wed Sep 12, 2018 8:10 pm
by Kudalufi
In Mint 19 the purge-old-kernels script, which was a fantastic way of pruning old kernels, was replaced and is basically just an alias now for apt-get autoremove. However, I am finding on my Mint 19 installation, that apt-get autoremove still completely fails to remove old kernels.

The purge-old-kernels script suggests reporting ongoing issues with apt-get autoremove not removing kernels to Ubuntu's apt bug list, but the bug associated with that was marked fixed and closed back in April.

Is this a left over artifact of my installation being one that was upgraded from 18, a mint-ism, or something that truly is wrong with apt? Are other mint users having this issue?

[edit] As noted in my final post, apt-get autoremove DOES work to remove old kernels. If you are upgrading from a previous mint version, though, it won't automatically remove any kernels which were installed prior to the upgrade. Once enough kernel upgrades (and manual removals of the old kernel) are performed that those are gone, apt-get autoremove will act to keep your current and one backup kernel installed.

Re: purge-old-kernels removed in 19, autoremove not working

Posted: Wed Sep 12, 2018 8:41 pm
by DAMIEN1307
i had to read this three or four times to figure out just what you were asking...first off, apt-get autoremove AKA sudo apt autoremove is not a kernel remover it removes the odd leftovers from things that have been removed from the system...kernels are manually removed from mint using the update manager, then click the "view" tab, then click on "linux kernels"...once that is showing, just click on the button marked as "remove" to remove any older unused kernel in the system...the kernel in use, of course, cannot be removed and always leave at least one kernel in there so in case you have a kernel failure in the one that is in use, you will have an older kernel to retreat back to...you can, of course, then use sudo apt autoremove to clean up any other residuals left over...im hoping a read and interpreted correctly what you were trying to say...the scripts listed below will also clean up things from old kernel removal as well as other odd bits of fluff...DAMIEN

Kernel and other Cleanups after Deletions/Removals/Purges

do these one at a time, dont worry if the first dpkg -l says error etc...just means nothing is there is all...

sudo apt autoremove

dpkg -l | grep '^rc' | awk '{print $2}' | sudo xargs dpkg --purge

dpkg -l | grep '^rc' | awk '{print $2}' | xargs sudo apt-get purge

Re: purge-old-kernels removed in 19, autoremove not working

Posted: Thu Sep 13, 2018 4:15 am
by JOPETA
Maybe Kudalufi is talking about scripts (like this one) out there. I always unisntall old kernel as DAMIEN1307 said (i.e. in the graphical way) but Pjotr shows you what to do in his web.

In other hand Ubuntu's bugs reported you've linked are for a separated /boot partition and using unattended-upgrades .The problem is when filling that partition because of default /boot partition size. Autoremove do not uninstall old kernels in Mint (or Ubuntu, I think). Only a couple of packages are replaced and proposed to be auto-removed when installing a new kernel not the kernel itself. There is no purge-old-kernels included in any packages pre-installed in Mint. Any way such tools (as BleachBit) are not recommended.

(edited)

Re: purge-old-kernels removed in 19, autoremove not working

Posted: Thu Sep 13, 2018 5:06 am
by Pjotr
JOPETA wrote:
Thu Sep 13, 2018 4:15 am
Pjotr shows you what to do on his website.
Yes, that kernel removal script still works fine. :)
JOPETA wrote:
Thu Sep 13, 2018 4:15 am
Any way such tools (as BleachBit) are not recommended.
I can't stress that fact enough.... Don't use software wrecking balls like BleachBit.

Re: purge-old-kernels removed in 19, autoremove not working

Posted: Thu Sep 13, 2018 5:37 am
by gm10
Kudalufi wrote:
Wed Sep 12, 2018 8:10 pm
In Mint 19 the purge-old-kernels script, which was a fantastic way of pruning old kernels, was replaced and is basically just an alias now for apt-get autoremove. However, I am finding on my Mint 19 installation, that apt-get autoremove still completely fails to remove old kernels.

The purge-old-kernels script suggests reporting ongoing issues with apt-get autoremove not removing kernels to Ubuntu's apt bug list, but the bug associated with that was marked fixed and closed back in April.

Is this a left over artifact of my installation being one that was upgraded from 18, a mint-ism, or something that truly is wrong with apt? Are other mint users having this issue?
Yes, it's an artifact. autoremove is specifically being blocked in Ubuntu from removing kernels. Ubuntu's apt version installs the script /etc/kernel/postinst.d/apt-auto-removal that ensures that you can never auto-remove them, even if you have them flagged as automatically installed (something that the Mint Update Manager does not necessarily do, anyway).

This "beautiful" one-liner will remove all your old kernels if you answer y when you run it:

Code: Select all

dpkg-query -W -f '${Version}\n' 'linux-image-[^g]*'|sort -u|sed -e '/^$/d' -e 's/\~[^~]*$//' -e 's/\.[^.]*$//' -e "/$(uname -r|sed 's/-generic//')/d" -e 's/.*/linux-*-&*/'|tr '\n' ' '|xargs -pr sudo apt-get remove --purge -y
I had posted a version that runs automatically every week here: viewtopic.php?f=47&t=275659&p=1514402#p1514402

Re: purge-old-kernels removed in 19, autoremove not working

Posted: Thu Sep 13, 2018 5:38 am
by Pierre
if don't have that script handy,
& you are still using an UN-modified version of the Boot Menu:
- you can select the Advanced Rescue option, from that Boot Menu
there is one for each Kernel . .
then select the Clean Option, from the GUI that then becomes available:
- this will remove some of those older kernels for you.

finally, just re-start your machine, as normal.
- this option is also good when you get that "Disk Full" or that "Disk is Nearly Full" error.
8)

Re: purge-old-kernels removed in 19, autoremove not working

Posted: Tue Sep 18, 2018 9:06 pm
by Kudalufi
DAMIEN1307 wrote:
Wed Sep 12, 2018 8:41 pm
i had to read this three or four times to figure out just what you were asking...first off, apt-get autoremove AKA sudo apt autoremove is not a kernel remover
I'm not an apt guru. What I know is this. There is a purge-old-kernels script as part of the byobu package. It worked fantastic - it would always remove all but the last N kernels, where N you could set. If you google removing old kernels, it is mentioned in several threads and blog entries. Unfortunately it was "updated" as part of Ubuntu 18.04 to remove all its functionality, and now just calls apt-get autoremove. Here are the comments now in the purge-old-kernels script:

# apt autoremove supposedly works correctly now.
#
# Thus, we're deprecating the functionality previously found
# in purge-old-kernels.
#
# If you still have old kernels lying around after this, please
# file a bug against apt: https://bugs.launchpad.net/ubuntu/+source/apt/+filebug

And it then proceeds to simply call apt-get autoremove.

If, as people suggest, apt-get autoremove isn't the way forward for removing old kernels, then perhaps Mint can bring back the old purge-old-kernels script, because it was fantastic one-stop-shopping. Getting into the weeds with:

Code: Select all

dpkg-query -W -f '${Version}\n' 'linux-image-[^g]*'|sort -u|sed -e '/^$/d' -e 's/\~[^~]*$//' -e 's/\.[^.]*$//' -e "/$(uname -r|sed 's/-generic//')/d" -e 's/.*/linux-*-&*/'|tr '\n' ' '|xargs -pr sudo apt-get remove --purge -y
Just to make room in /boot is ludicrous. Ten years ago I'd have loved it, and patted myself on the back for my ingenuity. But 10 years ago I got into the weeds for a living. Today I really just want it to work - as in if it's as complex as above, then it should be in a script that should be an apt-get away, like it was with purge-old-kernels before.

Re: purge-old-kernels removed in 19, autoremove not working

Posted: Tue Sep 18, 2018 9:41 pm
by MrEen
I believe that when byobu dropped this feature, that's when Pjotr picked up this one piece of it.

I've used it. It works. Go get it! Link is up there somewhere ^^^^^^ (And here as well)

Re: purge-old-kernels removed in 19, autoremove not working

Posted: Tue Nov 20, 2018 5:35 pm
by RR245
Kudalufi wrote:
Wed Sep 12, 2018 8:10 pm
The purge-old-kernels script suggests reporting ongoing issues with apt-get autoremove not removing kernels to Ubuntu's apt bug list, but the bug associated with that was marked fixed and closed back in April.
But this bugreport is about the package unattended-upgrades :shock: That's something completely different. And furthermore the very special case »when /boot partition gets full«. :roll:

I prefer a script (found in a german forum; but it is also in english) which let me select the kernels I want to purge
https://www.linuxmintusers.de/index.php?topic=46778

Re: purge-old-kernels removed in 19, autoremove not working

Posted: Tue Nov 20, 2018 10:42 pm
by sleeper12
I use ucaresystem-core on Mint 18 and it works well. Not sure about Mint 19, but might be worth a try:
https://www.linux.com/learn/intro-to-li ... ystem-core

Re: purge-old-kernels removed in 19, autoremove not working

Posted: Sun Dec 09, 2018 9:22 pm
by Kudalufi
Actually, apt-get autoremove does work to remove old kernels. The problem was that it wouldn't automatically remove any kernels which had been installed prior to the Mint 19 upgrade. Once enough kernel upgrades were performed post upgrade that all the pre-upgrade kernels were gone (manually removed), then apt-get autoremove began to work automatically to remove old kernels. It's actually quite nice, seeing as my /boot folder is quite limited in size.

Re: purge-old-kernels removed in 19, autoremove not working

Posted: Mon Dec 10, 2018 5:43 am
by gm10
Kudalufi wrote:
Sun Dec 09, 2018 9:22 pm
Actually, apt-get autoremove does work to remove old kernels. The problem was that it wouldn't automatically remove any kernels which had been installed prior to the Mint 19 upgrade. Once enough kernel upgrades were performed post upgrade that all the pre-upgrade kernels were gone (manually removed), then apt-get autoremove began to work automatically to remove old kernels. It's actually quite nice, seeing as my /boot folder is quite limited in size.
Depends how you install them, it will only remove those that were automatically updated via the kernel meta package. I patched up Update Manager for LM 19.1 to make that the default procedure now. That also means that you won't automatically get upgraded to HWE kernels anymore without asking for it. Kernels you manually installed via Update Manager > View > Linux kernels (or any other way) still won't get autoremoved.