summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2017-04-20 22:22:27 +0100
committerBen Hutchings <ben@decadent.org.uk>2017-04-21 03:50:51 +0100
commit8108a17189c631a6cf29845d23ec43a13edbc1d4 (patch)
treee4ee4ca32a0baeb94337b71ee1079bef547297e3
parent433e1ca0ab9b4102bfc7c983d7061fee9bf02d2d (diff)
Support requesting automatic selection of resume device with RESUME=auto
For now, this is effectively the same as setting RESUME to empty or not setting it. Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rwxr-xr-xhooks/resume25
-rw-r--r--initramfs.conf.53
2 files changed, 16 insertions, 12 deletions
diff --git a/hooks/resume b/hooks/resume
index 3e3f6db..43eb146 100755
--- a/hooks/resume
+++ b/hooks/resume
@@ -16,7 +16,7 @@ prereqs)
esac
# First check if a location is set and is a valid swap partition
-if [ -n "$RESUME" ] && \
+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
@@ -24,16 +24,19 @@ fi
# We need to be able to read the listed swap partitions
if ischroot || [ ! -r /proc/swaps ]; then
- exit 0
+ 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)
+ if [ -n "$UUID" ]; then
+ resume_auto="UUID=$UUID"
+ fi
+ fi
fi
-# Try to autodetect the RESUME partition, using biggest swap?
-# Write detected resume to intramfs conf.d
-RESUME=$(grep ^/dev/ /proc/swaps | sort -rnk3 | 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"
- fi
- echo "RESUME=${RESUME}" > ${DESTDIR}/conf/conf.d/zz-resume-auto
+# Write selected resume device to intramfs conf.d
+if [ "$RESUME" = auto ] || [ -n "$resume_auto" ]; then
+ echo "RESUME=${resume_auto}" > ${DESTDIR}/conf/conf.d/zz-resume-auto
fi
diff --git a/initramfs.conf.5 b/initramfs.conf.5
index c0d778c..b4eea70 100644
--- a/initramfs.conf.5
+++ b/initramfs.conf.5
@@ -78,7 +78,8 @@ Set to \fInfs\fP for an NFS root share.
.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,
+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.