Comment 5 for bug 923326

Revision history for this message
A Dasgupta (adg) wrote :

Some internals:

If you decide to resume manually, here is some additional low-level
(non-portable) method for detecting suspend signatures. This is
meant only for experienced users and even then a small error
can destroy all your data.

Both the kernel internal swsusp and the userland uswsusp (suspend-utils)
codes store their suspend signature in the last 10 bytes of the first
4096-byte block of the swap partition used at hibernation.

For the kernel internal swsusp, that signature is "S1SUSPEND\0",
as defined in kernel/power/swap.c:

#define SWSUSP_SIG "S1SUSPEND"

and for userland suspend, it is "ULSUSPEND\0", as defined in
swsusp.h:

#define SWSUSP_SIG "ULSUSPEND"

So if in the initramfs premount break-point shell you find a swap partition
/dev/sdXY for which blkid reports TYPE=swsusp, you can do the following
test for further confirmation (DANGER WARNING APPLIES):

suspsig=$(dd if=/dev/sdXY bs=1 skip=4086 count=9 2>/dev/null)

if [ "$suspsig" = "S1SUSPEND" ] ; then
  echo "kernel swsusp, echo major:minor onto /sys/power/resume to resume"
fi

if [ "$suspsig" = "ULSUSPEND" ] ; then
  echo "userland uswsusp, run /sbin/resume -r /dev/sdXY to resume"
fi

I am posting these only for those who may want to experiment while
being fully aware of the risk of losing all data on disk. The warning script
for manual resume posted in #4 can be further automated with the
last commands (giving the user the option to run these low-level tests
and resume commands to "auto-resume"), but that would be neither
portable not safe.
.