Blame 0009-fstab-do-not-mount-and-fsck-from-fstab-if-using-syst.patch

Harald Hoyer 240f09
From e920bfb1e8a5917e7b0f360d1c51d200db3acbfd Mon Sep 17 00:00:00 2001
Harald Hoyer 240f09
From: WANG Chao <chaowang@redhat.com>
Harald Hoyer 240f09
Date: Tue, 1 Apr 2014 15:20:49 +0800
Harald Hoyer 240f09
Subject: [PATCH] fstab: do not mount and fsck from fstab if using systemd
Harald Hoyer 240f09
Harald Hoyer 240f09
If using systemd in initramfs, we could run into a race condition when
Harald Hoyer 240f09
dracut and systemd both are trying to mount and run fsck for the same
Harald Hoyer 240f09
filesystem, and mount or fsck could be a failure.
Harald Hoyer 240f09
Harald Hoyer 240f09
To fix such failure, we should use systemd to mount/fsck from /etc/fstab
Harald Hoyer 240f09
only.
Harald Hoyer 240f09
Harald Hoyer 240f09
v2: check $DRACUT_SYSTEMD suggested by Alexander Tsoy
Harald Hoyer 240f09
Harald Hoyer 240f09
Signed-off-by: WANG Chao <chaowang@redhat.com>
Harald Hoyer 240f09
---
Harald Hoyer 240f09
 modules.d/95fstab-sys/mount-sys.sh | 6 +++++-
Harald Hoyer 240f09
 1 file changed, 5 insertions(+), 1 deletion(-)
Harald Hoyer 240f09
Harald Hoyer 240f09
diff --git a/modules.d/95fstab-sys/mount-sys.sh b/modules.d/95fstab-sys/mount-sys.sh
Zbigniew Jędrzejewski-Szmek 7f4a44
index 12711a07dd..a23781012f 100755
Harald Hoyer 240f09
--- a/modules.d/95fstab-sys/mount-sys.sh
Harald Hoyer 240f09
+++ b/modules.d/95fstab-sys/mount-sys.sh
Harald Hoyer 240f09
@@ -27,7 +27,11 @@ fstab_mount() {
Harald Hoyer 240f09
     return 0
Harald Hoyer 240f09
 }
Harald Hoyer 240f09
 
Harald Hoyer 240f09
-[ -f /etc/fstab ] && fstab_mount /etc/fstab
Harald Hoyer 240f09
+# systemd will mount and run fsck from /etc/fstab and we don't want to
Harald Hoyer 240f09
+# run into a race condition.
Harald Hoyer 240f09
+if [ -z "$DRACUT_SYSTEMD" ]; then
Harald Hoyer 240f09
+    [ -f /etc/fstab ] && fstab_mount /etc/fstab
Harald Hoyer 240f09
+fi
Harald Hoyer 240f09
 
Harald Hoyer 240f09
 # prefer $NEWROOT/etc/fstab.sys over local /etc/fstab.sys
Harald Hoyer 240f09
 if [ -f $NEWROOT/etc/fstab.sys ]; then
Zbigniew Jędrzejewski-Szmek 7f4a44
-- 
Zbigniew Jędrzejewski-Szmek 7f4a44
1.9.3
Zbigniew Jędrzejewski-Szmek 7f4a44