Commit aaaa6b54 authored by Ben Hutchings's avatar Ben Hutchings

hooks/resume: Report when we might be doing something surprising

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


- If RESUME=auto and we we fail to select a resume device, warn about
Signed-off-by: default avatarBen Hutchings <>
parent 8108a171
......@@ -16,12 +16,23 @@ prereqs)
# 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
echo >&2 "W: initramfs-tools configuration sets RESUME=$RESUME"
echo >&2 "W: but no matching swap device is available."
# If we were not explicitly requested to select a device, report that we
# are doing so
test "$RESUME" = auto || echo >&2 "I: $*"
# We need to be able to read the listed swap partitions
if ischroot || [ ! -r /proc/swaps ]; then
......@@ -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)"
report_auto "Set the RESUME variable to override this."
# 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"
echo "RESUME=${resume_auto}" > ${DESTDIR}/conf/conf.d/zz-resume-auto
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment