🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.debian.user
23 messages
23 total messages Started by Charles Curley Sun, 15 Nov 2026 00:10
APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#508
Author: Charles Curley
Date: Sun, 15 Nov 2026 00:10
34 lines
4081 bytes
On trixie, with apt version "apt 3.0.4 (amd64)", the setting

APT::NeverAutoRemove::KernelCount "3";

isn't quite working: during automatic upgrades, I get more than three
kernels.

As near as I can figure this setting should give me three kernel
packages installed, instead of the default two. However, I now have
five on test machines.

According to /usr/share/doc/apt/examples/configure-index,

    NeverAutoRemove::KernelCount "<INT>"; // Keep the configured amount
    of kernels

"man apt.conf" says, in part,

    NeverAutoRemove::KernelCount
        Keep a custom amount of kernels when autoremoving and defaults
        to 2, meaning two kernels are kept. Apt will always keep the
        running kernel and the latest one. If the latest kernel is the
        same as the running kernel, the second latest kernel is kept.
        Because of this, any value lower than 2 will be ignored. If you
        want only the latest kernel, you should set
        APT::Protect-Kernels to false.

Did I do something wrong or did I find a bug?

-- 
Does anybody read signatures any more?

https://charlescurley.com
https://charlescurley.com/blog/
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#510
Author: Greg Wooledge
Date: Sun, 15 Nov 2026 03:00
16 lines
2180 bytes
On Sat, Nov 14, 2026 at 17:01:42 -0700, Charles Curley wrote:
> On trixie, with apt version "apt 3.0.4 (amd64)", the setting
> 
> APT::NeverAutoRemove::KernelCount "3";
> 
> isn't quite working: during automatic upgrades, I get more than three
> kernels.
> 
> As near as I can figure this setting should give me three kernel
> packages installed, instead of the default two. However, I now have
> five on test machines.

Are you running apt autoremove?

The setting you're looking at affects autoremove.  It doesn't *trigger*
an autoremove.  You still need to run it yourself.
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#512
Author: Charles Curley
Date: Sun, 15 Nov 2026 05:10
41 lines
4686 bytes
On Sat, 14 Nov 2026 21:51:35 -0500
Greg Wooledge <greg@wooledge.org> wrote:

> > As near as I can figure this setting should give me three kernel
> > packages installed, instead of the default two. However, I now have
> > five on test machines.  
> 
> Are you running apt autoremove?
> 
> The setting you're looking at affects autoremove.  It doesn't
> *trigger* an autoremove.  You still need to run it yourself.

Now you have me mystified. If I don't set
APT::NeverAutoRemove::KernelCount then upgrades automatically install a
new kernel. (I have linux-image-amd64 installed.) They also remove an
old one, leaving me with the default net two kernels.

I don't think I have ever run "apt autoremove". I just did so on a
machine with five kernels installed; none were removed.

"man apt" says,

    autoremove is used to remove packages that were automatically
    installed to satisfy dependencies for other packages and are now no
    longer needed as dependencies changed or the package(s) needing
    them were removed in the meantime.

The current linux-image-amd64 depends on
linux-image-6.12.117+deb13-amd64. So if autoremove worked on kernels,
should it have removed all the kernels except
linux-image-6.12.117+deb13-amd64? Maybe it makes an exception for
kernels?

(And I am well aware of the dangers of believing the documentation
uncritically.)

-- 
Does anybody read signatures any more?

https://charlescurley.com
https://charlescurley.com/blog/
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#514
Author: Greg Wooledge
Date: Sun, 15 Nov 2026 13:50
55 lines
3900 bytes
On Sat, Nov 14, 2026 at 22:05:35 -0700, Charles Curley wrote:
> On Sat, 14 Nov 2026 21:51:35 -0500
> Greg Wooledge <greg@wooledge.org> wrote:
> > The setting you're looking at affects autoremove.  It doesn't
> > *trigger* an autoremove.  You still need to run it yourself.
> 
> Now you have me mystified. If I don't set
> APT::NeverAutoRemove::KernelCount then upgrades automatically install a
> new kernel. (I have linux-image-amd64 installed.) They also remove an
> old one, leaving me with the default net two kernels.
> 
> I don't think I have ever run "apt autoremove". I just did so on a
> machine with five kernels installed; none were removed.

Hmm.  Maybe it's a difference between apt-get and apt, then?  I usually
use apt-get, and it definitely doesn't do an autoremove for me.


hobbit:~$ apt-get -s upgrade
NOTE: This is only a simulation!
[...]
The following packages were automatically installed and are no longer required:
  enchant-2 ghp-import gir1.2-gtk-2.0 girepository-tools gsfonts gsfonts-x11
  [...]
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.


I don't do autoremoves on that system.  On others where I do use it, it
has always (so far) kept only the 2 latest kernels, as expected.

> The current linux-image-amd64 depends on
> linux-image-6.12.117+deb13-amd64. So if autoremove worked on kernels,
> should it have removed all the kernels except
> linux-image-6.12.117+deb13-amd64? Maybe it makes an exception for
> kernels?

Well... there's /etc/apt/apt.conf.d/01autoremove which contains

  NeverAutoRemove
  {
        "^firmware-linux.*";
        "^linux-firmware$";
        "^linux-image-[a-z0-9]*$";
        "^linux-image-[a-z0-9]*-[a-z0-9]*$";
  };

So if you've got custom kernels whose package names match one of those
regexes, they're untouchable.

If your kernels are from Debian (and therefore don't match any of those
regexes), then they should be counted by the KernelCount variable as far
as I'm aware.

How *exactly* did you configure this variable?
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#516
Author: Vincent Lefevre
Date: Sun, 15 Nov 2026 14:30
21 lines
3008 bytes
On 2026-11-15 08:42:23 -0500, Greg Wooledge wrote:
> On Sat, Nov 14, 2026 at 22:05:35 -0700, Charles Curley wrote:
> > Now you have me mystified. If I don't set
> > APT::NeverAutoRemove::KernelCount then upgrades automatically install a
> > new kernel. (I have linux-image-amd64 installed.) They also remove an
> > old one, leaving me with the default net two kernels.
> > 
> > I don't think I have ever run "apt autoremove". I just did so on a
> > machine with five kernels installed; none were removed.
> 
> Hmm.  Maybe it's a difference between apt-get and apt, then?

There are some differences, but not for autoremove. They just
propose to autoremove packages when some are concerned. There
is a difference with aptitude, which autoremoves packages by
default, but Charles didn't mention aptitude.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#517
Author: Charles Curley
Date: Sun, 15 Nov 2026 15:30
13 lines
3828 bytes
On Sun, 15 Nov 2026 15:26:35 +0100
Vincent Lefevre <vincent@vinc17.net> wrote:

> There is a difference with aptitude, which autoremoves packages by
> default, but Charles didn't mention aptitude.

Right. I don't use aptitude. Just apt.

-- 
Does anybody read signatures any more?

https://charlescurley.com
https://charlescurley.com/blog/
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#518
Author: Charles Curley
Date: Sun, 15 Nov 2026 15:50
90 lines
6125 bytes
On Sun, 15 Nov 2026 08:42:23 -0500
Greg Wooledge <greg@wooledge.org> wrote:

> > I don't think I have ever run "apt autoremove". I just did so on a
> > machine with five kernels installed; none were removed.  
> 
> Hmm.  Maybe it's a difference between apt-get and apt, then?  I
> usually use apt-get, and it definitely doesn't do an autoremove for
> me.
> 
> 
> hobbit:~$ apt-get -s upgrade
> NOTE: This is only a simulation!
> [...]
> The following packages were automatically installed and are no longer
> required: enchant-2 ghp-import gir1.2-gtk-2.0 girepository-tools
> gsfonts gsfonts-x11 [...]
> Use 'apt autoremove' to remove them.
> 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
> 
> 
> I don't do autoremoves on that system.  On others where I do use it,
> it has always (so far) kept only the 2 latest kernels, as expected.

root@peregrine:~# pre ux-im ; uname -r
linux-image-6.12.111+deb13-amd64	6.12.111-1		amd64
linux-image-6.12.113+deb13-amd64	6.12.113-1		amd64
linux-image-6.12.115+deb13.1-amd64	6.12.115-2		amd64
linux-image-6.12.116+deb13-amd64	6.12.116-1		amd64
linux-image-6.12.117+deb13-amd64	6.12.117-1		amd64
linux-image-amd64	6.12.117-1		amd64
6.12.117+deb13-amd64
root@peregrine:~# apt-get -s upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@peregrine:~# apt-get -s autoremove 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@peregrine:~# 




> 
> > The current linux-image-amd64 depends on
> > linux-image-6.12.117+deb13-amd64. So if autoremove worked on
> > kernels, should it have removed all the kernels except
> > linux-image-6.12.117+deb13-amd64? Maybe it makes an exception for
> > kernels?  
> 
> Well... there's /etc/apt/apt.conf.d/01autoremove which contains
> 
>   NeverAutoRemove
>   {
>         "^firmware-linux.*";
>         "^linux-firmware$";
>         "^linux-image-[a-z0-9]*$";
>         "^linux-image-[a-z0-9]*-[a-z0-9]*$";
>   };
> 
> So if you've got custom kernels whose package names match one of those
> regexes, they're untouchable.
> 
> If your kernels are from Debian (and therefore don't match any of
> those regexes), then they should be counted by the KernelCount
> variable as far as I'm aware.

No custom kernels here. Nor have I mucked with NeverAutoRemove.

> 
> How *exactly* did you configure this variable?

root@peregrine:/etc/apt/apt.conf.d# cat 40neverAutoRemove
# man apt.conf; less /usr/share/doc/apt/examples/configure-index

APT::NeverAutoRemove::KernelCount "3";
root@peregrine:/etc/apt/apt.conf.d# 



-- 
Does anybody read signatures any more?

https://charlescurley.com
https://charlescurley.com/blog/
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#519
Author: CGS
Date: Sun, 15 Nov 2026 16:10
25 lines
2825 bytes
On 2026-11-15, Charles Curley <charlescurley@charlescurley.com> wrote:

> root@peregrine:~# apt-get -s autoremove 

You don't need to be root to simulate

> Reading package lists... Done
> Building dependency tree... Done
> Reading state information... Done
> 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
> root@peregrine:~# 
>

cgs@schrodinger:~$ apt -s autoremove
NOTE: This is only a simulation!
      apt needs root privileges for real execution.
      Keep also in mind that locking is deactivated,
      so don't depend on the relevance to the real current situation!
 
REMOVING:                       
  linux-image-6.12.115+deb13.1-amd64
 
Summary:
  Upgrading: 0, Installing: 0, Removing: 1, Not Upgrading: 0
Remv linux-image-6.12.115+deb13.1-amd64 [6.12.115-2]
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#525
Author: David Wright
Date: Sun, 15 Nov 2026 18:10
52 lines
5963 bytes
On Sun 15 Nov 2026 at 08:43:23 (-0700), Charles Curley wrote:
> On Sun, 15 Nov 2026 08:42:23 -0500
> Greg Wooledge <greg@wooledge.org> wrote:
> 
> > > I don't think I have ever run "apt autoremove". I just did so on a
> > > machine with five kernels installed; none were removed.  
> > 
> > Hmm.  Maybe it's a difference between apt-get and apt, then?  I
> > usually use apt-get, and it definitely doesn't do an autoremove for
> > me.
> > 
> > 
> > hobbit:~$ apt-get -s upgrade
> > NOTE: This is only a simulation!
> > [...]
> > The following packages were automatically installed and are no longer
> > required: enchant-2 ghp-import gir1.2-gtk-2.0 girepository-tools
> > gsfonts gsfonts-x11 [...]
> > Use 'apt autoremove' to remove them.
> > 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
> > 
> > 
> > I don't do autoremoves on that system.  On others where I do use it,
> > it has always (so far) kept only the 2 latest kernels, as expected.
> 
> root@peregrine:~# pre ux-im ; uname -r
> linux-image-6.12.111+deb13-amd64	6.12.111-1		amd64
> linux-image-6.12.113+deb13-amd64	6.12.113-1		amd64
> linux-image-6.12.115+deb13.1-amd64	6.12.115-2		amd64
> linux-image-6.12.116+deb13-amd64	6.12.116-1		amd64
> linux-image-6.12.117+deb13-amd64	6.12.117-1		amd64
> linux-image-amd64	6.12.117-1		amd64
> 6.12.117+deb13-amd64
> root@peregrine:~# apt-get -s upgrade
> Reading package lists... Done
> Building dependency tree... Done
> Reading state information... Done
> Calculating upgrade... Done
> 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
> root@peregrine:~# apt-get -s autoremove 
> Reading package lists... Done
> Building dependency tree... Done
> Reading state information... Done
> 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
> root@peregrine:~# 

I don't understand this output. I'd prefer to see the output from:
 $ dpkg -l | grep linux-image
 $ apt-get -s --purge autoremove

Cheers,
David.
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#526
Author: Charles Curley
Date: Sun, 15 Nov 2026 18:50
37 lines
5703 bytes
On Sun, 15 Nov 2026 12:08:28 -0600
David Wright <deblis@lionunicorn.co.uk> wrote:

> I don't understand this output. I'd prefer to see the output from:
>  $ dpkg -l | grep linux-image
>  $ apt-get -s --purge autoremove

(May wrap egregiously, but should show correctly in a large enough
window.)

root@peregrine:~# dpkg -l | grep linux-image
ii  linux-image-6.12.111+deb13-amd64                    6.12.111-1                            amd64        Linux 6.12 for 64-bit PCs (signed)
ii  linux-image-6.12.113+deb13-amd64                    6.12.113-1                            amd64        Linux 6.12 for 64-bit PCs (signed)
ii  linux-image-6.12.115+deb13.1-amd64                  6.12.115-2                            amd64        Linux 6.12 for 64-bit PCs (signed)
ii  linux-image-6.12.116+deb13-amd64                    6.12.116-1                            amd64        Linux 6.12 for 64-bit PCs (signed)
ii  linux-image-6.12.117+deb13-amd64                    6.12.117-1                            amd64        Linux 6.12 for 64-bit PCs (signed)
ii  linux-image-amd64                                   6.12.117-1                            amd64        Linux for 64-bit PCs (meta-package)
root@peregrine:~# apt-get -s --purge autoremove
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@peregrine:~# dpkg -l | grep linux-image
ii  linux-image-6.12.111+deb13-amd64                    6.12.111-1                            amd64        Linux 6.12 for 64-bit PCs (signed)
ii  linux-image-6.12.113+deb13-amd64                    6.12.113-1                            amd64        Linux 6.12 for 64-bit PCs (signed)
ii  linux-image-6.12.115+deb13.1-amd64                  6.12.115-2                            amd64        Linux 6.12 for 64-bit PCs (signed)
ii  linux-image-6.12.116+deb13-amd64                    6.12.116-1                            amd64        Linux 6.12 for 64-bit PCs (signed)
ii  linux-image-6.12.117+deb13-amd64                    6.12.117-1                            amd64        Linux 6.12 for 64-bit PCs (signed)
ii  linux-image-amd64                                   6.12.117-1                            amd64        Linux for 64-bit PCs (meta-package)
root@peregrine:~# 


-- 
Does anybody read signatures any more?

https://charlescurley.com
https://charlescurley.com/blog/
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#529
Author: David Wright
Date: Sun, 15 Nov 2026 19:40
32 lines
5774 bytes
On Sun 15 Nov 2026 at 11:41:53 (-0700), Charles Curley wrote:
> On Sun, 15 Nov 2026 12:08:28 -0600
> David Wright <deblis@lionunicorn.co.uk> wrote:
> 
> > I don't understand this output. I'd prefer to see the output from:
> >  $ dpkg -l | grep linux-image
> >  $ apt-get -s --purge autoremove

[ … ]

> root@peregrine:~# apt-get -s --purge autoremove
> Reading package lists... Done
> Building dependency tree... Done
> Reading state information... Done
> 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
> root@peregrine:~# dpkg -l | grep linux-image
> ii  linux-image-6.12.111+deb13-amd64                    6.12.111-1                            amd64        Linux 6.12 for 64-bit PCs (signed)
> ii  linux-image-6.12.113+deb13-amd64                    6.12.113-1                            amd64        Linux 6.12 for 64-bit PCs (signed)
> ii  linux-image-6.12.115+deb13.1-amd64                  6.12.115-2                            amd64        Linux 6.12 for 64-bit PCs (signed)
> ii  linux-image-6.12.116+deb13-amd64                    6.12.116-1                            amd64        Linux 6.12 for 64-bit PCs (signed)
> ii  linux-image-6.12.117+deb13-amd64                    6.12.117-1                            amd64        Linux 6.12 for 64-bit PCs (signed)
> ii  linux-image-amd64                                   6.12.117-1                            amd64        Linux for 64-bit PCs (meta-package)
> root@peregrine:~# 

I guess we ought to check that this gives one yes and the rest no:

$ apt show linux-image-*amd64 | grep APT-Manual-Installed

before more careful scrutiny of APT's configuration.

Cheers,
David.
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#530
Author: charlescurley
Date: Sun, 15 Nov 2026 22:20
28 lines
4828 bytes
On 2026-11-15 13:30, David Wright wrote:
> On Sun 15 Nov 2026 at 11:41:53 (-0700), Charles Curley wrote:

...

> 
> I guess we ought to check that this gives one yes and the rest no:
> 
> $ apt show linux-image-*amd64 | grep APT-Manual-Installed
> 
> before more careful scrutiny of APT's configuration.
> 
> Cheers,
> David.

root@peregrine:~# apt show linux-image-*amd64 | grep 
APT-Manual-Installed

WARNING: apt does not have a stable CLI interface. Use with caution in 
scripts.

APT-Manual-Installed: yes
APT-Manual-Installed: no
APT-Manual-Installed: no
APT-Manual-Installed: no
APT-Manual-Installed: no
APT-Manual-Installed: no
root@peregrine:~#
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#539
Author: Vincent Lefevre
Date: Mon, 16 Nov 2026 11:40
20 lines
2906 bytes
On 2026-11-15 11:41:53 -0700, Charles Curley wrote:
> root@peregrine:~# apt-get -s --purge autoremove
> Reading package lists... Done
> Building dependency tree... Done
> Reading state information... Done
> 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

If you remove your

  APT::NeverAutoRemove::KernelCount "3";

setting, does this change anything?

I'm wondering whether APT::NeverAutoRemove::KernelCount is buggy
when explicitly set to any value.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#554
Author: charlescurley
Date: Mon, 16 Nov 2026 17:00
32 lines
5141 bytes
On 2026-11-16 05:30, Vincent Lefevre wrote:
> On 2026-11-15 11:41:53 -0700, Charles Curley wrote:
>> root@peregrine:~# apt-get -s --purge autoremove
>> Reading package lists... Done
>> Building dependency tree... Done
>> Reading state information... Done
>> 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
> 
> If you remove your
> 
>   APT::NeverAutoRemove::KernelCount "3";
> 
> setting, does this change anything?
> 
> I'm wondering whether APT::NeverAutoRemove::KernelCount is buggy
> when explicitly set to any value.

If I remove it, I get:

root@peregrine:~# apt -s upgrade

The following packages were automatically installed and are no longer 
required:
   linux-image-6.12.111+deb13-amd64  linux-image-6.12.113+deb13-amd64  
linux-image-6.12.115+deb13.1-amd64
Use 'apt autoremove' to remove them.

Summary:
   Upgrading: 0, Installing: 0, Removing: 0, Not Upgrading: 0
root@peregrine:~#

