• Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get mo

    From Charles Curley@3:633/10 to All on Sunday, November 15, 2026 06:10:01
    Subject: Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels

    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/

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Charles Curley@3:633/10 to All on Sunday, November 15, 2026 16:30:01
    Subject: Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels

    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/

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Charles Curley@3:633/10 to All on Sunday, November 15, 2026 16:50:04
    Subject: Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels

    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/

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Charles Curley@3:633/10 to All on Sunday, November 15, 2026 19:50:01
    Subject: Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels

    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/

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Charles Curley@3:633/10 to All on Wednesday, November 18, 2026 01:10:01
    Subject: Re: APT::NeverAutoRemove::KernelCount "3"; Not quite working: I get more than three kernels

    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/

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)