Blame SOURCES/0272-base-Don-t-wait-for-swap-devices-in-host-only-mode.patch

64b87c
From 589b4e61e2db2a5835b5aa425268f6f0f67c14e4 Mon Sep 17 00:00:00 2001
64b87c
From: Colin Guthrie <colin@mageia.org>
64b87c
Date: Fri, 15 May 2015 14:53:40 +0100
64b87c
Subject: [PATCH] base: Don't wait for swap devices in host-only mode.
64b87c
64b87c
The only reason we add swap devices to host-only mode (added in
64b87c
dd5875499ece9dbc90e10eafd0073ee15d0c86a4) is to allow us to process
64b87c
resume= arguments passed on the kernel command line when the swap
64b87c
partition lives on something slightly more complex than a normal
64b87c
partion (e.g. in an LVM or RAID setup).
64b87c
64b87c
By adding the device to host_devs, the necessary LVM and RAID hooks
64b87c
are added and thus the underlying storage will be initialised OK, and
64b87c
the 95resume module handles the waiting for the device (via udev rules
64b87c
creating the /dev/resume symlink).
64b87c
64b87c
So ultimately, we do not need to hard-code the waiting for the swap
64b87c
devices into the initramfs at build time as the waiting part can be
64b87c
dynamic.
64b87c
64b87c
This makes things more resiliant to swap partitions disappearing and
64b87c
being reformatted etc.
64b87c
64b87c
Inspired by a patch by Martin Whitaker on Mageia bug:
64b87c
https://bugs.mageia.org/show_bug.cgi?id=12305
64b87c
64b87c
(cherry picked from commit 3e3ed34f036a833ccc2150c6224d0a954e841e39)
64b87c
---
64b87c
 dracut.sh                        | 6 ++++--
64b87c
 modules.d/99base/module-setup.sh | 8 ++++++++
64b87c
 2 files changed, 12 insertions(+), 2 deletions(-)
64b87c
64b87c
diff --git a/dracut.sh b/dracut.sh
64b87c
index a214f81..90ac1fe 100755
64b87c
--- a/dracut.sh
64b87c
+++ b/dracut.sh
64b87c
@@ -1056,7 +1056,9 @@ if [[ $hostonly ]]; then
64b87c
                     done < /etc/crypttab
64b87c
                 fi
64b87c
 
64b87c
-                push host_devs "$(readlink -f "$dev")"
64b87c
+                _dev="$(readlink -f "$dev")"
64b87c
+                push host_devs "$_dev"
64b87c
+                push swap_devs "$_dev"
64b87c
                 break
64b87c
             done < /etc/fstab
64b87c
         done < /proc/swaps
64b87c
@@ -1181,7 +1183,7 @@ export initdir dracutbasedir \
64b87c
     omit_drivers mdadmconf lvmconf root_dev \
64b87c
     use_fstab fstab_lines libdirs fscks nofscks ro_mnt \
64b87c
     stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
64b87c
-    debug host_fs_types host_devs sshkey add_fstab \
64b87c
+    debug host_fs_types host_devs swap_devs sshkey add_fstab \
64b87c
     DRACUT_VERSION udevdir prefix filesystems drivers \
64b87c
     systemdutildir systemdsystemunitdir systemdsystemconfdir \
64b87c
     host_modalias host_modules hostonly_cmdline loginstall \
64b87c
diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh
64b87c
index fddf4b0..d5e7861 100755
64b87c
--- a/modules.d/99base/module-setup.sh
64b87c
+++ b/modules.d/99base/module-setup.sh
64b87c
@@ -104,6 +104,14 @@ install() {
64b87c
 
64b87c
                 for _dev in ${host_devs[@]}; do
64b87c
                     [[ "$_dev" == "$root_dev" ]] && continue
64b87c
+
64b87c
+                    # We only actually wait for real devs - swap is only needed
64b87c
+                    # for resume and udev rules generated when parsing resume=
64b87c
+                    # argument take care of the waiting for us
64b87c
+                    for _dev2 in ${swap_devs[@]}; do
64b87c
+                      [[ "$_dev" == "$_dev2" ]] && continue 2
64b87c
+                    done
64b87c
+
64b87c
                     _pdev=$(get_persistent_dev $_dev)
64b87c
 
64b87c
                     case "$_pdev" in