As I have five kernels on that machine, that looks reasonable to me.
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#557
Author: David Wright
Date: Mon, 16 Nov 2026 20:00
43 lines
5958 bytes
On Mon 16 Nov 2026 at 10:21:46 (-0600), charlescurley@charlescurley.com wrote:
> On 2026-11-16 05:30, Vincent Lefevre wrote:
> > On 2026-11-15 11:41:53 -0700, Charles Curley wrote:
> > > root@peregrine:~# apt-get -s --purge autoremove
> > > Reading package lists... Done
> > > Building dependency tree... Done
> > > Reading state information... Done
> > > 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
> > 
> > If you remove your
> > 
> >   APT::NeverAutoRemove::KernelCount "3";
> > 
> > setting, does this change anything?
> > 
> > I'm wondering whether APT::NeverAutoRemove::KernelCount is buggy
> > when explicitly set to any value.
> 
> If I remove it, I get:
> 
> root@peregrine:~# apt -s upgrade
> 
> The following packages were automatically installed and are no longer
> required:
>   linux-image-6.12.111+deb13-amd64  linux-image-6.12.113+deb13-amd64
> linux-image-6.12.115+deb13.1-amd64
> Use 'apt autoremove' to remove them.
> 
> Summary:
>   Upgrading: 0, Installing: 0, Removing: 0, Not Upgrading: 0
> root@peregrine:~#
> 
> As I have five kernels on that machine, that looks reasonable to me.

Yes, but that's just testing the default regime that most people here
probably run under: the two most recent kernels are left installed.

It would be more realistic to try out Vincent's suggestion by
testing with APT::NeverAutoRemove::KernelCount "N"; where N=0…6
in turn.

Cheers,
David.
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#563
Author: Vincent Lefevre
Date: Tue, 17 Nov 2026 03:20
50 lines
3922 bytes
On 2026-11-16 13:58:11 -0600, David Wright wrote:
> It would be more realistic to try out Vincent's suggestion by
> testing with APT::NeverAutoRemove::KernelCount "N"; where N=0…6
> in turn.

Yes. And the current code (3.3.7) in apt-pkg/algorithms.cc is

   auto keepKernels = (unsigned long)_config->FindI("APT::NeverAutoRemove::KernelCount", 2);
   if (keepKernels < 2)
      keepKernels = 2;

   if (Debug)
      std::clog << "Amount of kernels to keep " << keepKernels << std::endl;

   if (not bootedVersion.empty())
   {
      if (Debug)
         std::clog << "Keeping booted kernel " << bootedVersion << std::endl;
      keep.insert(bootedVersion);
   }

   while (keep.size() < keepKernels && versions != version2unames.rend())
   {
      auto v = versions->first;
      if (v == bootedVersion)
      {
         versions++;
         continue;
      }
      if (Debug)
         std::clog << "Keeping previous kernel " << v << std::endl;
      keep.insert(v);
      versions++;
   }

So it can output debug information. It would be interesting to get it.
If this loop outputs unexpected "Keeping previous kernel" lines, then
the bug is there. If not...

Later in the code:

   if (Debug)
      std::clog << "Kernel protection regex: " << re << "\n";

See whether the constructed regex is correct.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#564
Author: Vincent Lefevre
Date: Tue, 17 Nov 2026 03:40
28 lines
3414 bytes
On 2026-11-17 04:18:55 +0100, Vincent Lefevre wrote:
> On 2026-11-16 13:58:11 -0600, David Wright wrote:
> > It would be more realistic to try out Vincent's suggestion by
> > testing with APT::NeverAutoRemove::KernelCount "N"; where N=0…6
> > in turn.
> 
> Yes. And the current code (3.3.7) in apt-pkg/algorithms.cc is
[...]

No need to do any test: Mistral AI found a bug when I asked to
look at this discussion, starting at

  https://lists.debian.org/debian-user/2026/11/msg00232.html

