On 17/08/2022 13:00, dorset-requ...@mailman.lug.org.uk wrote:
Send dorset mailing list submissions to
        dorset@mailman.lug.org.uk

To subscribe or unsubscribe via the World Wide Web, visit
        https://mailman.lug.org.uk/mailman/listinfo/dorset
or, via email, send a message with subject or body 'help' to
        dorset-requ...@mailman.lug.org.uk

You can reach the person managing the list at
        dorset-ow...@mailman.lug.org.uk

When replying, please edit your Subject line so it is more specific
than "Re: Contents of dorset digest..."


Today's Topics:

    1. Cleaning system (Peter Merchant)


----------------------------------------------------------------------

Message: 1
Date: Tue, 16 Aug 2022 21:12:52 +0100
From: Peter Merchant <petermerch...@hotmail.com>
To: DLug <dorset@mailman.lug.org.uk>
Subject: [Dorset] Cleaning system
Message-ID:
        
<as8p191mb15906712d55a5942df52d42eb3...@as8p191mb1590.eurp191.prod.outlook.com>
        
Content-Type: text/plain; charset=UTF-8; format=flowed

I have been thinking that my system is slow recently, and especially with some 
programs such as the Arduino IDE which takes well over a minute to load. I 
wondered if I had two many old versions of the kernel or something so I ran

sudo dpkg --list | egrep 'linux-image|linux-headers'

Which did show me many old ones.

According to one reference
sudo apt autoremove --purge????? should have cleaned up the system, but it 
didn't seem to do anything, so I have been working through each one seperately


sudo apt purge linux-image-5.4.0-99-generic? ....

even so they leave a lot of files around so I have been going into

root/usr/lib/modules/5.4.0-99-generic and all the others trying to remove them.

Is there an easy way to do this?

I have looked at bleachbit but it doesn't seem to help.

thee is probably a fairly simple script to do it, but I am not a script 
programmer.


Thanks for any help.

Peter





------------------------------

Subject: Digest Footer

_______________________________________________
dorset mailing list
dorset@mailman.lug.org.uk
https://mailman.lug.org.uk/mailman/listinfo/dorset


------------------------------

End of dorset Digest, Vol 917, Issue 1
**************************************
Peter, I attach a script that I use to remove all but the latest 3 (default) kernels from my Mageia installations. I hope it is of use for you.
Graeme
#!/bin/bash
# Set number of packages to keep. Must be 1 or greater
declare -i NumberOfVersionsToKeep=3
set -u
ListInstalledPackages() {
    LatestPrefixStart="${LatestPrefix%%-*}"
    if  [ "virtualbox" == "${LatestPrefixStart}" ] ; then
        PackagePrefix="virtualbox-kernel"
    elif [ "vboxadditions" == "${LatestPrefixStart}" ] ; then
        PackagePrefix="vboxadditions-kernel"
    elif [ "xtables" == "${LatestPrefixStart}" ] ; then
        PackagePrefix="xtables-addons-kernel"
    else
        PackagePrefix="$LatestPrefix"
    fi
    RpmOutputLines=($(rpm -qa $PackagePrefix-\[0-9\]*|sort -V))
    PackageCount=${#RpmOutputLines[@]}
    if (( $PackageCount > $NumberOfVersionsToKeep )) ; then
       LinesKeep=$(( $PackageCount - $NumberOfVersionsToKeep ))
       RemoveListNew=("$(printf "%s\n" "${RpmOutputLines[@]}"|head -n 
$LinesKeep)")
       RemoveList=(${RemoveList[@]-} ${RemoveListNew[@]})
    fi
}
ProcessLatest() {
    x="${LatestPackage%-*}" # strip last hyphen and following (removes rpm 
Release)
    x="${x%-*}" # strip last hyphen and following (removes rpm Version')
    LatestPrefix="${x%-*}" # strip last hyphen and following (removes '-latest')
    ListInstalledPackages
}
RemoveList=( )
LatestPackagesList=($(rpm -qa *latest |grep -v perl-latest|sort))
for LatestPackage in "${LatestPackagesList[@]}"; do
    ProcessLatest
done
if  (( ${#RemoveList[@]} > 0 )) ; then
    urpme --wait-lock ${RemoveList[@]}
fi
exit
-- 
  Next meeting: Online, Jitsi, Tuesday, 2022-09-06 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk

Reply via email to