[PATCH] Order root fsck after dracut-pre-mount.service

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

 



Currently root fsck runs concurrently with dracut-pre-mount and so
races with resume from disk (started by dracut-pre-mount). This leads
to data corruption if fsck changes filesystem.

Make sure root fsck runs after dracut-pre-mount.service.

Details including console logs:
https://bugzilla.suse.com/show_bug.cgi?id=906592

Signed-off-by: Andrei Borzenkov <arvidjaar@xxxxxxxxx>

---
 modules.d/98systemd/rootfs-generator.sh | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/modules.d/98systemd/rootfs-generator.sh b/modules.d/98systemd/rootfs-generator.sh
index 9523729..a2d26b9 100755
--- a/modules.d/98systemd/rootfs-generator.sh
+++ b/modules.d/98systemd/rootfs-generator.sh
@@ -32,6 +32,22 @@ generator_wait_for_dev()
     fi
 }
 
+generator_fsck_after_pre_mount()
+{
+    local _name
+
+    [ -z "$1" ] && return 0
+
+    _name=$(dev_unit_name "$1")
+    [ -d /run/systemd/generator/systemd-fsck@${_name}.service.d ] || mkdir -p /run/systemd/generator/systemd-fsck@${_name}.service.d
+    if ! [ -f /run/systemd/generator/systemd-fsck@${_name}.service.d/after-pre-mount.conf ]; then
+        {
+            echo "[Unit]"
+            echo "After=dracut-pre-mount.service"
+        } > /run/systemd/generator/systemd-fsck@${_name}.service.d/after-pre-mount.conf
+    fi
+}
+
 root=$(getarg root=)
 case "$root" in
     block:LABEL=*|LABEL=*)
@@ -58,6 +74,9 @@ case "$root" in
         rootok=1 ;;
 esac
 
-[ "${root%%:*}" = "block" ] && generator_wait_for_dev "${root#block:}"
+if [ "${root%%:*}" = "block" ]; then
+    generator_wait_for_dev "${root#block:}"
+    generator_fsck_after_pre_mount "${root#block:}"
+fi
 
 exit 0
-- 
tg: (778b354..) u/root-fsck-after-pre-mount (depends on: master)
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux