Package: eclean-kernel
Introductioneclean-kernelis a small tool aimed at removing old and stale kernel files. It
does not only remove old kernels itself but also tries to remove all related
files including auxiliary files in /boot, kernel modules and even the source
tree.UsageThe typical use is:eclean-kernel -n 3 -pwhere-n3is used to keep three newest kernels around, and-pmakes
eclean-kernel only print kernels which would be removed.In case the results are satisfactory, use:eclean-kernel -n 3to actually remove the kernels.If you are unsure whether kernel files are mapped correctly, you can use
list mode:eclean-kernel -lwhich just lists found kernels with file mappings.Configuration fileSome default options can be specified ineclean-kernel.rcfile in a location
mandated by the XDG configuration directory setting, e.g.~/.config/.The file format is very simple – additional command-line options are specified
in shell style. For example, to keep three newest kernels and always preserve
kernel configs,~/.config/eclean-kernel.rcwould contain:-n 3 -x configThe options read from config files will be parsed before actual command-line
options, so the latter will override them.Fiding and mapping kernelseclean-kernel supports two distinct /boot layouts: the bootloader spec
layout (gummiboot / systemd-boot) and the legacy /boot layout.
The former is used if/boot/MACHINE-IDor/boot/EFI/MACHINE-IDare found, otherwise the latter is used.The bootloader spec layout uses subdirectories of/boot/MACHINE-IDnamed after kernel versions. It expects the kernel to be namedlinux, and initramfs to be namedinitrd. However, it collects
arbitrary files in that directory as well.The legacy layout scans all files directly in/bootdirectory
that are named asPREFIX-VERSION. Files recognized as bzImages
can have any prefix, other files use a predefined list of prefixes.In both layouts, eclean-kernel looks for kernel modules
in/lib/modules/REALVERSIONwhereREALVERSIONcorresponds to
the actual kernel version string used by the kernel itself. It is read
from kernel image and it is assumed to be equal toVERSIONfor libdirs
unmatched to any kernel image.In other words, genkernel-generatedkernel-genkernel-ARCH-X.Y.Zwill
matchSystem.map-genkernel-ARCH-X.Y.Zand/lib/modules/X.Y.Z.Choosing kernels to removeThe kernel choice algorithm is quite simple:If the kernel is currently used, don’t remove it;If the kernel is referenced by a bootloader, don’t remove it
(unless--destructive);If auxiliary files do not map to existing kernel, remove them;If--allis used, remove the kernel;If kernel is not withinNnewest kernels (whereNis the argument
to-n), remove it.The program always derefences symlinks and counts real path references. Thus,
a particular file will be removed only if all kernels referencing it are removed
as well. This is especially important for shared kernel sources.Bootloader supportIn order to determine kernels currently used, eclean-kernel is supposed to read
configuration files used by the bootloader. Right now, the following bootloaders
are supported (and looked up in the following order):lilo,grub2,grub,yaboot.There is also a pseudo-bootloader module calledsymlinkswhich assumes files
symlinked to/boot/PREFIXand/boot/PREFIX.oldare used.By default, eclean-kernel uses the first bootloader from the above list for
which a configuration file exists, and usessymlinksas a fallback. This can
be changed using--bootloaderargument.Reporting bugsPlease report bugs either tothe issue trackerorGentoo Bugzilla. When
reporting a bug, please attach the outputs of:eclean-kernel -l
ls -l /boot /lib/modules/*If relevant, please attach bootloader configuration files as well.