dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0180-ppc64le-sync-mkconfig-to-disk-1212114.patch

ecb9bb
From f1edaeeeffdfc291e0b17d87f8727baaecbfaf63 Mon Sep 17 00:00:00 2001
ecb9bb
From: Don Zickus <dzickus@redhat.com>
ecb9bb
Date: Wed, 22 Jul 2015 13:59:55 -0400
27a4da
Subject: [PATCH 180/260] ppc64le sync mkconfig to disk (#1212114)
ecb9bb
ecb9bb
If creating a new grub2 entry using grub2-mkconfig, the entry is not
ecb9bb
immediately sync'd to disk.  If a crash happens before the writeback,
ecb9bb
the subsequent reboot fails because the grub2.cfg is corrupted.
ecb9bb
ecb9bb
Address this by forcing all the changes (mainly the fs meta data) to disk
ecb9bb
before finishing the grub2 conf changes.
ecb9bb
ecb9bb
Tested by 'grub2-mkconfig -o /etc/grub22.cfg; echo c > /proc/sysrq-trigger'.
ecb9bb
ecb9bb
Before, the machine would panic and on reboot be stuck without a grub.cfg
ecb9bb
to read.  After, works as expected.
ecb9bb
ecb9bb
Resolves: rhbz#1212114
ecb9bb
---
ecb9bb
 util/grub-mkconfig.in | 9 +++++++++
ecb9bb
 1 file changed, 9 insertions(+)
ecb9bb
ecb9bb
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
27a4da
index e029d0d5e..cf315e241 100644
ecb9bb
--- a/util/grub-mkconfig.in
ecb9bb
+++ b/util/grub-mkconfig.in
ecb9bb
@@ -290,3 +290,12 @@ fi
ecb9bb
 
ecb9bb
 gettext "done" >&2
ecb9bb
 echo >&2
ecb9bb
+
ecb9bb
+# make sure changes make it to the disk.
ecb9bb
+# if /boot is a mountpoint, force the meta data on disk
ecb9bb
+# to by-pass writeback delay.
ecb9bb
+# PPC64LE-only to deal with Petitboot issues
ecb9bb
+ARCH=$(uname -m)
ecb9bb
+if [ "${ARCH}" = "ppc64le" ]; then
ecb9bb
+    sync && mountpoint -q /boot &&fsfreeze -f /boot && fsfreeze -u /boot
ecb9bb
+fi
ecb9bb
-- 
27a4da
2.13.0
ecb9bb