update-initramfs and mkinitramfs should rename into place after creation

Bug #83629 reported by Ian Jackson on 2007-02-06
Affects Status Importance Assigned to Milestone
initramfs-tools (Ubuntu)

Bug Description

Binary package hint: initramfs-tools

update-initramfs calls mkinitramfs which truncates the output file straight away. This is very wrong.

mkinitramfs (or failing that, update-initramfs) should write out to a temporary file (<output-filename>.new, for example) and rename into place. Other approaches involve leaving an empty or truncated file on failure !

Ian Jackson (ijackson) on 2007-02-06
Changed in initramfs-tools:
importance: Undecided → High
Aurelien Naldi (aurelien.naldi) wrote :

In feisty, I can see some initrd-[...].bak files, which looks fine. Except it is clearly not working properly :/
When updating the initramfs is regenerated _many_ times: once for the kernel, once for udev, lvm, mdadm, initramfs-tools...
If the first one fails, it keeps the old working one as backup, which will be removed by the next generation of the initramfs....

As the new initramfs-tools refuses to generate initramfs for the edgy kernel, the old kernel gets broken during the update and at the end remains to empty files for it!

The "backup" is a good think but not used properly it becomes quite useless. In particular, if the newly created file is empty, then the backup should be kept and the "new" one discarded.

On a related note, I thought that a mechanism existed to push some scripts to the end of the update ? Generating initramfs only one at the end would make things much faster AND provide a (lame but still valuable) solution to this problem.

Paul R. (paul-nz) wrote :

I was also bitten by this bug when the Gutsy screen manager caused fglrx to hard-lock my PC upon trying to change the refresh rate, *when mkinitramfs was generating the initramfs*, leaving me with an unbootable system. No Joe Sixpack user could ever recover from such an arcane problem. The update of the in-place initramfs should be an *atomic operation*, i.e. move completed file into place, not wiping the existing one and creating a window of huge vulnerability (e.g. power cut during that time would nuke the system).

Changed in initramfs-tools:
status: New → Confirmed
Colin Watson (cjwatson) wrote :

This was fixed a while ago, for Ubuntu 8.04:

initramfs-tools (0.85eubuntu24) hardy; urgency=low

  * Implement the initramfs-tools part of the initramfs error handling spec
  * update-initramfs:
    - Make a hard link to the original initramfs image, rather than moving
      it out of the way.
    - Create a new initramfs image to ${initramfs}.new, to ensure we still
      have a functional initramfs in case of failure. The original initramfs
      only gets replaced when a new image is successfully created.
  * scripts/functions:
    - Added add_mountroot_fail_hook function to allow scripts in
      init-premount to register a hook to allow extra information
      to be given to the user, in the event of a non-existant root
    - The panic function now runs any registered mountroot fail hooks that
      were previously registered, and only does so when passed the -r
      argument from the calling function.
  * scripts/local: Call the panic function with -r to run any registered
    mountroot fail hooks when a root device cannot be found.

 -- Luke Yelavich <email address hidden> Tue, 05 Feb 2008 13:38:51 +1100

Changed in initramfs-tools:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers