Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: Kernel and autoremove  (Read 1808 times)

Offline cliff6056

  • User
  • Posts: 20
Kernel and autoremove
« on: 2021/03/26, 01:10:36 »
At some point in the New Year following a full-upgrade, my system ceased to  autoremove the oldest kernel.  It  now wants to  remove the running kernel, which I deny.  Following a reboot into the newly installed kernel, nothing is  to be removed. 

My update procedure previous was
Code: [Select]
apt update && apt full-upgrade && apt autoremove && rebootIn one of my backups I find the behavior I believe I used to have.  This under
Code: [Select]
apt kernel postinst.d apt-auto-removal
and is

Code: [Select]
#!/bin/sh
set -e
# Mark as not-for-autoremoval those kernel packages that are:
#  - the currently booted version
#  - the kernel version we've been called for
#  - the latest kernel version (as determined by debian version number)
#  - the second-latest kernel version
#
# In the common case this results in two kernels saved (booted into the
# second-latest kernel, we install the latest kernel in an upgrade), but
# can save up to four. Kernel refers here to a distinct release, which can
# potentially be installed in multiple flavours counting as one kernel.
I do  not find this in my current running system.  Has the procedure changed?  I did come across a thread under Upgrade Warnings that I thought was directly related to this, but the addition of the apt-config-siduction file which spawned the "80siduction"  did not change things for me.

So  if this is the expected behavior, I will  remove the kernels manually.   

Thoughts appreciated.
Cliff



Offline sunrat

  • User
  • Posts: 404
Re: Kernel and autoremove
« Reply #1 on: 2021/03/26, 12:12:37 »
Boot into the new kernel before running apt autoremove. Here it offers to keep the current latest kernel and the second latest, as expected.
That script you mentioned should be at /etc/kernel/postinst.d/apt-auto-removal

Offline devil

  • Administrator
  • User
  • *****
  • Posts: 4.579
Re: Kernel and autoremove
« Reply #2 on: 2021/03/26, 13:11:42 »
The recommended way to deal with kernels was always to run kernel-remover.

Offline gnasch

  • User
  • Posts: 45
Re: Kernel and autoremove
« Reply #3 on: 2021/03/26, 13:36:33 »
Is it possible to make autoremove leave the kernels alone?
I would like to keep my older versions like 5.8, 5.9, etc.
It does not help me when I find out on 5.11.6 that something does not
work since 5.10.
By now you have certainly remarked how attentive I am :-\.
Thanks!
gnasch

Offline cliff6056

  • User
  • Posts: 20
Re: Kernel and autoremove
« Reply #4 on: 2021/03/26, 15:19:31 »
Thanks for replies. 

sunrat - Thanks, however, when I upgrade and boot into the new kernel.  and then run autoremove, it finds nothing to remove.  And the script I mentioned was indeed found in etc/kernel/postinst.d/apt-auto-removal, however that is  from a backup of last December.  The current contents of that file is now
Code: [Select]
#!/bin/sh
set -e

eval $(apt-config shell APT_CONF_D Dir::Etc::parts/d)
test -n "${APT_CONF_D}" || APT_CONF_D="/etc/apt/apt.conf.d"
config_file="${APT_CONF_D}/01autoremove-kernels"

generateconfig() {
    cat <<EOF
// DO NOT EDIT! File autogenerated by $0
APT::LastInstalledKernel "$1";
EOF
}
generateconfig "$@" > "${config_file}.dpkg-new"
mv -f "${config_file}.dpkg-new" "$config_file"
chmod 444 "$config_file"
Is this different from yours?


devil - thanks for help now and in the past, guess kernel-remover is my new friend and that's how I will be doing it. 



Offline sedonix

  • User
  • Posts: 32
Re: Kernel and autoremove
« Reply #5 on: 2021/03/26, 21:19:05 »
Is it possible to make autoremove leave the kernels alone?
I would like to keep my older versions like 5.8, 5.9, etc.
It does not help me when I find out on 5.11.6 that something does not
work since 5.10.
By now you have certainly remarked how attentive I am :-\ .
Thanks!
gnasch
I don't know where it came from but autoremoving kernels is disabled here. You can have as many kernels of any versions as you like with a minimum of two. I would question why you are having problems with any particular kernel. I use only the siduction experimental kernels, now at 5.12.0-rc4, with almost no problems over the years.  Yes, you should always use the kernel-remover.

Offline sedonix

  • User
  • Posts: 32
Re: Kernel and autoremove
« Reply #6 on: 2021/03/27, 00:03:56 »
I knew I could find it! /etc/apt/conf.d. (01autoremove)

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

  VersionedKernelPackages
  {
    # kernels
    "linux-.*";
    "kfreebsd-.*";
    "gnumach-.*";
    # (out-of-tree) modules
    ".*-modules";
    ".*-kernel";
  };

  Never-MarkAuto-Sections
  {
    "metapackages";
    "contrib/metapackages";
    "non-free/metapackages";
    "restricted/metapackages";
    "universe/metapackages";
    "multiverse/metapackages";
  };

  Move-Autobit-Sections
  {
    "oldlibs";
    "contrib/oldlibs";
    "non-free/oldlibs";
    "restricted/oldlibs";
    "universe/oldlibs";
    "multiverse/oldlibs";
  };
};

And next to it: (01autoremove-kernels)
Keep this one.

Code: [Select]
// DO NOT EDIT! File autogenerated by /etc/kernel/postinst.d/apt-auto-removal
APT::LastInstalledKernel "5.12.0-rc4-siduction-amd64";

Offline harley-peter

  • User
  • Posts: 882
Re: Kernel and autoremove
« Reply #7 on: 2021/04/01, 10:09:54 »
Same scripts here but autoremove delete the old kernels here.

What must I change to prevent that apt-autoremove delete the kernels?

Offline gnasch

  • User
  • Posts: 45
Re: Kernel and autoremove
« Reply #8 on: 2021/04/01, 18:28:13 »
Happens here also with these scripts.
Same question.
Thanks and sorry for the bother ::)
gnasch

Offline towo

  • Global Moderator
  • User
  • *****
  • Posts: 2.510
Re: Kernel and autoremove
« Reply #9 on: 2021/04/01, 18:41:53 »
If siduction-scripts is installed, kernels should be prevented from removal.
Ich gehe nicht zum Karneval, ich verleihe nur manchmal mein Gesicht.

Offline gnasch

  • User
  • Posts: 45
Re: Kernel and autoremove
« Reply #10 on: 2021/04/01, 18:48:39 »
It would still like to delete kernels:


root@Nh364Mz:~# apt install --reinstall siduction-scripts
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libaom2 linux-headers-5.10.15-towo.1-siduction-amd64 linux-headers-5.10.20-towo.1-siduction-amd64
  linux-image-5.10.15-towo.1-siduction-amd64 linux-image-5.10.20-towo.1-siduction-amd64
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 51 not upgraded.
Need to get 30.6 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://packages.siduction.org/extra unstable/main amd64 siduction-scripts all 2018.1.2 [30.6 kB]
Fetched 30.6 kB in 1s (27.8 kB/s)                       
(Reading database ... 341433 files and directories currently installed.)
Preparing to unpack .../siduction-scripts_2018.1.2_all.deb ...
Unpacking siduction-scripts (2018.1.2) over (2018.1.2) ...
Setting up siduction-scripts (2018.1.2) ...
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for siduction-dynamic-dms (2016.01.31) ...
Scanning processes...                                                                                                           
Scanning candidates...                                                                                                           
Scanning processor microcode...                                                                                                 
Scanning linux images...                                                                                                         

Running kernel seems to be up-to-date.

The processor microcode seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.
root@Nh364Mz:~# apt dist-upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  libaom2 linux-headers-5.10.15-towo.1-siduction-amd64 linux-headers-5.10.20-towo.1-siduction-amd64
  linux-image-5.10.15-towo.1-siduction-amd64 linux-image-5.10.20-towo.1-siduction-amd64
Use 'apt autoremove' to remove them.
The following NEW packages will be installed:
  linux-headers-5.11.11-1-siduction-amd64 linux-image-5.11.11-1-siduction-amd64
The following packages have been kept back:
  firefox firefox-esr firefox-esr-l10n-de firefox-l10n-de firefox-l10n-en-gb firefox-l10n-fr firefox-l10n-pt-br
The following packages will be upgraded:
  dnsmasq-base firmware-amd-graphics firmware-atheros firmware-bnx2 firmware-bnx2x firmware-brcm80211 firmware-intelwimax
  firmware-iwlwifi firmware-libertas firmware-linux firmware-linux-nonfree firmware-misc-nonfree firmware-myricom
  firmware-netxen firmware-qlogic firmware-realtek firmware-ti-connectivity libcpupower1 libcrypt-dev libcrypt1
  libgnutls-openssl27 libgnutls30 libixml11 libkf5globalaccel-bin libkf5globalaccel-data libkf5globalaccel5
  libkf5globalaccelprivate5 libldb2 libmediainfo0v5 libssh2-1 libssl-dev libssl1.1 libupnp17 libzen0v5 linux-cpupower
  linux-headers-siduction-amd64 linux-image-siduction-amd64 linux-libc-dev netbase openssl python3-ldb python3-soupsieve teams
  whois
44 upgraded, 2 newly installed, 0 to remove and 7 not upgraded.
Need to get 219 MB of archives.
After this operation, 294 MB of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.

Offline towo

  • Global Moderator
  • User
  • *****
  • Posts: 2.510
Re: Kernel and autoremove
« Reply #11 on: 2021/04/01, 19:00:12 »
Sorry, it's apt-conf-siduction.
Ich gehe nicht zum Karneval, ich verleihe nur manchmal mein Gesicht.

