[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#783620: [PATCH initramfs-tools] update-initramfs: Run 'sync' after writing the initramfs



Control: tag -1 patch
---
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>
---
 update-initramfs | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/update-initramfs b/update-initramfs
index ea301ba..161010d 100755
--- a/update-initramfs
+++ b/update-initramfs
@@ -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
-- 
Ben Hutchings
Theory and practice are closer in theory than in practice.
                                - John Levine, moderator of comp.compilers

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: