• Deleting old Kernels.

    From Alan K.@alan@invalid.com to alt.os.linux.mint on Fri May 8 18:16:13 2026
    From Newsgroup: alt.os.linux.mint

    Okay, in update manager there is a checkbox to get update manager to purge excess kernels.
    However I've 3 of them now, and I thought at one time I had 4.

    I know how to do it manually. Sudo apt autoremove doesn't do it now with 3.

    So what's the key to this? It used to do it with the autoremove in 22.2, but seems now,
    at least on my machine, in 22.3 it don't do it.
    --
    Mint 22.3, Thunderbird 140.10.0esr, Firefox 150.0.1
    Alan K.

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From George@Invalid@invalid.invalid to alt.os.linux.mint on Fri May 8 23:45:07 2026
    From Newsgroup: alt.os.linux.mint

    On 08/05/2026 23:16, Alan K. wrote:
    Okay, in update manager there is a checkbox to get update manager to
    purge excess kernels.
    However I've 3 of them now, and I thought at one time I had 4.

    I know how to do it manually.-a-a Sudo apt autoremove doesn't do it now
    with 3.

    So what's the key to this?-a-a It used to do it with the autoremove in
    22.2, but seems now, at least on my machine, in 22.3 it don't do it.



    Try running this:

    sudo apt purge --autoremove







    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Alan K.@alan@invalid.com to alt.os.linux.mint on Fri May 8 21:34:43 2026
    From Newsgroup: alt.os.linux.mint

    On 5/8/26 6:45 PM, George wrote:
    On 08/05/2026 23:16, Alan K. wrote:
    Okay, in update manager there is a checkbox to get update manager to
    purge excess kernels.
    However I've 3 of them now, and I thought at one time I had 4.

    I know how to do it manually.-a-a Sudo apt autoremove doesn't do it now
    with 3.

    So what's the key to this?-a-a It used to do it with the autoremove in
    22.2, but seems now, at least on my machine, in 22.3 it don't do it.



    Try running this:

    sudo apt purge --autoremove







    same thing. says nothing to remove upgrade or install
    --
    Mint 22.3, Thunderbird 140.10.0esr, Firefox 150.0.1
    Alan K.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Paul@nospam@needed.invalid to alt.os.linux.mint on Sat May 9 00:31:52 2026
    From Newsgroup: alt.os.linux.mint

    On Fri, 5/8/2026 9:34 PM, Alan K. wrote:
    On 5/8/26 6:45 PM, George wrote:
    On 08/05/2026 23:16, Alan K. wrote:
    Okay, in update manager there is a checkbox to get update manager to
    purge excess kernels.
    However I've 3 of them now, and I thought at one time I had 4.

    I know how to do it manually.-a-a Sudo apt autoremove doesn't do it now
    with 3.

    So what's the key to this?-a-a It used to do it with the autoremove in
    22.2, but seems now, at least on my machine, in 22.3 it don't do it.



    Try running this:

    sudo apt purge --autoremove

    same thing.-a-a says nothing to remove upgrade or install

    For some reason, a search tells me of a "purge-old-kernels" script.
    Apparently, this is only a valid approach before the year 2012.

    sudo apt install byobu

    /usr/bin/purge-old-kernels <=== the logic has already been removed, need an old copy.

    https://github.com/algodelinux/purge-old-kernels/blob/master/purge-old-kernels

    show_installed_kernels () {
    INSTALLED_KERNELS=$(ls /boot/vmlinuz-* | sed -e "s/^\/boot\/vmlinuz-//" | awk -F'[.-]' '{print $1"\t"$2"\t"$3"\t"$4"\t"$0}' | sort -k1 -k2 -k3 -k4 -n | cut -f5)
    echo -e "Installed kernels:"
    echo -e "${GREEN}$INSTALLED_KERNELS${NC}"
    }

    Which tells us basically, we should look through the
    /boot/vmlinuz-* for evidence of kernels :-)

    total 215912
    drwxr-xr-x 3 root root 4096 Apr 23 09:34 .
    drwxr-xr-x 22 root root 4096 Apr 23 09:36 ..
    -rw-r--r-- 1 root root 296189 Nov 20 03:36 config-6.14.0-37-generic -rw-r--r-- 1 root root 302833 Mar 25 14:31 config-6.17.0-22-generic drwxr-xr-x 5 root root 4096 Apr 26 12:32 grub
    lrwxrwxrwx 1 root root 28 Apr 23 09:33 initrd.img -> initrd.img-6.17.0-22-generic
    -rw-r--r-- 1 root root 82729428 Apr 23 09:12 initrd.img-6.14.0-37-generic -rw-r--r-- 1 root root 85795499 Apr 23 09:34 initrd.img-6.17.0-22-generic lrwxrwxrwx 1 root root 28 Apr 23 09:04 initrd.img.old -> initrd.img-6.14.0-37-generic
    -rw------- 1 root root 9159323 Nov 20 03:36 System.map-6.14.0-37-generic -rw------- 1 root root 10475441 Mar 25 14:31 System.map-6.17.0-22-generic lrwxrwxrwx 1 root root 25 Apr 23 09:33 vmlinuz -> vmlinuz-6.17.0-22-generic
    -rw-r--r-- 1 root root 15571336 Nov 20 03:38 vmlinuz-6.14.0-37-generic -rw------- 1 root root 16734280 Mar 25 15:06 vmlinuz-6.17.0-22-generic lrwxrwxrwx 1 root root 25 Apr 23 09:33 vmlinuz.old -> vmlinuz-6.14.0-37-generic

    There is the current kernel and one older kernel (for an option as an emergency boot).

    For more info about the logic and commands, try this as a reference. In particular,
    it shows a --dry-run option, so you can see what the chain-saw is about to cut.

    https://askubuntu.com/questions/563483/why-doesnt-apt-get-autoremove-remove-my-old-kernels

    Paul


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From german newsgroups@usualsuspectrider@gmail.com to alt.os.linux.mint on Sat May 9 08:18:02 2026
    From Newsgroup: alt.os.linux.mint

    Le 09/05/2026 |a 00:16, Alan K. a |-crit-a:
    Okay, in update manager there is a checkbox to get update manager to
    purge excess kernels.
    However I've 3 of them now, and I thought at one time I had 4.

    I know how to do it manually.-a-a Sudo apt autoremove doesn't do it now
    with 3.

    So what's the key to this?-a-a It used to do it with the autoremove in
    22.2, but seems now, at least on my machine, in 22.3 it don't do it.


    it's suspect what you are saying !

    22.3 it the last version of linux mint.

    if you are NOT a pro office, and if you don't need a specific DRIVER !
    may be compile it...dont't touch anythink avec the maj / update.

    you can put ON your tux for 5 years and work well because, all
    MASTERs do becarefull when they put online a website...so, what ?
    the same firefox 'll work !!! thunderdird ? a client mail !!!!

    hum.........
    --
    Amicalement,

    Frenchy Friendly, & French touch !

    german
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From jjb@jjb@invalid.invalid to alt.os.linux.mint on Sat May 9 12:18:51 2026
    From Newsgroup: alt.os.linux.mint

    On 2026-05-09 06:31, Paul wrote:
    On Fri, 5/8/2026 9:34 PM, Alan K. wrote:
    On 5/8/26 6:45 PM, George wrote:
    On 08/05/2026 23:16, Alan K. wrote:
    Okay, in update manager there is a checkbox to get update manager to
    purge excess kernels.
    However I've 3 of them now, and I thought at one time I had 4.

    I know how to do it manually.-a-a Sudo apt autoremove doesn't do it now >>>> with 3.

    So what's the key to this?-a-a It used to do it with the autoremove in >>>> 22.2, but seems now, at least on my machine, in 22.3 it don't do it.



    Try running this:

    sudo apt purge --autoremove

    same thing.-a-a says nothing to remove upgrade or install

    For some reason, a search tells me of a "purge-old-kernels" script. Apparently, this is only a valid approach before the year 2012.

    I had the same problem, so I wrote a little perl script to do it right.
    I also made a systemd service so the script runs at every boot.

    Perl program:

    #####################################
    #!/usr/bin/perl --

    use strict;
    use warnings;
    use v5.34;
    use utf8;
    use open qw (:std :utf8);
    use feature qw (refaliasing declared_refs unicode_strings);
    no warnings qw (experimental::refaliasing experimental::declared_refs);
    use lib '/opt/Perl/private_modules';
    use File::stat;

    my ($file, $running);
    my (@lines, @kernels, @files);
    my (%files);

    #
    # Constants
    #
    my $kernels_to_keep = 2; #Aantal oude kernels om te bewaren

    print "Starting kernel purge procedure.\n";
    #1. Find all installed kernels
    @lines = `dpkg --list | grep -i 'linux-image'`;
    foreach (@lines) {
    if (/^ii\s+linux-image-(\d[\S]+)/) {
    push (@kernels, $1);
    }
    }
    #2. Find all images in /boot
    @lines = glob ("/boot/vmlinuz*");
    foreach (@lines) {
    if (/^\/boot\/vmlinuz-(\d[\S]+)/) {
    push (@files, $1);
    $file = stat ($_);
    $files{$file -> mtime} = s/.+vmlinuz-(\d[\S]+)/$1/r;
    }
    }
    #3. Check on equal number of installed kernels and images in /boot
    unless (scalar (@kernels) == scalar (keys (%files))) {
    die ("Discrepancy between number of installed kernels and kernel
    images in /booot\n")
    }
    #4. Check of each installed kernel has an kernel image
    @lines = sort (values (%files));
    foreach (0 .. $#lines) {
    unless ($lines[$_] eq $kernels[$_]) {
    die "Names f kernel images and installed kernels do not match\n";
    }
    }
    #5. Exempt most recent and running kernels
    pop (@kernels); #Save most recent kernel
    $running = (`uname -r` =~ s/\R\z//r);
    @kernels = grep !/$running/, @kernels; #Save running kernel
    for (my $i = 0; $i < $kernels_to_keep; $i++) {
    pop (@kernels);
    }
    unless (@kernels) {
    print "No kernels to remove.\n";
    exit 0;
    }
    #6. Remove old kernels
    foreach (@kernels) {
    print "Purging linux_image-$_*\n";
    system ("/usr/bin/apt-get -y purge linux-image-$_");
    print "Purging linux_headers-$_*\n";
    system ("/usr/bin/apt-get -y purge linux-headers-$_");
    print "Purging linux_modules-$_*\n";
    system ("/usr/bin/apt-get -y purge linux-modules-$_");
    }
    exit 0;
    ############################
    Service file:

    ###############################
    [Unit]
    Description=Purge old kernels

    [Service]
    Type=simple
    ExecStart=/usr/bin/perl /root/.misc_programs/purge_kernels.pl
    Restart=no
    WorkingDirectory=/root/.misc_programs

    [Install]
    WantedBy=multi-user.target
    ################################

    YMMV, no guarantees.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From RonB@ronb02NOSPAM@gmail.com to alt.os.linux.mint on Sat May 9 11:06:59 2026
    From Newsgroup: alt.os.linux.mint

    On 2026-05-08, George <Invalid@invalid.invalid> wrote:
    On 08/05/2026 23:16, Alan K. wrote:
    Okay, in update manager there is a checkbox to get update manager to
    purge excess kernels.
    However I've 3 of them now, and I thought at one time I had 4.

    I know how to do it manually.-a-a Sudo apt autoremove doesn't do it now
    with 3.

    So what's the key to this?-a-a It used to do it with the autoremove in
    22.2, but seems now, at least on my machine, in 22.3 it don't do it.



    Try running this:

    sudo apt purge --autoremove

    You can delete them individually in Update Manager, under View > Kernels. I think autoremove keeps at least one extra kernel in case there is a problem with the new one.
    --
    Not all Jews are Zionists. Not all Zionists are Jews. Zionism rea Judaism.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Alan K.@alan@invalid.com to alt.os.linux.mint on Sat May 9 09:03:22 2026
    From Newsgroup: alt.os.linux.mint

    On 5/9/26 7:06 AM, RonB wrote:
    On 2026-05-08, George <Invalid@invalid.invalid> wrote:
    On 08/05/2026 23:16, Alan K. wrote:
    Okay, in update manager there is a checkbox to get update manager to
    purge excess kernels.
    However I've 3 of them now, and I thought at one time I had 4.

    I know how to do it manually.-a-a Sudo apt autoremove doesn't do it now
    with 3.

    So what's the key to this?-a-a It used to do it with the autoremove in
    22.2, but seems now, at least on my machine, in 22.3 it don't do it.



    Try running this:

    sudo apt purge --autoremove

    You can delete them individually in Update Manager, under View > Kernels. I think autoremove keeps at least one extra kernel in case there is a problem with the new one.

    Thanks. I think I put that in the OP. I know all the standard procedures. It's the
    automatic part that I'm not getting the system to do. Or at least the 'autoremove' part.
    --
    Mint 22.3, Thunderbird 140.10.0esr, Firefox 150.0.1
    Alan K.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to alt.os.linux.mint on Sun May 10 03:36:13 2026
    From Newsgroup: alt.os.linux.mint

    On Sat, 9 May 2026 12:18:51 +0200, jjb wrote:

    #1. Find all installed kernels
    @lines = `dpkg --list | grep -i 'linux-image'`;
    foreach (@lines) {
    if (/^ii\s+linux-image-(\d[\S]+)/) {
    push (@kernels, $1);
    }
    }

    You can ask the dpkg commands for exactly the info you need, to save
    parsing out unwanted cruft. HererCOs what I came up with in Python:

    import subprocess

    kernel_list = subprocess.check_output \
    (
    args = ("dpkg-query", "-f" "${Package}\n", "-W", "*linux-image*"),
    text = True
    ).split("\n")[:-1]

    print(kernel_list)

    HererCOs (partial) output on my Debian Unstable system:

    ['linux-image-6.1.0-8-amd64', 'linux-image-6.1.0-8-amd64-unsigned',
    'linux-image-6.1.0-9-amd64', 'linux-image-6.1.0-9-amd64-unsigned',
    'linux-image-6.10.11-amd64', 'linux-image-6.10.11-amd64-unsigned' ...
    'linux-image-6.9.10-amd64', 'linux-image-6.9.10-amd64-unsigned',
    'linux-image-amd64', 'linux-image-generic']
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to alt.os.linux.mint on Sun May 10 04:36:27 2026
    From Newsgroup: alt.os.linux.mint

    On Sat, 9 May 2026 12:18:51 +0200, jjb wrote:

    #1. Find all installed kernels
    @lines = `dpkg --list | grep -i 'linux-image'`;
    foreach (@lines) {
    if (/^ii\s+linux-image-(\d[\S]+)/) {
    push (@kernels, $1);
    }
    }

    OK, I didnrCOt notice you were specifically checking for packages with
    status = installed. HererCOs an update to my code that includes such a
    check:

    import subprocess

    kernel_list = list \
    (
    n
    for s, n in
    (l.split("\t", 1)
    for l in
    subprocess.check_output
    (
    args = ("dpkg-query", "-f" "${Status;-1}\t${Package}\n", "-W", "*linux-image*"),
    text = True
    ).split("\n")
    if l != ""
    )
    if s == "i"
    )

    print(kernel_list)

    The output list is much shorter. ;)
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From jjb@jjb@invalid.invalid to alt.os.linux.mint on Sun May 10 12:11:59 2026
    From Newsgroup: alt.os.linux.mint

    On 2026-05-10 06:36, Lawrence DrCOOliveiro wrote:
    On Sat, 9 May 2026 12:18:51 +0200, jjb wrote:

    #1. Find all installed kernels
    @lines = `dpkg --list | grep -i 'linux-image'`;
    foreach (@lines) {
    if (/^ii\s+linux-image-(\d[\S]+)/) {
    push (@kernels, $1);
    }
    }

    OK, I didnrCOt notice you were specifically checking for packages with
    status = installed. HererCOs an update to my code that includes such a
    check:

    import subprocess

    kernel_list = list \
    (
    n
    for s, n in
    (l.split("\t", 1)
    for l in
    subprocess.check_output
    (
    args = ("dpkg-query", "-f" "${Status;-1}\t${Package}\n", "-W", "*linux-image*"),
    text = True
    ).split("\n")
    if l != ""
    )
    if s == "i"
    )

    print(kernel_list)

    The output list is much shorter. ;)

    Hi,
    Thanks for reviewing my code. You say the output list is much shorter.
    On my system, it consists of 4 lines. Stripping each line is an
    efficient process in perl using a regex.
    As you see, the script tries to be very conservative in deleting
    kernels. Any situation differing from what I expect leads to program
    abort. Feel free to adapt it to your liking.
    --- Synchronet 3.22a-Linux NewsLink 1.2