Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Culling old versions of Kernel from /usr/lib/modules/

42 views
Skip to first unread message

KCB Leigh

unread,
Mar 24, 2023, 6:00:06 PM3/24/23
to
This message is related to the 'Re: solution to / full' thread.

I am running my computer from a Debian 11.6 OS on a 25GB partition on
a USB stick.  The root partition is now 70% full, with over 4GB (16%) of
the volume occupied by /usr/lib/modules/ (3.5GB) &
/usr/lib/x86_64-linux-gnu (1.4GB) - as far as I can tell, this latter
directory only has essential, current files.  I have been using this
volume for over a year, & the modules directory now has over a
dozen kernels from previous versions of the operating system.  I can
see the need to retain the last couple of versions, but within the
space constraints, I really cannot afford to keep all of these old
kernels, each consuming 307-323MB.

MY QUESTION:
- Is there some utility that pares these files, or must one do this
  manually?
- I have been reluctant to do this manually because I'm not too
  familiar with the structure of the operating system & do not want to
  delete a file which may be required by some other part of the system
  that I've not also removed.  Specifically, in the /boot/ directory
  there are also files related to these older kernel versions:
    config-5.10.0-*-amd64    (236 kB each)
    initrd.img-5.10.0-*-amd64    ( 72.7MB each)
    System.map-5.10.0-*-amd64    ( 83 bytes each)
    vmlinuz-5.10.0-*-amd64    (  6.8MB each)
  corresponding to each of the dozen or so old versions of kernel in
  the /usr/lib/modules/ directory.  I would think the older versions
  of these files should also be removed when the kernels are.
? & are there any other files related to these kernels that should
  also be deleted?  I think there is some file that contains the list
  of possible boot volumes displayed by grub: I think I've found this
  somewhere in the distant past, but can't recall whether it contains
  a list of these older kernels, or whether that list is dynamically
  updated depending on what is found on the boot volume.

I would appreciate any references that might give more information
about this, or any advice.

With thanks in advance,
Ken

(I have not subscribed to the list, but will try to check it; I would
be very grateful if replies could be cc to my e-mail address:
kcbl...@yahoo.co.uk.)

David

unread,
Mar 24, 2023, 6:30:05 PM3/24/23
to
On Fri, 2023-03-24 at 21:39 +0000, KCB Leigh wrote:
> This message is related to the 'Re: solution to / full' thread.
>
> I am running my computer from a Debian 11.6 OS on a 25GB partition on
> a USB stick.  The root partition is now 70% full, with over 4GB (16%)
> of
> the volume occupied by /usr/lib/modules/ (3.5GB) &
> /usr/lib/x86_64-linux-gnu (1.4GB) - as far as I can tell, this latter
> directory only has essential, current files.  I have been using this
> volume for over a year, & the modules directory now has over a
> dozen kernels from previous versions of the operating system.  I can
> see the need to retain the last couple of versions, but within the
> space constraints, I really cannot afford to keep all of these old
> kernels, each consuming 307-323MB.
>
> MY QUESTION:
> - Is there some utility that pares these files, or must one do this
>   manually?

Su to root.
`apt auto-remove'
enter

After this, install cruft-ng and deborphan to help keep things tidy.
Cheers!

Joe

unread,
Mar 25, 2023, 5:00:06 AM3/25/23
to
On Fri, 24 Mar 2023 21:39:33 +0000 (UTC)
KCB Leigh <kcbl...@yahoo.co.uk> wrote:

> This message is related to the 'Re: solution to / full' thread.
>
> I am running my computer from a Debian 11.6 OS on a 25GB partition on
> a USB stick.  The root partition is now 70% full, with over 4GB (16%)
> of the volume occupied by /usr/lib/modules/ (3.5GB) &
> /usr/lib/x86_64-linux-gnu (1.4GB) - as far as I can tell, this latter
> directory only has essential, current files.  I have been using this
> volume for over a year, & the modules directory now has over a
> dozen kernels from previous versions of the operating system.  I can
> see the need to retain the last couple of versions, but within the
> space constraints, I really cannot afford to keep all of these old
> kernels, each consuming 307-323MB.
>
> MY QUESTION:
> - Is there some utility that pares these files, or must one do this
>   manually?

Just kernels? apt autoremove will remove anything which is no longer
part of the dependency tree, with the exception that it will leave two
kernels i.e. the current and previous versions.

This is normally a good idea, since occasionally a new kernel has a
problem, and grub will allowing booting to either the current or
previous one.

Sometimes a package will be replaced by another with a different name
(not just the version number part) perhaps as a result of restructuring
(does not apply to Stable) and the previous versions will not normally
be removed in the course of the upgrade. Autoremove will get rid of
these.

It's not an automatic process, in terms of actually happening without
manual intervention, as there may be a reason you don't want it done
routinely. But an ordinary apt upgrade will normally display the
obsolete package names and suggest the use of autoremove.

--
Joe
0 new messages