On Wed, Nov 6, 2024 at 5:04 PM home user via users
<[email protected]> wrote:
>
> On 11/6/24 11:12 AM, Jeffrey Walton wrote:
> > [...]
> >>> Related, be sure to look in /lib/modules for old kernel artifacts.
> >>> There have been several bugs related to proceccessing old kernel
> >>> removals. The removal scripts would _not_ remove the directory if they
> >>> were not empty, and the script had a bug that left a few small files.
> >>>
> >>> Something like this is safe to run to cleanup /lib/modules:
> >>>
> >>> # https://bugzilla.redhat.com/show_bug.cgi?id=2185410
> >>> clean_lib_modules() {
> >>> if [[ -d "/lib/modules" ]]; then
> >>> echo "Cleaning /lib/modules"
> >>> # dirs=($(ls /lib/modules))
> >>> mapfile -t dirs < <(ls /lib/modules)
> >>> for dir in "${dirs[@]}"
> >>> do
> >>> dir="/lib/modules/${dir}"
> >>> if [ "$(du -s -B 4096 "${dir}" | awk '{print $1}')" -lt
> >>> 4096 ]
> >>> then
> >>> echo " removing ${dir}"
> >>> rm -rf "${dir}" 2>/dev/null
> >>> fi
> >>> done
> >>> fi
> >>> }
> >>
> >> I do not fully understand that script, but I did the clean-up. 5 old
> >> directories, each having several times 4096 blocks were left behind. I
> >> don't know if the problem is in dnf, a database, or something/somewhere
> >> else. But post patching clean-up seems to be an ongoing problem.
> >
> > The script uses `du` to count the size of files in the directory tree
> > of each [previously installed] kernel. If the size is less than 4K, it
> > deletes the directory tree. If the size is greater than 4K, then it is
> > not touched.
> >
> > Here's an example of what causes the accumulation of leftovers in
> > /lib/modules from a Linux Mint machine. As I understand things, the
> > kernel uses the same scripts everywhere. Notice the "dpkg:
> > warning...".
> >
> > Removing linux-modules-5.15.0-122-generic (5.15.0-122.132) ...
> > (Reading database ... 375164 files and directories currently installed.)
> > Purging configuration files for linux-modules-5.15.0-122-generic
> > (5.15.0-122.132) ...
> > dpkg: warning: while removing linux-modules-5.15.0-122-generic,
> > directory '/lib/modules/5.15.0-122-generic' not empty so not removed
> > Purging configuration files for linux-image-5.15.0-122-generic
> > (5.15.0-122.132) ...
> > Purging configuration files for linux-modules-extra-5.15.0-122-generic
> > (5.15.0-122.132) ...
> > ...
> >
> >> I'm still needing the answer to the core questions of this thread.
>
> Several directories were cleaned out. But several (5) sub-directories were
> left behind and are still there. All are over 36000 4-k blocks The oldest
> are 6.2.*, dating back to f-37. Likewise, /boot still has 5 files from
> 6.10.12 (f-39). S-o-m-e t-h-i-n-g in the patch and upgrade processes is not
> cleaning up properly.
`package-cleanup --oldkernels --count=2` might help with that. It
removes all old kernels except the current kernel and the one before
it.
You can also manually do it. For each old kernel listed in
/lib/modules, do something like this:
export kernel_ver=6.11.5-200.fc40.x86_64
dnf remove \
kernel-$(kernel_ver) \
kernel-core-$(kernel_ver) \
kernel-devel-$(kernel_ver) \
kernel-modules-$(kernel_ver)
Once you manually remove the old kernels, then run clean_lib_modules
to remove the old artifacts in /usr/modules.
Jeff
--
_______________________________________________
users mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives:
https://lists.fedoraproject.org/archives/list/[email protected]
Do not reply to spam, report it:
https://pagure.io/fedora-infrastructure/new_issue