Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.kernel > #57623

[PATCH initramfs-tools 8/9] hooks/resume: Report when we might be doing something surprising

From Ben Hutchings <ben@decadent.org.uk>
Newsgroups linux.debian.kernel
Subject [PATCH initramfs-tools 8/9] hooks/resume: Report when we might be doing something surprising
Date 2017-04-21 05:40 +0200
Message-ID <tyxAn-Ku-23@gated-at.bofh.it> (permalink)
References <tyxAm-Ku-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Some systems have swap devices that aren't available at boot, but are
still selected as resume devices.  There used to be no way to disable
this at build time, but it also used to be quite harmless.  Now that
we wait for the resume device to appear, this is a real problem and
users of such systems will need to set RESUME=none.  Therefore:

- If RESUME is invalid, warn about this
- If RESUME is unset or invalid, and we automatically set a resume device,
  report this

Also:

- If RESUME=auto and we we fail to select a resume device, warn about
  this

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 hooks/resume | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/hooks/resume b/hooks/resume
index 43eb146b1f42..06ff62af3f3c 100755
--- a/hooks/resume
+++ b/hooks/resume
@@ -16,12 +16,23 @@ prereqs)
 esac
 
 # First check if a location is set and is a valid swap partition
-if [ -n "$RESUME" ] && [ "$RESUME" != auto ] && \
-   { [ "$RESUME" = none ] || blkid -p -n swap $RESUME >/dev/null 2>&1; }; then
-	# As mkinitramfs copies the config file nothing to do.
-	exit 0
+if [ -n "$RESUME" ] && [ "$RESUME" != auto ]; then
+	if [ "$RESUME" = none ] || blkid -p -n swap $RESUME >/dev/null 2>&1; then
+		# As mkinitramfs copies the config file nothing to do.
+		exit 0
+	fi
+
+	echo >&2 "W: initramfs-tools configuration sets RESUME=$RESUME"
+	echo >&2 "W: but no matching swap device is available."
 fi
 
+# If we were not explicitly requested to select a device, report that we
+# are doing so
+report_auto()
+{
+	test "$RESUME" = auto || echo >&2 "I: $*"
+}
+
 # We need to be able to read the listed swap partitions
 if ischroot || [ ! -r /proc/swaps ]; then
 	resume_auto=
@@ -30,13 +41,21 @@ else
 	resume_auto=$(grep ^/dev/ /proc/swaps | sort -rnk3 | head -n 1 | cut -d " " -f 1)
 	if [ -n "$resume_auto" ]; then
 		UUID=$(blkid -s UUID -o value "$resume_auto" || true)
+		report_auto "The initramfs will attempt to resume from $resume_auto"
 		if [ -n "$UUID" ]; then
+			report_auto "(UUID=$UUID)"
 			resume_auto="UUID=$UUID"
 		fi
+		report_auto "Set the RESUME variable to override this."
 	fi
 fi
 
 # Write selected resume device to intramfs conf.d
 if [ "$RESUME" = auto ] || [ -n "$resume_auto" ]; then
+	# If we were explicitly requested to select a device, and we failed,
+	# report that
+	if [ -z "$resume_auto" ]; then
+		echo >&2 "W: initramfs-tools failed to select a resume device"
+	fi
 	echo "RESUME=${resume_auto}" > ${DESTDIR}/conf/conf.d/zz-resume-auto
 fi

Back to linux.debian.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH initramfs-tools 0/9] Fix resume device configuration Ben Hutchings <ben@decadent.org.uk> - 2017-04-21 05:40 +0200
  [PATCH initramfs-tools 1/9] hooks/resume: Use correct sort options  to select the biggest swap partition Ben Hutchings <ben@decadent.org.uk> - 2017-04-21 05:40 +0200
  [PATCH initramfs-tools 3/9] Support setting of RESUME in  initramfs.conf or anywhere in conf.d/ Ben Hutchings <ben@decadent.org.uk> - 2017-04-21 05:40 +0200
  [PATCH initramfs-tools 6/9] Allow disabling resume from disk at  build time by setting RESUME=none Ben Hutchings <ben@decadent.org.uk> - 2017-04-21 05:40 +0200
  [PATCH initramfs-tools 5/9] hooks/resume: Check for chroot earlier Ben Hutchings <ben@decadent.org.uk> - 2017-04-21 05:40 +0200
  [PATCH initramfs-tools 9/9] NEWS: Add entry explaining the need for  RESUME=none on some systems Ben Hutchings <ben@decadent.org.uk> - 2017-04-21 05:40 +0200
  [PATCH initramfs-tools 2/9] initramfs.conf(5): Clean up split  between general and NFS variables Ben Hutchings <ben@decadent.org.uk> - 2017-04-21 05:40 +0200
  [PATCH initramfs-tools 7/9] Support requesting automatic selection  of resume device with RESUME=auto Ben Hutchings <ben@decadent.org.uk> - 2017-04-21 05:40 +0200
  [PATCH initramfs-tools 8/9] hooks/resume: Report when we might be  doing something surprising Ben Hutchings <ben@decadent.org.uk> - 2017-04-21 05:40 +0200
  Re: [PATCH initramfs-tools 0/9] Fix resume device configuration Martin Steigerwald <martin@lichtvoll.de> - 2017-04-21 11:10 +0200
    Re: [PATCH initramfs-tools 0/9] Fix resume device configuration Ben Hutchings <ben@decadent.org.uk> - 2017-04-21 17:20 +0200
  Re: [PATCH initramfs-tools 0/9] Fix resume device configuration Michael Prokop <mika@debian.org> - 2017-04-21 14:30 +0200
  Re: [PATCH initramfs-tools 0/9] Fix resume device configuration Bjørn Mork <bjorn@mork.no> - 2017-04-24 09:50 +0200
    Re: [PATCH initramfs-tools 0/9] Fix resume device configuration Ben Hutchings <ben@decadent.org.uk> - 2017-04-26 05:40 +0200

csiph-web