update-initramfs: Run 'sync' after writing the initramfs

Bug #783620 involves several machines with root on xfs being upgraded
from wheezy to jessie and then immediately rebooted.  In some cases
the initramfs was apparently written to the journal but not committed
during the reboot.  As GRUB doesn't replay the journal, it loaded an
empty initramfs and the kernel failed to boot.

There is clearly a bug elsewhere (init system or kernel) that
prevented the filesystem being cleanly shut down.  However, there
seems to be a general risk here, so add a 'sync' to mitigate it.

Closes: #783620
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
This commit is contained in:
Ben Hutchings 2015-12-07 00:35:41 +00:00
parent 6a8d18b4e6
commit fa1985b91f

View File

@ -172,6 +172,8 @@ generate_initramfs()
if mkinitramfs ${OPTS} "${initramfs}.new" "${version}"; then
mv -f "${initramfs}.new" "${initramfs}"
set_sha1
# Guard against an unclean shutdown
sync
else
mkinitramfs_return="$?"
remove_initramfs_bak