"update-initramfs" is executed several times when you remove old kernels

Bug #1554455 reported by kay
68
This bug affects 14 people
Affects Status Importance Assigned to Milestone
initramfs-tools (Ubuntu)
Confirmed
Undecided
Unassigned
linux (Ubuntu)
Confirmed
Low
Unassigned

Bug Description

Here is an example. I had several old kernels:

linux-image-3.19.0-49-generic
linux-image-4.2.0-25-generic
linux-signed-image-3.19.0-49-generic
linux-signed-image-4.2.0-25-generic

I used apt-get autoremove and here is the result:

apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  grub-pc-bin linux-headers-3.19.0-49 linux-headers-3.19.0-49-generic
  linux-image-3.19.0-49-generic linux-image-4.2.0-25-generic
  linux-image-extra-3.19.0-49-generic linux-image-extra-4.2.0-25-generic
  linux-signed-image-3.19.0-49-generic linux-signed-image-4.2.0-25-generic
0 upgraded, 0 newly installed, 9 to remove and 0 not upgraded.
After this operation, 502 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 211099 files and directories currently installed.)
Removing grub-pc-bin (2.02~beta2-9ubuntu1.7) ...
Removing linux-headers-3.19.0-49-generic (3.19.0-49.55~14.04.1) ...
Removing linux-headers-3.19.0-49 (3.19.0-49.55~14.04.1) ...
Removing linux-signed-image-3.19.0-49-generic (3.19.0-49.55~14.04.1) ...
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.2.0-30-generic
Found initrd image: /boot/initrd.img-4.2.0-30-generic
Found linux image: /boot/vmlinuz-4.2.0-27-generic
Found initrd image: /boot/initrd.img-4.2.0-27-generic
Found linux image: /boot/vmlinuz-3.19.0-51-generic
Found initrd image: /boot/initrd.img-3.19.0-51-generic
Found linux image: /boot/vmlinuz-3.19.0-49-generic
Found initrd image: /boot/initrd.img-3.19.0-49-generic
Found linux image: /boot/vmlinuz-4.2.0-30-generic
Found initrd image: /boot/initrd.img-4.2.0-30-generic
Found linux image: /boot/vmlinuz-4.2.0-27-generic
Found initrd image: /boot/initrd.img-4.2.0-27-generic
Found linux image: /boot/vmlinuz-3.19.0-51-generic
Found initrd image: /boot/initrd.img-3.19.0-51-generic
Found linux image: /boot/vmlinuz-3.19.0-49-generic
Found initrd image: /boot/initrd.img-3.19.0-49-generic
Found Windows Boot Manager on /dev/sda2@/EFI/Microsoft/Boot/bootmgfw.efi
Found Ubuntu Xenial Xerus (development branch) (16.04) on /dev/mapper/VG-root
Adding boot menu entry for EFI firmware configuration
done
Removing linux-image-extra-3.19.0-49-generic (3.19.0-49.55~14.04.1) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.19.0-49-generic /boot/vmlinuz-3.19.0-49-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.19.0-49-generic /boot/vmlinuz-3.19.0-49-generic
update-initramfs: Generating /boot/initrd.img-3.19.0-49-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 3.19.0-49-generic /boot/vmlinuz-3.19.0-49-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 3.19.0-49-generic /boot/vmlinuz-3.19.0-49-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.19.0-49-generic /boot/vmlinuz-3.19.0-49-generic
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.2.0-30-generic
Found initrd image: /boot/initrd.img-4.2.0-30-generic
Found linux image: /boot/vmlinuz-4.2.0-27-generic
Found initrd image: /boot/initrd.img-4.2.0-27-generic
Found linux image: /boot/vmlinuz-3.19.0-51-generic
Found initrd image: /boot/initrd.img-3.19.0-51-generic
Found linux image: /boot/vmlinuz-3.19.0-49-generic
Found initrd image: /boot/initrd.img-3.19.0-49-generic
Found linux image: /boot/vmlinuz-4.2.0-30-generic
Found initrd image: /boot/initrd.img-4.2.0-30-generic
Found linux image: /boot/vmlinuz-4.2.0-27-generic
Found initrd image: /boot/initrd.img-4.2.0-27-generic
Found linux image: /boot/vmlinuz-3.19.0-51-generic
Found initrd image: /boot/initrd.img-3.19.0-51-generic
Found linux image: /boot/vmlinuz-3.19.0-49-generic
Found initrd image: /boot/initrd.img-3.19.0-49-generic
Found Windows Boot Manager on /dev/sda2@/EFI/Microsoft/Boot/bootmgfw.efi
Found Ubuntu Xenial Xerus (development branch) (16.04) on /dev/mapper/VG-root
Adding boot menu entry for EFI firmware configuration
done
Removing linux-image-3.19.0-49-generic (3.19.0-49.55~14.04.1) ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.19.0-49-generic /boot/vmlinuz-3.19.0-49-generic
update-initramfs: Deleting /boot/initrd.img-3.19.0-49-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.19.0-49-generic /boot/vmlinuz-3.19.0-49-generic
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.2.0-30-generic
Found initrd image: /boot/initrd.img-4.2.0-30-generic
Found linux image: /boot/vmlinuz-4.2.0-27-generic
Found initrd image: /boot/initrd.img-4.2.0-27-generic
Found linux image: /boot/vmlinuz-3.19.0-51-generic
Found initrd image: /boot/initrd.img-3.19.0-51-generic
Found linux image: /boot/vmlinuz-4.2.0-30-generic
Found initrd image: /boot/initrd.img-4.2.0-30-generic
Found linux image: /boot/vmlinuz-4.2.0-27-generic
Found initrd image: /boot/initrd.img-4.2.0-27-generic
Found linux image: /boot/vmlinuz-3.19.0-51-generic
Found initrd image: /boot/initrd.img-3.19.0-51-generic
Found Windows Boot Manager on /dev/sda2@/EFI/Microsoft/Boot/bootmgfw.efi
Found Ubuntu Xenial Xerus (development branch) (16.04) on /dev/mapper/VG-root
Adding boot menu entry for EFI firmware configuration
done
Removing linux-signed-image-4.2.0-25-generic (4.2.0-25.30~14.04.1) ...
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.2.0-30-generic
Found initrd image: /boot/initrd.img-4.2.0-30-generic
Found linux image: /boot/vmlinuz-4.2.0-27-generic
Found initrd image: /boot/initrd.img-4.2.0-27-generic
Found linux image: /boot/vmlinuz-3.19.0-51-generic
Found initrd image: /boot/initrd.img-3.19.0-51-generic
Found linux image: /boot/vmlinuz-4.2.0-30-generic
Found initrd image: /boot/initrd.img-4.2.0-30-generic
Found linux image: /boot/vmlinuz-4.2.0-27-generic
Found initrd image: /boot/initrd.img-4.2.0-27-generic
Found linux image: /boot/vmlinuz-3.19.0-51-generic
Found initrd image: /boot/initrd.img-3.19.0-51-generic
Found Windows Boot Manager on /dev/sda2@/EFI/Microsoft/Boot/bootmgfw.efi
Found Ubuntu Xenial Xerus (development branch) (16.04) on /dev/mapper/VG-root
Adding boot menu entry for EFI firmware configuration
done
Removing linux-image-extra-4.2.0-25-generic (4.2.0-25.30~14.04.1) ...
depmod: FATAL: could not load /boot/System.map-4.2.0-25-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
update-initramfs: Generating /boot/initrd.img-4.2.0-25-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.2.0-30-generic
Found initrd image: /boot/initrd.img-4.2.0-30-generic
Found linux image: /boot/vmlinuz-4.2.0-27-generic
Found initrd image: /boot/initrd.img-4.2.0-27-generic
Found linux image: /boot/vmlinuz-3.19.0-51-generic
Found initrd image: /boot/initrd.img-3.19.0-51-generic
Found linux image: /boot/vmlinuz-4.2.0-30-generic
Found initrd image: /boot/initrd.img-4.2.0-30-generic
Found linux image: /boot/vmlinuz-4.2.0-27-generic
Found initrd image: /boot/initrd.img-4.2.0-27-generic
Found linux image: /boot/vmlinuz-3.19.0-51-generic
Found initrd image: /boot/initrd.img-3.19.0-51-generic
Found Windows Boot Manager on /dev/sda2@/EFI/Microsoft/Boot/bootmgfw.efi
Found Ubuntu Xenial Xerus (development branch) (16.04) on /dev/mapper/VG-root
Adding boot menu entry for EFI firmware configuration
done
Removing linux-image-4.2.0-25-generic (4.2.0-25.30~14.04.1) ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
update-initramfs: Deleting /boot/initrd.img-4.2.0-25-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.2.0-30-generic
Found initrd image: /boot/initrd.img-4.2.0-30-generic
Found linux image: /boot/vmlinuz-4.2.0-27-generic
Found initrd image: /boot/initrd.img-4.2.0-27-generic
Found linux image: /boot/vmlinuz-3.19.0-51-generic
Found initrd image: /boot/initrd.img-3.19.0-51-generic
Found linux image: /boot/vmlinuz-4.2.0-30-generic
Found initrd image: /boot/initrd.img-4.2.0-30-generic
Found linux image: /boot/vmlinuz-4.2.0-27-generic
Found initrd image: /boot/initrd.img-4.2.0-27-generic
Found linux image: /boot/vmlinuz-3.19.0-51-generic
Found initrd image: /boot/initrd.img-3.19.0-51-generic
Found Windows Boot Manager on /dev/sda2@/EFI/Microsoft/Boot/bootmgfw.efi
Found Ubuntu Xenial Xerus (development branch) (16.04) on /dev/mapper/VG-root
Adding boot menu entry for EFI firmware configuration
done

apt has executed "update-initramfs" three times! Same for the grub (but here we have 6 times!). Looks like some triggers are not optimized.

Didn't find duplicate but probably relates to these issues:
https://bugs.launchpad.net/ubuntu/+source/initramfs-tools/+bug/184852
https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1505805
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=574336
https://bugs.dogfood.paddev.net/ubuntu/+source/linux-ports-meta/+bug/303644
https://bugs.launchpad.net/ubuntu/+source/initramfs-tools/+bug/798414

Revision history for this message
kay (kay-diam) wrote :
affects: initramfs-tools (Ubuntu) → linux-meta (Ubuntu)
description: updated
Brad Figg (brad-figg)
affects: linux-meta (Ubuntu) → linux (Ubuntu)
kay (kay-diam)
description: updated
Revision history for this message
Brad Figg (brad-figg) wrote : Missing required logs.

This bug is missing log files that will aid in diagnosing the problem. From a terminal window please run:

apport-collect 1554455

and then change the status of the bug to 'Confirmed'.

If, due to the nature of the issue you have encountered, you are unable to run this command, please add a comment stating that fact and change the bug status to 'Confirmed'.

This change has been made by an automated script, maintained by the Ubuntu Kernel Team.

Changed in linux (Ubuntu):
status: New → Incomplete
Revision history for this message
kay (kay-diam) wrote :

This bug doesn't require additional logs.

Changed in linux (Ubuntu):
status: Incomplete → Confirmed
penalvch (penalvch)
Changed in linux (Ubuntu):
importance: Undecided → Low
Revision history for this message
rebroad (rebroad) wrote :

Yes, it does seem odd that all of the initrd.img files in /boot are recreated from scratch just because I'm removing versions of the kernel...

Revision history for this message
Loic (lbndev) wrote :

I think this bug's priority should be raised.
When automated install of security updates is enabled, /boot fills up, newer kernel are in a "partially installed" state, and then apt-get autoremove fails because of all the old outdated initrds that keep being re-created (despite the associated kernel is being removed)

Revision history for this message
vontrapp (von-fugal) wrote :

Why is this still an issue? Why is it not resolved? It's been 2 years?

Consider this simple scenario right now as I apt-get autoremove and it removes 4 old kernels. It also keeps 3 kernels.

Generating the initrd for a single kernel takes ballpark 45 seconds.

First step: remove one kernel and generate 6 (!!) initrds.
Second step: remove another kernel. Generate 5 (!!) initrds.
Step 3: remove another kernel. Generate 4 initrds.
Step 4: remove fourth kernel. Generate 3 initrds.

Final count: 18 initrds generated. That takes 13 minutes!

It really only needed to generate 3, if that!

Revision history for this message
John Bucy (bucy) wrote :

+1

uninstalling a linux-image package regenerates the initrd.img for that kernel and then immediately deletes it

from 16.04
Removing linux-image-4.4.0-119-generic (4.4.0-119.143) ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.4.0-119-generic /boot/vmlinuz-4.4.0-119-generic
update-initramfs: Deleting /boot/initrd.img-4.4.0-119-generic

Brad Figg (brad-figg)
tags: added: cscc
Revision history for this message
Von (straeker) wrote :

It's been 4 years and nothing has been changed, this still happening.
executing "update-initramfs" several times is wasting of processing power and time.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in initramfs-tools (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.