Blob Blame History Raw
From 29a9e92999f7b7c977bba4d8cc59233cd3fbf986 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@hoyer.xyz>
Date: Tue, 19 Dec 2017 15:35:18 +0100
Subject: [PATCH] Merge pull request #331 from fcami/master-fsfreeze

call fsfreeze(8) on /boot to flush initramfs data & metadata to media
---
 dracut.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/dracut.sh b/dracut.sh
index 8daafc35..f5c8d74c 100755
--- a/dracut.sh
+++ b/dracut.sh
@@ -1828,8 +1828,13 @@ fi
 command -v restorecon &>/dev/null && restorecon -- "$outfile"
 
 if ! sync "$outfile" 2> /dev/null; then
-    dinfo "dracut: sync operartion on newly created initramfs $outfile failed"
+    dinfo "dracut: sync operation on newly created initramfs $outfile failed"
     exit 1
+# use fsfreeze only if we're not writing to /
+elif ! [ "$(stat -c %m -- "$outfile")" == "/" ]; then
+    if ! $(fsfreeze -f $(dirname "$outfile") 2>/dev/null && fsfreeze -u $(dirname "$outfile") 2>/dev/null); then
+        dinfo "dracut: warning: could not fsfreeze $(dirname "$outfile")"
+    fi
 fi
 
 exit 0