eclean-kernel icon indicating copy to clipboard operation
eclean-kernel copied to clipboard

Too many initramfs files are removed

Open JulienDlq opened this issue 4 years ago • 8 comments

I have the following inside my /boot.

ls -1 /boot
amd-uc.img
EFI
grub
initramfs-5.8.1-gentoo-x86_64.img
initramfs-5.8.1-gentoo-x86_64.old.img
initramfs-5.8.2-gentoo-x86_64.img
intel-uc.img
lost+found
System.map-5.8.1-gentoo-x86_64
System.map-5.8.1-gentoo-x86_64.old
System.map-5.8.2-gentoo-x86_64
vmlinuz-5.8.1-gentoo-x86_64
vmlinuz-5.8.1-gentoo-x86_64.old
vmlinuz-5.8.2-gentoo-x86_64

If I perform the following command I can see that only the .old kernel and related files will be removed.

eclean-kernel -d -n 2 -p            
These are the kernels which would be removed:
- 5.8.1-gentoo-x86_64.old: unwanted
kernel-install will be called to perform prerm tasks.

In order to be sure, I run the following command.

eclean-kernel -l        
5.8.2-gentoo-x86_64 [5.8.2-gentoo-x86_64]:
- vmlinuz: /boot/vmlinuz-5.8.2-gentoo-x86_64
- systemmap: /boot/System.map-5.8.2-gentoo-x86_64
- initramfs: /boot/initramfs-5.8.2-gentoo-x86_64.img
- modules: /lib/modules/5.8.2-gentoo-x86_64
- build: /usr/src/linux-5.8.2-gentoo
- last modified: 2020-08-20 16:21:44
5.8.1-gentoo-x86_64 [5.8.1-gentoo-x86_64]:
- vmlinuz: /boot/vmlinuz-5.8.1-gentoo-x86_64
- systemmap: /boot/System.map-5.8.1-gentoo-x86_64
- initramfs: /boot/initramfs-5.8.1-gentoo-x86_64.img
- modules: /lib/modules/5.8.1-gentoo-x86_64
- build: /usr/src/linux-5.8.1-gentoo
- last modified: 2020-08-18 18:35:56
5.8.1-gentoo-x86_64.old [5.8.1-gentoo-x86_64]:
- vmlinuz: /boot/vmlinuz-5.8.1-gentoo-x86_64.old
- systemmap: /boot/System.map-5.8.1-gentoo-x86_64.old
- initramfs: /boot/initramfs-5.8.1-gentoo-x86_64.old.img
- modules: /lib/modules/5.8.1-gentoo-x86_64
- build: /usr/src/linux-5.8.1-gentoo
- last modified: 2020-08-18 18:35:56

If I run the following command, it seems to perform what it is expected.

eclean-kernel -d -n 2   
* Removing kernel 5.8.1-gentoo-x86_64.old (unwanted)
- /boot/vmlinuz-5.8.1-gentoo-x86_64.old
- /boot/System.map-5.8.1-gentoo-x86_64.old
- /boot/initramfs-5.8.1-gentoo-x86_64.old.img
Removed 1 kernels

But if I double check, actually, eclean-kernel also removed the /boot/initramfs-5.8.1-gentoo-x86_64.img file. I didn't asked for that!

ls -1 /boot               
amd-uc.img
EFI
grub
initramfs-5.8.2-gentoo-x86_64.img
intel-uc.img
lost+found
System.map-5.8.1-gentoo-x86_64
System.map-5.8.2-gentoo-x86_64
vmlinuz-5.8.1-gentoo-x86_64
vmlinuz-5.8.2-gentoo-x86_64

It seems that initramfs management is buggy. :cry:

JulienDlq avatar Aug 20 '20 17:08 JulienDlq

I also tried with 2.99.1. I have the same issue.

