aleluff/uktools

Old kernels are not being auto removed

gouthamravee opened this issue · 12 comments

Old kernels are piling up, requiring manually marking them as auto through apt and running autoremove.

OS: Debian buster

Hi,

Thanks for your report
Can you please give me the result of each of these command :

apt-cache madison linux-headers-generic | awk '{ print $3 }' | sed -r 's/\./-/3'

uname -r | cut -d'-' -f-2

dpkg -l | grep "linux-headers"

apt-cache madison linux-headers-generic | awk '{ print $3 }' | sed -r 's/./-/3'

nothing was returned (not the actual output)

uname -r | cut -d'-' -f-2

5.10.13-051013

dpkg -l | grep "linux-headers"

ii  linux-headers-5.10.12-051012                   5.10.12-051012.202101301330       all          Header files related to Linux kernel version 5.10.12
ii  linux-headers-5.10.12-051012-lowlatency        5.10.12-051012.202101301330       amd64        Linux kernel headers for version 5.10.12 on 64 bit x86 SMP
ii  linux-headers-5.10.13-051013                   5.10.13-051013.202102032337       all          Header files related to Linux kernel version 5.10.13
ii  linux-headers-5.10.13-051013-lowlatency        5.10.13-051013.202102032337       amd64        Linux kernel headers for version 5.10.13 on 64 bit x86 SMP

The first signs of issues were when my VMs started running out of space, these are small VMs running either vanilla Debian Buster or Diet-Pi. I don't provide too much space for these VMs as they are small, at the least 16GB, at the most 64GB.

I used NCDU to find whats taking up space and found that /usr/lib/modules had a lot of copies of old linux kernels. The results below are from running "ls /usr/lib/modules" on one of the VMs that I haven't cleaned up yet, its the same VM I ran the commands above on. I'm using uktools with the default settings except for some VMs I went with the lowlatency kernel instead of the generic. But the issue has been happening on all my VMs.

4.19.0-10-amd64            5.10.13-051013-lowlatency  5.8.14-050814-lowlatency
4.19.0-11-amd64            5.10.2-051002-lowlatency   5.9.0-050900-lowlatency
4.19.0-12-amd64            5.10.3-051003-lowlatency   5.9.10-050910-lowlatency
4.19.0-13-amd64            5.10.4-051004-lowlatency   5.9.1-050901-lowlatency
4.19.0-14-amd64            5.10.5-051005-lowlatency   5.9.12-050912-lowlatency
4.19.0-8-amd64             5.10.6-051006-lowlatency   5.9.2-050902-lowlatency
4.19.0-9-amd64             5.10.7-051007-lowlatency   5.9.3-050903-lowlatency
5.10.0-051000-lowlatency   5.10.8-051008-lowlatency   5.9.4-050904-lowlatency
5.10.10-051010-lowlatency  5.10.9-051009-lowlatency   5.9.6-050906-lowlatency
5.10.1-051001-lowlatency   5.6.0-0.bpo.2-amd64        5.9.7-050907-lowlatency
5.10.11-051011-lowlatency  5.7.0-0.bpo.2-amd64        5.9.8-050908-lowlatency
5.10.12-051012-lowlatency  5.8.13-050813-lowlatency

Thank you.

Hi,

Can you go inside the repository and run
cd src && ./purge
And then give me the result please

User for Git Update: zoneminder
———————————————————————————————————————————————————————————————————————————————
                                     Autoup
———————————————————————————————————————————————————————————————————————————————
User for Git Update: zoneminder
———————————————————————————————————————————————————————————————————————————————
                                  UkTools Purge
———————————————————————————————————————————————————————————————————————————————
This script will only keep last versions of each installed minor versions
-------------------------------------------------------------------------------

------------------------------- Current Version -------------------------------
Linux Kernel 5.10.14-051014 lowlatency (5.10.14-051014-lowlatency)

the user is in the sudoers group

Hi,

Can you tell me if after running ./purge things went better
If not, can you try sudo apt -get autoremove --purge --simulate and paste here the result

I try different ways, but can't succeed reproduce the bug

