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

Bug#861433: unblock: initramfs-tools/0.130



Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock

Please unblock package initramfs-tools

This fixes several longstanding bugs in handling configuration of
the suspend/resume device:

- Setting the RESUME variable anywhere other than
  /etc/initramfs-tools/conf.d/resume was ignored
- Setting the RESUME variable to UUID=something or LABEL=something
  was ignored (#861057)
- The fallback to automatic selection of the biggest swap partition
  actually sorted by dictionary order, not numeric order, of size
- There was no way to disable this automatic selection (#860403)

These used to be mostly harmless in practice, but version 0.128
(current version in testing) waits for the resume device to appear at
boot time.  That caused a regression for systems which didn't use
hibernation and where automatic selection was doing the wrong thing.
Dealing with that led me to all the other bugs.

Ben.

--- a/debian/NEWS
+++ b/debian/NEWS
@@ -1,3 +1,24 @@
+initramfs-tools (0.129) unstable; urgency=medium
+
+  * Some systems that do not support suspend-to-disk (hibernation) will
+    require a configuration change to explicitly disable this.
+
+    From version 0.128, the boot code waits for a suspend/resume device
+    to appear, rather than checking just once.  If the configured or
+    automatically selected resume device is not available at boot time,
+    this results in a roughly 30 second delay.
+
+    You should set the RESUME variable in
+    /etc/initramfs-tools/conf.d/resume or
+    /etc/initramfs-tools/initramfs.conf to one of:
+
+    - auto - select the resume device automatically
+    - none - disable use of a resume device
+    - UUID=<uuid> - use a specific resume device (by UUID)
+    - /dev/<name> - use a specific resume device (by kernel name)
+
+ -- Ben Hutchings <ben@decadent.org.uk>  Thu, 20 Apr 2017 23:21:32 +0100
+
 initramfs-tools (0.121~rc1) unstable; urgency=medium
 
   * If initramfs-tools is configured to use busybox but it is not
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,29 @@
+initramfs-tools (0.130) unstable; urgency=medium
+
+  * [5b7c092] hooks/resume: Fix validation of resume devices specified by
+    UUID etc. (Closes: #861057)
+
+ -- Ben Hutchings <ben@decadent.org.uk>  Wed, 26 Apr 2017 02:00:05 +0100
+
+initramfs-tools (0.129) unstable; urgency=medium
+
+  * [71cfb7f] hooks/resume: Use correct sort options to select the biggest swap
+    partition
+  * [7da8194] initramfs.conf(5): Clean up split between general and NFS
+    variables
+  * [d857e91] Support setting of RESUME in initramfs.conf or anywhere in conf.d/
+  * [786e4aa] initramfs.conf(5): Document the RESUME variable
+  * [7106c3e] hooks/resume: Check for chroot earlier
+  * [433e1ca] Allow disabling resume from disk at build time by setting
+    RESUME=none
+  * [8108a17] Support requesting automatic selection of resume device with
+    RESUME=auto
+  * [aaaa6b5] hooks/resume: Report when we might be doing something surprising
+  * [995b556] NEWS: Add entry explaining the need for RESUME=none on some
+    systems (Closes: #860403)
+
+ -- Ben Hutchings <ben@decadent.org.uk>  Mon, 24 Apr 2017 01:06:21 +0100
+
 initramfs-tools (0.128) unstable; urgency=medium
 
   * [cd352e8] debian/control: Add Breaks against older versions of busybox
--- a/hooks/resume
+++ b/hooks/resume
@@ -15,29 +15,53 @@ prereqs)
 	;;
 esac
 
-# First check if a location is set and is a valid swap partition
-test -r /etc/initramfs-tools/conf.d/resume \
-	&& . /etc/initramfs-tools/conf.d/resume
-if [ -n "$RESUME" ] && blkid -p -n swap $RESUME >/dev/null 2>&1; then
-	# As mkinitramfs copies the config file nothing to do.
-	exit 0
-fi
+. /usr/share/initramfs-tools/scripts/functions
 
-# We need to be able to read the listed swap partitions
-if [ ! -r /proc/swaps ]; then
-	exit 0
+# First check if a location is set and is a valid swap partition.
+# If so, the config file will be copied in and there is nothing to do.
+if [ -n "$RESUME" ] && [ "$RESUME" != auto ]; then
+	if [ "$RESUME" = none ]; then
+		exit 0
+	fi
+	if resume_dev_node="$(resolve_device "$RESUME")" && \
+	   blkid -p -n swap "$resume_dev_node" >/dev/null 2>&1; then
+		exit 0
+	fi
+
+	echo >&2 "W: initramfs-tools configuration sets RESUME=$RESUME"
+	echo >&2 "W: but no matching swap device is available."
 fi
 
-# Try to autodetect the RESUME partition, using biggest swap?
-RESUME=$(grep ^/dev/ /proc/swaps | sort -rk3 | head -n 1 | cut -d " " -f 1)
-if [ -n "$RESUME" ]; then
-	UUID=$(blkid -s UUID -o value "$RESUME" || true)
-	if [ -n "$UUID" ]; then
-			RESUME="UUID=$UUID"
+# 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=
+else
+	# Try to autodetect the RESUME partition, using biggest swap?
+	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 detected resume to intramfs conf.d/resume if not in a chroot
-if [ -n "${RESUME}" ] && ! ischroot; then
-	echo "RESUME=${RESUME}" > ${DESTDIR}/conf/conf.d/resume
+# 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
--- a/init
+++ b/init
@@ -189,8 +189,8 @@ if [ -z "${BOOT}" ]; then
 	BOOT=local
 fi
 
-if [ -n "${noresume}" ]; then
-	export noresume
+if [ -n "${noresume}" ] || [ "$RESUME" = none ]; then
+	export noresume=y
 	unset resume
 else
 	resume=${RESUME:-}
--- a/initramfs.conf.5
+++ b/initramfs.conf.5
@@ -68,13 +68,23 @@ corresponding userspace utility is not present.
 Set the umask value of the generated initramfs file.
 Useful to not disclose eventual keys.
 
-.SH NFS VARIABLES
 .TP
 \fB BOOT
 Allows one to use an nfs drive as the root of the drive.
 The default is to boot from \fIlocal\fP media (hard drive, USB stick).
 Set to \fInfs\fP for an NFS root share.
 
+.SH VARIABLES FOR LOCAL BOOT
+.TP
+\fB RESUME
+Specifies the device used for suspend-to-disk (hibernation), which the
+initramfs code should attempt to resume from.  If this is not defined
+or is set to \fIauto\fP,
+.B mkinitramfs
+will automatically select the largest available swap partition.
+Set it to \fInone\fP to disable resume from disk.
+
+.SH VARIABLES FOR NFS BOOT
 .TP
 \fB DEVICE
 Specifies the network interface, like eth0.
--- a/mkinitramfs
+++ b/mkinitramfs
@@ -205,6 +205,7 @@ export verbose
 export KEYMAP
 export MODULES
 export BUSYBOX
+export RESUME
 
 # Private, used by 'catenate_cpiogz'.
 export __TMPCPIOGZ
--- END ---

unblock initramfs-tools/0.130

-- System Information:
Debian Release: 9.0
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'stable-updates'), (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: amd64
 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.9.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)


Reply to: