]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
base: Don't wait for swap devices in host-only mode.
authorColin Guthrie <colin@mageia.org>
Fri, 15 May 2015 13:53:40 +0000 (14:53 +0100)
committerHarald Hoyer <harald@redhat.com>
Fri, 3 Jul 2015 12:06:29 +0000 (14:06 +0200)
The only reason we add swap devices to host-only mode (added in
dd5875499ece9dbc90e10eafd0073ee15d0c86a4) is to allow us to process
resume= arguments passed on the kernel command line when the swap
partition lives on something slightly more complex than a normal
partion (e.g. in an LVM or RAID setup).

By adding the device to host_devs, the necessary LVM and RAID hooks
are added and thus the underlying storage will be initialised OK, and
the 95resume module handles the waiting for the device (via udev rules
creating the /dev/resume symlink).

So ultimately, we do not need to hard-code the waiting for the swap
devices into the initramfs at build time as the waiting part can be
dynamic.

This makes things more resiliant to swap partitions disappearing and
being reformatted etc.

Inspired by a patch by Martin Whitaker on Mageia bug:
https://bugs.mageia.org/show_bug.cgi?id=12305

(cherry picked from commit 3e3ed34f036a833ccc2150c6224d0a954e841e39)

dracut.sh
modules.d/99base/module-setup.sh

index a214f810abc826e13b2888c99b2486544ba242dc..90ac1fe9b40eb8a62015b3684cce5d1407f7b07b 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -1056,7 +1056,9 @@ if [[ $hostonly ]]; then
                     done < /etc/crypttab
                 fi
 
-                push host_devs "$(readlink -f "$dev")"
+                _dev="$(readlink -f "$dev")"
+                push host_devs "$_dev"
+                push swap_devs "$_dev"
                 break
             done < /etc/fstab
         done < /proc/swaps
@@ -1181,7 +1183,7 @@ export initdir dracutbasedir \
     omit_drivers mdadmconf lvmconf root_dev \
     use_fstab fstab_lines libdirs fscks nofscks ro_mnt \
     stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
-    debug host_fs_types host_devs sshkey add_fstab \
+    debug host_fs_types host_devs swap_devs sshkey add_fstab \
     DRACUT_VERSION udevdir prefix filesystems drivers \
     systemdutildir systemdsystemunitdir systemdsystemconfdir \
     host_modalias host_modules hostonly_cmdline loginstall \
index fddf4b06b5f49109bf4f5522051a296f80a469f8..d5e7861329371f8d36df1daccc14b5eb7eb054b2 100755 (executable)
@@ -104,6 +104,14 @@ install() {
 
                 for _dev in ${host_devs[@]}; do
                     [[ "$_dev" == "$root_dev" ]] && continue
+
+                    # We only actually wait for real devs - swap is only needed
+                    # for resume and udev rules generated when parsing resume=
+                    # argument take care of the waiting for us
+                    for _dev2 in ${swap_devs[@]}; do
+                      [[ "$_dev" == "$_dev2" ]] && continue 2
+                    done
+
                     _pdev=$(get_persistent_dev $_dev)
 
                     case "$_pdev" in