public inbox for initramfs@vger.kernel.org
 help / color / mirror / Atom feed
* dracut: Make host only mode more resilient to missing swaps.
@ 2015-05-15 13:53 Colin Guthrie
       [not found] ` <1431698021-16626-1-git-send-email-colin-odJJhXpcy38dnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Colin Guthrie @ 2015-05-15 13:53 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

This patch set allows swap devices to disappear without cocking up a
host-only initramfs boot.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] base: Don't wait for swap devices in host-only mode.
       [not found] ` <1431698021-16626-1-git-send-email-colin-odJJhXpcy38dnm+yROfE0A@public.gmane.org>
@ 2015-05-15 13:53   ` Colin Guthrie
  2015-05-15 13:53   ` [PATCH 2/2] resume: Ensure we actually wait for the /dev/resume 'device' Colin Guthrie
  2015-06-02 10:26   ` dracut: Make host only mode more resilient to missing swaps Harald Hoyer
  2 siblings, 0 replies; 5+ messages in thread
From: Colin Guthrie @ 2015-05-15 13:53 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA; +Cc: Colin Guthrie

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
---
 dracut.sh                        | 6 ++++--
 modules.d/99base/module-setup.sh | 8 ++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/dracut.sh b/dracut.sh
index 6215b36..ec48015 100755
--- a/dracut.sh
+++ b/dracut.sh
@@ -1223,7 +1223,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
@@ -1334,7 +1336,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 \
diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh
index fd65cdf..bbc68ba 100755
--- a/modules.d/99base/module-setup.sh
+++ b/modules.d/99base/module-setup.sh
@@ -103,6 +103,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
-- 
2.3.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] resume: Ensure we actually wait for the /dev/resume 'device'
       [not found] ` <1431698021-16626-1-git-send-email-colin-odJJhXpcy38dnm+yROfE0A@public.gmane.org>
  2015-05-15 13:53   ` [PATCH 1/2] base: Don't wait for swap devices in host-only mode Colin Guthrie
@ 2015-05-15 13:53   ` Colin Guthrie
       [not found]     ` <1431698021-16626-3-git-send-email-colin-odJJhXpcy38dnm+yROfE0A@public.gmane.org>
  2015-06-02 10:26   ` dracut: Make host only mode more resilient to missing swaps Harald Hoyer
  2 siblings, 1 reply; 5+ messages in thread
From: Colin Guthrie @ 2015-05-15 13:53 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA; +Cc: Colin Guthrie

Although various bits are in place to cancel waiting for the /dev/resume
device (actually a symlink), we don't actually ever wait for it.

Also as the udev rule may create the symlink, silence any errors from
our manual ln -s call from the settled job.
---
 modules.d/95resume/parse-resume.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/modules.d/95resume/parse-resume.sh b/modules.d/95resume/parse-resume.sh
index 9296429..3b97e51 100755
--- a/modules.d/95resume/parse-resume.sh
+++ b/modules.d/95resume/parse-resume.sh
@@ -37,6 +37,8 @@ esac
 
 if ! getarg noresume; then
     if [ -n "$resume" ]; then
+        wait_for_dev /dev/resume
+
         {
             printf "KERNEL==\"%s\", ACTION==\"add|change\", SYMLINK+=\"resume\"\n" \
                 ${resume#/dev/};
@@ -65,7 +67,7 @@ if ! getarg noresume; then
             printf -- '%s\n' ' RUN+="/sbin/initqueue --finished --unique --name 00resume echo %M:%m  > /sys/power/resume"'
         } >> /etc/udev/rules.d/99-resume.rules
 
-        printf '[ -e "%s" ] && { ln -s "%s" /dev/resume; rm -f -- "$job" "%s/initqueue/timeout/resume.sh"; }\n' \
+        printf '[ -e "%s" ] && { ln -s "%s" /dev/resume 2> /dev/null; rm -f -- "$job" "%s/initqueue/timeout/resume.sh"; }\n' \
             "$resume" "$resume" "$hookdir" >> $hookdir/initqueue/settled/resume.sh
 
         {
-- 
2.3.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] resume: Ensure we actually wait for the /dev/resume 'device'
       [not found]     ` <1431698021-16626-3-git-send-email-colin-odJJhXpcy38dnm+yROfE0A@public.gmane.org>
@ 2015-05-15 14:01       ` Dracut GitHub Import Bot
  0 siblings, 0 replies; 5+ messages in thread
From: Dracut GitHub Import Bot @ 2015-05-15 14:01 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Patchset imported to github.
Pull request:
<https://github.com/haraldh/dracut/compare/master...dracut-mailing-devs:1431698021-16626-3-git-send-email-colin%40mageia.org>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: dracut: Make host only mode more resilient to missing swaps.
       [not found] ` <1431698021-16626-1-git-send-email-colin-odJJhXpcy38dnm+yROfE0A@public.gmane.org>
  2015-05-15 13:53   ` [PATCH 1/2] base: Don't wait for swap devices in host-only mode Colin Guthrie
  2015-05-15 13:53   ` [PATCH 2/2] resume: Ensure we actually wait for the /dev/resume 'device' Colin Guthrie
@ 2015-06-02 10:26   ` Harald Hoyer
  2 siblings, 0 replies; 5+ messages in thread
From: Harald Hoyer @ 2015-06-02 10:26 UTC (permalink / raw)
  To: Colin Guthrie, initramfs-u79uwXL29TY76Z2rM5mHXA

On 15.05.2015 15:53, Colin Guthrie wrote:
> This patch set allows swap devices to disappear without cocking up a
> host-only initramfs boot.
> 

pushed, thanks

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-06-02 10:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-15 13:53 dracut: Make host only mode more resilient to missing swaps Colin Guthrie
     [not found] ` <1431698021-16626-1-git-send-email-colin-odJJhXpcy38dnm+yROfE0A@public.gmane.org>
2015-05-15 13:53   ` [PATCH 1/2] base: Don't wait for swap devices in host-only mode Colin Guthrie
2015-05-15 13:53   ` [PATCH 2/2] resume: Ensure we actually wait for the /dev/resume 'device' Colin Guthrie
     [not found]     ` <1431698021-16626-3-git-send-email-colin-odJJhXpcy38dnm+yROfE0A@public.gmane.org>
2015-05-15 14:01       ` Dracut GitHub Import Bot
2015-06-02 10:26   ` dracut: Make host only mode more resilient to missing swaps Harald Hoyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox