stage-1: fix hibernation (close #6675)

Fixes #6617.

(cherry picked from commit b802018482)
This commit is contained in:
Nikolay Amiantov 2015-03-05 18:06:51 +03:00 committed by Vladimír Čunát
parent 28c0d0fe41
commit b37188eddb

View File

@ -175,20 +175,24 @@ fi
if test -e /sys/power/resume -a -e /sys/power/disk; then
if test -n "@resumeDevice@"; then
resumeDev="@resumeDevice@"
resumeInfo="$(udevadm info -q property "$resumeDev" )"
else
for sd in @resumeDevices@; do
# Try to detect resume device. According to Ubuntu bug:
# https://bugs.launchpad.net/ubuntu/+source/pm-utils/+bug/923326/comments/1
# When there are multiple swap devices, we can't know where will hibernate
# image reside. We can check all of them for swsuspend blkid.
if [ "$(udevadm info -q property "$sd" | sed -n 's/^ID_FS_TYPE=//p')" = "swsuspend" ]; then
resumeInfo="$(udevadm info -q property "$sd" )"
if [ "$(echo "$resumeInfo" | sed -n 's/^ID_FS_TYPE=//p')" = "swsuspend" ]; then
resumeDev="$sd"
break
fi
done
fi
if test -n "$resumeDev"; then
readlink -f "$resumeDev" > /sys/power/resume 2> /dev/null || echo "failed to resume..."
if test -e "$resumeDev"; then
resumeMajor="$(echo "$resumeInfo" | sed -n 's/^MAJOR=//p')"
resumeMinor="$(echo "$resumeInfo" | sed -n 's/^MINOR=//p')"
echo "$resumeMajor:$resumeMinor" > /sys/power/resume 2> /dev/null || echo "failed to resume..."
fi
fi