Steps: 1. emerge -avuDN @world to upgrade new kernel then reboot 2. emerge -ac * Always study the list of packages to be cleaned for any obvious * mistakes. Packages that are part of the world set will always * be kept. They can be manually added to this set with * `emerge --noreplace <atom>`. Packages that are listed in * package.provided (see portage(5)) will be removed by * depclean, even if they are part of the world set. * * As a safety measure, depclean will not remove any packages * unless *all* required dependencies have been resolved. As a * consequence of this, it often becomes necessary to run * `emerge --update --newuse --deep @world` prior to depclean. Calculating dependencies... done! >>> Calculating removal order... >>> These are the packages that would be unmerged: sys-kernel/gentoo-kernel selected: 6.12.1 protected: none omitted: 6.12.3 All selected packages: =sys-kernel/gentoo-kernel-6.12.1 >>> 'Selected' packages are slated for removal. >>> 'Protected' and 'omitted' packages will not be removed. Would you like to unmerge these packages? [Yes/No] >>> Waiting 5 seconds before starting... >>> (Control-C to abort)... >>> Unmerging in: 5 4 3 2 1 >>> Unmerging (1 of 1) sys-kernel/gentoo-kernel-6.12.1... Packages installed: 1052 Packages in world: 50 Packages in system: 49 Required packages: 1052 Number removed: 1 3. eclean-kernel -n 1 -a eclean-kernel has met the following issue: SystemError('No vmlinuz found. This is a serious problem, and it would mean removing all remaining files. Aborting.') If you believe that the mentioned issue is a bug, please report it to https://github.com/mgorny/eclean-kernel/issues. If possible, please attach the output of 'eclean-kernel --list-kernels' and your regular eclean-kernel call with additional '--debug' argument. 4. eclean-kernel --list-kernels modules-only 6.12.3-gentoo-dist [None] - modules: /lib/modules/6.12.3-gentoo-dist - build: /lib/modules/6.12.3-gentoo-dist/../../../src/linux-6.12.3-gentoo-dist - last modified: 2024-12-09 02:48:51 modules-only 6.12.1-gentoo-dist [None] - modules: /lib/modules/6.12.1-gentoo-dist - last modified: 2024-12-06 02:19:28
5. I am using Grub2. $: ls /boot grub initramfs-6.12.1-gentoo-dist.img initramfs-6.12.3-gentoo-dist.img kernel-6.12.1-gentoo-dist kernel-6.12.3-gentoo-dist
run eclean-kernel with --debug: $: eclean-kernel -n 1 --debug DEBUG:root:Sorter: <ecleankernel.sort.VersionSort object at 0x7fc67e664650> DEBUG:root:Layout: <ecleankernel.layout.blspec.BlSpecLayout object at 0x7fc67e6672f0> DEBUG:root:Bootloader failed: <class 'ecleankernel.bootloader.lilo.LILO'> DEBUG:root:/boot/grub/grub.cfg found DEBUG:root:Bootloader: <ecleankernel.bootloader.grub2.GRUB2 object at 0x7fc67e3f7410> DEBUG:root:in get_removal_list() Traceback (most recent call last): File "/usr/lib/python-exec/python3.12/eclean-kernel", line 8, in <module> sys.exit(setuptools_main()) ^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/ecleankernel/__main__.py", line 391, in setuptools_main sys.exit(main(sys.argv[1:])) ^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/ecleankernel/__main__.py", line 251, in main removals = get_removal_list( ^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/ecleankernel/process.py", line 81, in get_removal_list raise SystemError( SystemError: No vmlinuz found. This is a serious problem, and it would mean removing all remaining files. Aborting.
After some debugging today, I found that this is an interesting bug, yes I now believe it is a bug. When it detects that I am Grub2 and uses the blspec layout, it results in not being able to find the correct kernel that needs to be removed. The logic for determining the layout here seems to have some issues, because when using auto it directly enters the blspec layout (since this layout matches my current layout, it is considered the correct layout). ecleankernel/__main__.py: ``` for layout_cls in layouts: if args.layout in ('auto', layout_cls.name): try: layout = layout_cls(root=args.root) break except LayoutNotFound as e: logging.debug(f'Layout failed: {layout_cls}; ' f'exception: {e}') else: # auto should never fail -- std always succeeds assert args.layout != 'auto' argp.error(f'Invalid layout: {args.layout}') logging.debug(f'Layout: {layout}') ``` But actually, std layout should be used here: ``` ❯ sudo eclean-kernel -n 1 -a --debug -L std DEBUG:root:Sorter: <ecleankernel.sort.VersionSort object at 0x7fecdf1e3ec0> DEBUG:root:Layout: <ecleankernel.layout.std.StdLayout object at 0x7fecdf05dc10> DEBUG:root:Bootloader failed: <class 'ecleankernel.bootloader.lilo.LILO'> DEBUG:root:/boot/grub/grub.cfg found DEBUG:root:Bootloader: <ecleankernel.bootloader.grub2.GRUB2 object at 0x7fecdf0fb2c0> DEBUG:root:in get_removal_list() DEBUG:root:Config is autogenerated, ignoring Preserving currently running kernel (6.12.5-gentoo-dist) Legend: [-] file being removed [x] file does not exist (anymore) [+] file being kept (used by other kernels) * Removing kernel other 6.12.1-gentoo-dist (not referenced by bootloader (grub2)) Generating grub configuration file ... Found linux image: /boot/kernel-6.12.5-gentoo-dist Found initrd image: /boot/initramfs-6.12.5-gentoo-dist.img Found linux image: /boot/kernel-6.12.4-gentoo-dist Found initrd image: /boot/initramfs-6.12.4-gentoo-dist.img Found linux image: /boot/kernel-6.12.3-gentoo-dist Found initrd image: /boot/initramfs-6.12.3-gentoo-dist.img Warning: os-prober will not be executed to detect other bootable partitions. Systems on them will not be added to the GRUB boot configuration. Check GRUB_DISABLE_OS_PROBER documentation entry. Adding boot menu entry for UEFI Firmware Settings ... done [x] /boot/kernel-6.12.1-gentoo-dist [-] /lib/modules/6.12.1-gentoo-dist [x] /boot/initramfs-6.12.1-gentoo-dist.img * Removing kernel other 6.12.3-gentoo-dist (not referenced by bootloader (grub2)) Generating grub configuration file ... Found linux image: /boot/kernel-6.12.5-gentoo-dist Found initrd image: /boot/initramfs-6.12.5-gentoo-dist.img Found linux image: /boot/kernel-6.12.4-gentoo-dist Found initrd image: /boot/initramfs-6.12.4-gentoo-dist.img Warning: os-prober will not be executed to detect other bootable partitions. Systems on them will not be added to the GRUB boot configuration. Check GRUB_DISABLE_OS_PROBER documentation entry. Adding boot menu entry for UEFI Firmware Settings ... done [x] /boot/kernel-6.12.3-gentoo-dist [-] /lib/modules/6.12.3-gentoo-dist [x] /boot/initramfs-6.12.3-gentoo-dist.img * Removing kernel other 6.12.4-gentoo-dist (not referenced by bootloader (grub2)) Generating grub configuration file ... Found linux image: /boot/kernel-6.12.5-gentoo-dist Found initrd image: /boot/initramfs-6.12.5-gentoo-dist.img Warning: os-prober will not be executed to detect other bootable partitions. Systems on them will not be added to the GRUB boot configuration. Check GRUB_DISABLE_OS_PROBER documentation entry. Adding boot menu entry for UEFI Firmware Settings ... done [x] /boot/kernel-6.12.4-gentoo-dist [-] /lib/modules/6.12.4-gentoo-dist [x] /boot/initramfs-6.12.4-gentoo-dist.img Removed 3 kernels DEBUG:root:Calling grub2-mkconfig Generating grub configuration file ... Found linux image: /boot/kernel-6.12.5-gentoo-dist Found initrd image: /boot/initramfs-6.12.5-gentoo-dist.img Warning: os-prober will not be executed to detect other bootable partitions. Systems on them will not be added to the GRUB boot configuration. Check GRUB_DISABLE_OS_PROBER documentation entry. Adding boot menu entry for UEFI Firmware Settings ... done ``` This is the cleanup result that Grub2 wants.
Of course, you can think it's not a bug. A counterargument is that I didn't use the correct layout parameters, haha. But this is very unintuitive. From the above boot partition structure, it looks very ordinary and standard. This is the directory structure installed according to the Gentoo handbook guide, and there is another key point in using std layout: you need to enable the zstd USE flag.
Got it working with "--layout std".
New discovery, I previously installed systemd-boot, so /efi left the bls layout. After deleting it, it works by default without using -L std. ``` ❯ sudo eclean-kernel --debug DEBUG:root:Sorter: <ecleankernel.sort.VersionSort object at 0x7fa3d3ca68a0> DEBUG:root:Layout failed: <class 'ecleankernel.layout.blspec.BlSpecLayout'>; exception: /boot/[EFI/]loader not found DEBUG:root:Layout: <ecleankernel.layout.std.StdLayout object at 0x7fa3d3d2b2c0> DEBUG:root:Bootloader failed: <class 'ecleankernel.bootloader.lilo.LILO'> DEBUG:root:/boot/grub/grub.cfg found DEBUG:root:Bootloader: <ecleankernel.bootloader.grub2.GRUB2 object at 0x7fa3d3d2b110> DEBUG:root:in get_removal_list() No outdated kernels found. ```
If there are multiple layouts that match the ecelan-kernel detection, should a warning be added? After all, the layouts used by grub and systemd-boot are quite different. In the situation mentioned above, systemd-boot is no longer in the system, so why is it still reasonable for bls to be selected? it seems reasonable to add a warning for this situation.