eclean-kernel -D -d -n 2
DEBUG:root:Trying bootloader lilo
DEBUG:root:Trying bootloader grub2
DEBUG:root:/boot/grub/grub.cfg found
DEBUG:root:in get_removal_list()
Legend:
[-] file being removed
[x] file does not exist (anymore)
[+] file being kept (used by other kernels

* Removing kernel 5.8.1-gentoo-x86_64.old (unwanted)
 [-] /boot/vmlinuz-5.8.1-gentoo-x86_64.old
 [+] /usr/src/linux-5.8.1-gentoo
 [+] /lib/modules/5.8.1-gentoo-x86_64
 [-] /boot/System.map-5.8.1-gentoo-x86_64.old
 [-] /boot/initramfs-5.8.1-gentoo-x86_64.old.img
Removed 1 kernels
ls -1 /boot     
amd-uc.img
EFI
grub
initramfs-5.8.2-gentoo-x86_64.img
intel-uc.img
lost+found
System.map-5.8.1-gentoo-x86_64
System.map-5.8.2-gentoo-x86_64
vmlinuz-5.8.1-gentoo-x86_64
vmlinuz-5.8.2-gentoo-x86_64

JulienDlq avatar Aug 20 '20 18:08 JulienDlq

Ok even if I tell my scripts to save previous initramfs with .img.old extension instead of .old.img, I still have the same issue.

But it seems that grub-mkconfig do not recognise the right initramfs for the right kernel!

grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.8.2-gentoo-x86_64
Found initrd image: /boot/intel-uc.img /boot/amd-uc.img /boot/initramfs-5.8.2-gentoo-x86_64.img
Found linux image: /boot/vmlinuz-5.8.1-gentoo-x86_64
Found initrd image: /boot/intel-uc.img /boot/amd-uc.img /boot/initramfs-5.8.1-gentoo-x86_64.img
Found linux image: /boot/vmlinuz-5.8.1-gentoo-x86_64.old
Found initrd image: /boot/intel-uc.img /boot/amd-uc.img /boot/initramfs-5.8.1-gentoo-x86_64.img
done

If a rename back the old initramfs file to /boot/initramfs-5.8.1-gentoo-x86_64.old.img.

grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.8.2-gentoo-x86_64
Found initrd image: /boot/intel-uc.img /boot/amd-uc.img /boot/initramfs-5.8.2-gentoo-x86_64.img
Found linux image: /boot/vmlinuz-5.8.1-gentoo-x86_64
Found initrd image: /boot/intel-uc.img /boot/amd-uc.img /boot/initramfs-5.8.1-gentoo-x86_64.img
Found linux image: /boot/vmlinuz-5.8.1-gentoo-x86_64.old
Found initrd image: /boot/intel-uc.img /boot/amd-uc.img /boot/initramfs-5.8.1-gentoo-x86_64.old.img
done

Everything is fine.

So the old initramfs file must be named initramfs-<version>.old.img.

JulienDlq avatar Aug 20 '20 18:08 JulienDlq

Do I understand correctly that it's removing a file even though it doesn't say it's removing it?

Could you verify that it isn't kernel-install removing it? E.g. rename it or move out of PATH, and try eclean-kernel then.

mgorny avatar Sep 22 '20 07:09 mgorny

I'm having the very same issue here

runcom avatar Apr 19 '23 16:04 runcom

Could you verify that it isn't kernel-install removing it? E.g. rename it or move out of PATH, and try eclean-kernel then.

I can confirm it's kernel-install removing the other files indeed :man_facepalming: I'll run with --no-kernel-install and check it works

runcom avatar Apr 19 '23 16:04 runcom

I can confirm it's kernel-install removing the other files indeed man_facepalming I'll run with --no-kernel-install and check it works

I can confirm that running with --no-kernel-install "solves" the issue as in, it doesn't delete the initiramfs for the currentl (not old) kernel. Running without does indeed call kernel-install and as a result, it removes the initramfs (the "old" one). Any way to report this upstream in systemd perhaps?

runcom avatar Apr 19 '23 18:04 runcom

Do you have dracut installed? I think this removal may be happening due to /usr/lib/kernel/install.d/50-dracut.install. I think an easy way to confirm would be to remove that file and see if it still happens.

In any case, this is going to be hard because there are so many different /boot layouts…

mgorny avatar Apr 24 '23 06:04 mgorny

Same here, my initramfs images are deleted despite not being listed as being removed by eclean-kernel.

I'm using dracut. Removing /usr/lib/kernel/install.d/50-dracut.install doesn't make any difference for me.

However, using --no-kernel-install as suggested by @runcom also solves the issue on my end.

% eclean-kernel --version
2.99.7
% equery u app-admin/eclean-kernel
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for app-admin/eclean-kernel-2.99.7:
 U I
 - - lz4                       : Enable support for lz4 compression (as implemented in app-arch/lz4)
 - - lzo                       : Enable support for lzo compression
 - - python_targets_python3_10 : Build with Python 3.10
 - - python_targets_python3_11 : Build with Python 3.11
 + + python_targets_python3_12 : Build with Python 3.12
 - - test                      : Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled
                                 independently)
 - - zstd                      : Enable support for ZSTD compression
% ls /boot
EFI
grub
config-6.1.90-gentoo-custom
config-6.1.90-gentoo-custom.old
config-6.6.30-gentoo-custom
config-6.6.30-gentoo-custom.old
initramfs-6.1.90-gentoo-custom.img
initramfs-6.6.30-gentoo-custom.img
intel-uc.img
System.map-6.1.90-gentoo-custom
System.map-6.1.90-gentoo-custom.old
System.map-6.6.30-gentoo-custom
System.map-6.6.30-gentoo-custom.old
vmlinuz-6.1.90-gentoo-custom
vmlinuz-6.1.90-gentoo-custom.old
vmlinuz-6.6.30-gentoo-custom
vmlinuz-6.6.30-gentoo-custom.old
% sudo eclean-kernel -A -n 1
Preserving currently running kernel (6.1.90-gentoo-custom)
Legend:
[-] file being removed
[x] file does not exist (anymore)
[+] file being kept (used by other kernels)

Remove other 6.6.30-gentoo-custom.old (not referenced by bootloader (grub2))? [Yes/No]yes
Remove other 6.1.90-gentoo-custom.old (not referenced by bootloader (grub2))? [Yes/No]yes
* Removing kernel other 6.6.30-gentoo-custom.old (not referenced by bootloader (grub2))
 [-] /boot/vmlinuz-6.6.30-gentoo-custom.old
 [+] /usr/src/linux-6.6.30-gentoo
 [+] /lib/modules/6.6.30-gentoo-custom
 [-] /boot/System.map-6.6.30-gentoo-custom.old
 [-] /boot/config-6.6.30-gentoo-custom.old
* Removing kernel other 6.1.90-gentoo-custom.old (not referenced by bootloader (grub2))
 [-] /boot/vmlinuz-6.1.90-gentoo-custom.old
 [+] /usr/src/linux-6.1.90-gentoo
 [+] /lib/modules/6.1.90-gentoo-custom
 [-] /boot/System.map-6.1.90-gentoo-custom.old
 [-] /boot/config-6.1.90-gentoo-custom.old
Removed 2 kernels
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.6.30-gentoo-custom
Found initrd image: /boot/intel-uc.img
Found linux image: /boot/vmlinuz-6.1.90-gentoo-custom
Found initrd image: /boot/intel-uc.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
% ls /boot
EFI
grub
config-6.1.90-gentoo-custom
config-6.6.30-gentoo-custom
intel-uc.img
System.map-6.1.90-gentoo-custom
System.map-6.6.30-gentoo-custom
vmlinuz-6.1.90-gentoo-custom
vmlinuz-6.6.30-gentoo-custom
% sudo eclean-kernel -A -n 1 --no-kernel-install
Preserving currently running kernel (6.1.90-gentoo-custom)
Legend:
[-] file being removed
[x] file does not exist (anymore)
[+] file being kept (used by other kernels)

Remove other 6.6.30-gentoo-custom.old (not referenced by bootloader (grub2))? [Yes/No]yes
Remove other 6.1.90-gentoo-custom.old (not referenced by bootloader (grub2))? [Yes/No]yes
* Removing kernel other 6.6.30-gentoo-custom.old (not referenced by bootloader (grub2))
 [-] /boot/vmlinuz-6.6.30-gentoo-custom.old
 [+] /usr/src/linux-6.6.30-gentoo
 [+] /lib/modules/6.6.30-gentoo-custom
 [-] /boot/System.map-6.6.30-gentoo-custom.old
 [-] /boot/config-6.6.30-gentoo-custom.old
* Removing kernel other 6.1.90-gentoo-custom.old (not referenced by bootloader (grub2))
 [-] /boot/vmlinuz-6.1.90-gentoo-custom.old
 [+] /usr/src/linux-6.1.90-gentoo
 [+] /lib/modules/6.1.90-gentoo-custom
 [-] /boot/System.map-6.1.90-gentoo-custom.old
 [-] /boot/config-6.1.90-gentoo-custom.old
Removed 2 kernels
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.6.30-gentoo-custom
Found initrd image: /boot/intel-uc.img /boot/initramfs-6.6.30-gentoo-custom.img
Found linux image: /boot/vmlinuz-6.1.90-gentoo-custom
Found initrd image: /boot/intel-uc.img /boot/initramfs-6.1.90-gentoo-custom.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
% ls /boot
EFI
grub
config-6.1.90-gentoo-custom
config-6.6.30-gentoo-custom
initramfs-6.1.90-gentoo-custom.img
initramfs-6.6.30-gentoo-custom.img
intel-uc.img
System.map-6.1.90-gentoo-custom
System.map-6.6.30-gentoo-custom
vmlinuz-6.1.90-gentoo-custom
vmlinuz-6.6.30-gentoo-custom

Edit: also tried --exclude initramfs but the initramfs images were still deleted. Only --no-kernel-install seems to do the trick.

xfzv avatar May 28 '24 14:05 xfzv