Thanks

Hello,

no running the purge script didn't clear up the old data in /usr/lib/modules

$ sudo ls /usr/lib/modules
4.19.0-10-amd64            5.10.14-051014-lowlatency  5.8.13-050813-lowlatency
4.19.0-11-amd64            5.10.15-051015-lowlatency  5.8.14-050814-lowlatency
4.19.0-12-amd64            5.10.16-051016-lowlatency  5.9.0-050900-lowlatency
4.19.0-13-amd64            5.10.2-051002-lowlatency   5.9.10-050910-lowlatency
4.19.0-14-amd64            5.10.3-051003-lowlatency   5.9.1-050901-lowlatency
4.19.0-8-amd64             5.10.4-051004-lowlatency   5.9.12-050912-lowlatency
4.19.0-9-amd64             5.10.5-051005-lowlatency   5.9.2-050902-lowlatency
5.10.0-051000-lowlatency   5.10.6-051006-lowlatency   5.9.3-050903-lowlatency
5.10.10-051010-lowlatency  5.10.7-051007-lowlatency   5.9.4-050904-lowlatency
5.10.1-051001-lowlatency   5.10.8-051008-lowlatency   5.9.6-050906-lowlatency
5.10.11-051011-lowlatency  5.10.9-051009-lowlatency   5.9.7-050907-lowlatency
5.10.12-051012-lowlatency  5.6.0-0.bpo.2-amd64        5.9.8-050908-lowlatency
5.10.13-051013-lowlatency  5.7.0-0.bpo.2-amd64
$ sudo apt-get autoremove --purge --simulate
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Is it possible this is happening because the script is installed within a user's home directory /home/zoneminder/uktools ?
I have this issue happening across multiple virtual machines, and all are installed the same way, but different users in each vm.

I'm able to autoremove these old kernels by running the command below

sudo apt-mark auto linux-*

After running that command, the autoremove gets me results.

$ sudo apt autoremove --purge --simulate
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  linux-headers-5.10.13-051013* linux-headers-5.10.13-051013-lowlatency*
  linux-headers-5.10.15-051015* linux-headers-5.10.15-051015-lowlatency*
  linux-image-unsigned-5.10.13-051013-lowlatency* linux-image-unsigned-5.10.15-051015-lowlatency*
  linux-modules-5.10.13-051013-lowlatency* linux-modules-5.10.15-051015-lowlatency*
0 upgraded, 0 newly installed, 8 to remove and 0 not upgraded.
Purg linux-headers-5.10.13-051013-lowlatency [5.10.13-051013.202102032337]
Purg linux-headers-5.10.13-051013 [5.10.13-051013.202102032337]
Purg linux-headers-5.10.15-051015-lowlatency [5.10.15-051015.202102100936]
Purg linux-headers-5.10.15-051015 [5.10.15-051015.202102100936]
Purg linux-image-unsigned-5.10.13-051013-lowlatency [5.10.13-051013.202102032337] [linux-modules-5.10.13-051013-lowlatency:amd64 ]
Purg linux-modules-5.10.13-051013-lowlatency [5.10.13-051013.202102032337]
Purg linux-image-unsigned-5.10.15-051015-lowlatency [5.10.15-051015.202102100936] [linux-modules-5.10.15-051015-lowlatency:amd64 ]
Purg linux-modules-5.10.15-051015-lowlatency [5.10.15-051015.202102100936]

Though its still not getting all the old kernels.

The best I can do now, is a remote access & debug on one of your machine
If you want a call also, it can be a pleasure

Tell me

?

Apologies, this issue isn't that big of a deal that I need remote access nor do I want to take up your time with that. Can be closed for now, if I find a solution on my own I will let you know.

Something I noticed, when setting up UKtools, and when given the option to auto remove old kernel I get the message 'no cron for root'

Running the command sudo crontab -e I only see one entry:

0 */2 * * * /home/dietpi/uktools/src/upgrade | while IFS= read -r line; do echo "[$(date '+\%Y-\%m-$

should there be another entry here to run the auto remove command?