Bug 858840

Summary: Kernel update complexity (excess use of mkinitrd); extended "unsafe" period
Product: [openSUSE] openSUSE 12.3 Reporter: Ulrich Windl <Ulrich.Windl>
Component: Update ProblemsAssignee: E-mail List <kernel-maintainers>
Status: RESOLVED DUPLICATE QA Contact: Jiri Srain <jsrain>
Severity: Normal    
Priority: P5 - None CC: mrmazda, tiwai
Version: Final   
Target Milestone: ---   
Hardware: All   
OS: openSUSE 12.3   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Bug Depends on: 786318    
Bug Blocks:    

Description Ulrich Windl 2014-01-15 10:23:50 UTC
User-Agent:       Mozilla/5.0 (X11; Linux i686; rv:26.0) Gecko/20100101 Firefox/26.0

For systems where more than one kernel (n kernels) is installed (e.g. multiple versions or flavors), mkinitrd creates an initrd for each. So far, so good.

Unfortunately a single "kernel" consists of two or more packages which are installed in a somewhat loose order. Each %post script of a kernel package calls mkinitrd, which in turn, re-creates the initrds for each kernel found.

Despite the fact that the "useless temporary" initrd updates waste time and CPU cycles, there is a danger associated with this: If you update your kernel (say from 2.6.x to 3.0.y), the first mkinitrd of the first kernel package created an initrd that does not fit to the rest of the kernel. If the system crashes or the power goes out (or a cluster node fences the server), the system may be unbootable (modules in initrd not matching the kernel image).

Reproducible: Always

Steps to Reproduce:
1. Watch kernel updates

Actual Results:  
Multiple mkinitd calls are observerd

Expected Results:  
mkinitrd should be deferred until all the kernel-related updates are on disk.

For example: I installed updates for kernel and multipath. multipath-update alone built the initrd several times:
2014-01-15 10:41:51 <1> pc(10330) [zypp] RpmDb.cc(doInstallPackage):1849 RpmDb::installPackage(/var/cache/zypp/packages/repo-update/i586/multipath-tools-0.4.9-7.5.1.i586.rpm,0x0000000c)
[...]
2014-01-15 10:52:46 <1> pc(10330) [zypp] RpmDb.cc(doInstallPackage):1849 RpmDb::installPackage(/var/cache/zypp/packages/repo-update/i586/parted-2.4-30.4.1.i586.rpm,0x0000000c)

That is 11 minutes to wait just for the update of multipath-tools!
Each of my 3 kernels got its initrd build at least two times during that.
Comment 1 Takashi Iwai 2014-03-17 09:52:12 UTC
Nowadays multiple kernels are installed as default, so "no bootable" won't happen by this scenario, at least.  If we consider only a single kernel on system, deferring the initrd creation is also risky when the operation is aborted after the removal of old package contents (but before initrd creation).

Though, I think the new %posttrans would fit better for such a task, too.  But this doesn't reduce the potential risk of breakage.
Comment 2 Felix Miata 2014-03-17 16:43:42 UTC
Is this materially different from bug 786318?
Comment 3 Takashi Iwai 2014-03-17 16:50:16 UTC
Looks same.  The zypper part should have been already fixed in 13.1, so the rest is rather the implementation in the kernel package side.  I can close as DUP, but the bug 786318 subject looks also confusing (which was already fixed, per se).
Comment 4 Felix Miata 2014-03-17 17:09:24 UTC
Nothing WRT bug 786318's original summary and comment 0 has changed, other than post-13.1 the problem is dracut called instead of mkinitrd.
Comment 5 Takashi Iwai 2014-03-18 14:37:26 UTC
Let's track in a single bug.

*** This bug has been marked as a duplicate of bug 786318 ***
Comment 6 Michael Andres 2014-03-18 15:26:52 UTC
> Looks same.

Note that like rpm, libzypp does not unify %posttrans scripts. The fix in bug #786318 delays execution of %posttrans scripts until all packages are actually installed (as it should be). The total number of script invocations does not change.
Comment 7 Takashi Iwai 2014-03-18 15:40:02 UTC
Yes, but we can limit the execution, e.g. by executing only when some file is present.  A similar trick was found in the recent font configuration, IIRC.
Comment 8 Michael Andres 2014-03-19 08:37:20 UTC
So this (excess use of mkinitrd) is actually not a duplicate of bug#786318 (which covers the zypp aspect) but may have been blocked by it. If the kernel %posttrans scripts are not yet fixed, we should consider reopening this, so it does not get lost.