Offline gnasch

  • User
  • Posts: 45
Re: Kernel and autoremove
« Reply #12 on: 2021/04/01, 19:04:41 »
yet still:

Code: [Select]
root@Nh364Mz:~# apt policy apt-conf-siduction
apt-conf-siduction:
  Installed: 0.5.1+nmu1
  Candidate: 0.5.1+nmu1
  Version table:
 *** 0.5.1+nmu1 500
        500 http://packages.siduction.org/extra unstable/main amd64 Packages
        100 /var/lib/dpkg/status
     0.5.0 500
        500 http://packages.siduction.org/fixes unstable/main amd64 Packages
root@Nh364Mz:~# apt install --reinstall apt-conf-siduction
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libaom2 linux-headers-5.10.15-towo.1-siduction-amd64 linux-headers-5.10.20-towo.1-siduction-amd64
  linux-image-5.10.15-towo.1-siduction-amd64 linux-image-5.10.20-towo.1-siduction-amd64
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 51 not upgraded.
Need to get 2’264 B of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://packages.siduction.org/extra unstable/main amd64 apt-conf-siduction all 0.5.1+nmu1 [2’264 B]
Fetched 2’264 B in 0s (29.4 kB/s)                 
(Reading database ... 341433 files and directories currently installed.)
Preparing to unpack .../apt-conf-siduction_0.5.1+nmu1_all.deb ...
Unpacking apt-conf-siduction (0.5.1+nmu1) over (0.5.1+nmu1) ...
Setting up apt-conf-siduction (0.5.1+nmu1) ...
Processing triggers for siduction-dynamic-dms (2016.01.31) ...
Scanning processes...                                                                                                           
Scanning candidates...                                                                                                           
Scanning processor microcode...                                                                                                 
Scanning linux images...                                                                                                         

Running kernel seems to be up-to-date.

The processor microcode seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.
root@Nh364Mz:~# apt dist-upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  libaom2 linux-headers-5.10.15-towo.1-siduction-amd64 linux-headers-5.10.20-towo.1-siduction-amd64
  linux-image-5.10.15-towo.1-siduction-amd64 linux-image-5.10.20-towo.1-siduction-amd64
Use 'apt autoremove' to remove them.
The following NEW packages will be installed:
  linux-headers-5.11.11-1-siduction-amd64 linux-image-5.11.11-1-siduction-amd64
The following packages have been kept back:
  firefox firefox-esr firefox-esr-l10n-de firefox-l10n-de firefox-l10n-en-gb firefox-l10n-fr firefox-l10n-pt-br
The following packages will be upgraded:
  dnsmasq-base firmware-amd-graphics firmware-atheros firmware-bnx2 firmware-bnx2x firmware-brcm80211 firmware-intelwimax
  firmware-iwlwifi firmware-libertas firmware-linux firmware-linux-nonfree firmware-misc-nonfree firmware-myricom
  firmware-netxen firmware-qlogic firmware-realtek firmware-ti-connectivity libcpupower1 libcrypt-dev libcrypt1
  libgnutls-openssl27 libgnutls30 libixml11 libkf5globalaccel-bin libkf5globalaccel-data libkf5globalaccel5
  libkf5globalaccelprivate5 libldb2 libmediainfo0v5 libssh2-1 libssl-dev libssl1.1 libupnp17 libzen0v5 linux-cpupower
  linux-headers-siduction-amd64 linux-image-siduction-amd64 linux-libc-dev netbase openssl python3-ldb python3-soupsieve teams
  whois
44 upgraded, 2 newly installed, 0 to remove and 7 not upgraded.
Need to get 219 MB of archives.
After this operation, 294 MB of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.

Offline hendrikL

  • Global Moderator
  • User
  • *****
  • Gravatar
  • Posts: 509
Re: Kernel and autoremove
« Reply #13 on: 2021/04/01, 23:11:57 »
Mh, maybe mark them as manual installed

Code: [Select]
sudo apt-mark manual '^linux-[h-i]'

But then you have to mark every new kernel as manual installed
And if this is the right way to do, i don't know!?

EDIT
I tested a bit and added that line above to /etc/apt/apt.sonf.d/01autoremove

Code: [Select]
---snip--
APT
{
  NeverAutoRemove
  {
"^firmware-linux.*";
"^linux-firmware$";
"^linux-image-[a-z0-9]*$";
"^linux-image-[a-z0-9]*-[a-z0-9]*$";
"^linux-[h-i]";
  };

  VersionedKernelPackages
---snap---

so it works for me™, i don't have to mark new kernel as installed manual.
« Last Edit: 2021/04/01, 23:22:10 by hendrikL »

Offline gnasch

  • User
  • Posts: 45
Re: Kernel and autoremove
« Reply #14 on: 2021/04/02, 18:51:52 »
Yes - this works  ;D
Problem seems to be inconsistent naming conventions.
thanks @hendrikL