It says that there is a configuration namespace collision:
APT::NeverAutoRemove is simultaneously a scalar option scope
(holding KernelCount) and a list of regexes that protects packages
from autoremove. Setting KernelCount "3" injects the string 3 into
that regex list.

Full information:

  https://chat.mistral.ai/work/80af5892-0370-4bff-8748-652e0fe6666c

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#567
Author: Greg Wooledge
Date: Tue, 17 Nov 2026 04:00
18 lines
2967 bytes
On Tue, Nov 17, 2026 at 04:34:48 +0100, Vincent Lefevre wrote:
> No need to do any test: Mistral AI found a bug when I asked to
> look at this discussion, starting at
> 
>   https://lists.debian.org/debian-user/2026/11/msg00232.html
> 
> It says that there is a configuration namespace collision:
> APT::NeverAutoRemove is simultaneously a scalar option scope
> (holding KernelCount) and a list of regexes that protects packages
> from autoremove. Setting KernelCount "3" injects the string 3 into
> that regex list.

Amusing.  Of course, all Trixie kernels have a "3" in their version
strings (from the "deb13" bit), so they all match the NeverAutoRemove
regex.

You might want to add a note about this discover to
<https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1145185>
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#568
Author: David Wright
Date: Tue, 17 Nov 2026 05:10
18 lines
5312 bytes
On Mon 16 Nov 2026 at 23:24:43 (-0500), Jeffrey Walton wrote:
> 
> Wandering a little off-topic... The thread piqued my interest because
> I run both a standard kernel and HWE kernel on Ubuntu.  It allows me
> to run, say, a 6.x kernel most of the time, and drop back to a 5.x
> kernel when things break.*  Under Ubuntu, the packages are:
> 
>    * Standard - linux-image-generic linux-headers-generic
>    * HWE - linux-headers-generic-hwe-24.04 linux-image-generic-hwe-24.04
> 
> So the question in my mind is, which kernels are removed when kernels
> from different lines are present?

I presume that you installed HWE manually, in which case I think it's
unaffected by autoremove. Is that so?

Cheers,
David.
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#569
Author: Vincent Lefevre
Date: Tue, 17 Nov 2026 05:20
12 lines
2847 bytes
On 2026-11-16 22:53:18 -0500, Greg Wooledge wrote:
> You might want to add a note about this discover to
> <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1145185>

Done. This also explains the behavior noticed by the bug reporter
(the kernels 7.0.13-1 and 7.1.3-1 are not removed due to the "3"
in the regex list).

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#573
Author: CGS
Date: Tue, 17 Nov 2026 15:40
5 lines
2622 bytes
On 2026-11-17, Vincent Lefevre <vincent@vinc17.net> wrote:
>
>  Mistral AI

LOL.
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#577
Author: Vincent Lefevre
Date: Tue, 17 Nov 2026 23:40
23 lines
3434 bytes
On 2026-11-17 20:02:54 +0100, Franco Martelli wrote:
> On 17/11/26 at 06:10, Vincent Lefevre wrote:
> > On 2026-11-16 22:53:18 -0500, Greg Wooledge wrote:
> > > You might want to add a note about this discover to
> > > <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1145185>
> > 
> > Done. This also explains the behavior noticed by the bug reporter
> > (the kernels 7.0.13-1 and 7.1.3-1 are not removed due to the "3"
> > in the regex list).
> 
> I didn't find yet anything about the Greg's note in the BTS page. When did
> you add that?

See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1145185#10
(note that this bug was for testing/unstable, but once you know
that the APT::NeverAutoRemove::KernelCount value is injected in
the regex list, you know which kernels will be always protected
because of that).

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)
Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels
#578
Author: Charles Curley
Date: Wed, 18 Nov 2026 00:10
13 lines
4207 bytes
On Wed, 18 Nov 2026 00:34:02 +0100
Vincent Lefevre <vincent@vinc17.net> wrote:

> (note that this bug was for testing/unstable,

I am also seeing this on trixie. I'll add a note to that effect to the
bug shortly.

-- 
Does anybody read signatures any more?

https://charlescurley.com
https://charlescurley.com/blog/
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads