Contents
uswsusp is the package with tools to use userspace software suspend provided by Linux.
This program appears to be usable, with a few fixes and workarounds.
Currently this page is based on my experience with a desktop system. It may all be somewhat different with a laptop or other systems. This is what I appear to be able to use with my amd64 (that's debianese for x86_64 intel or amd) desktop system, and it mostly consistently works.
Install the uswsusp
$ sudo apt-get install uswsusp
Defaults and reconfiguration
IIRC dpkg-reconfigure will automatically run during installation, where defaults should work. You can and probably will, upon reading the pertaining docs, re-issue:
dpkg-reconfigure uswsusp
later at some stage(s).
This page is not a substitute for the docs that come with the install.
Read the fine documentation
$ sudo apt-file list uswsusp
That will list all the files of this package. Know that currently a lot of very useful information and detailed explanation is intermixed with some obsolete information.
E.g. encrypting does not work, so just do not try selecting it during dpkg-reconfigure. However, if your whole HDD is encrypted, including the swap partition, you will suspend to disk in that swap partition, and it will be encrypted.
Suspend to ram
Prepare the machine to test suspend it to RAM. Unmount extra usb sticks or HDDs attached over USB, unplug/remove peripherals such as printer, scanner, camera. If the suspend to RAM succeeds you can later try attaching those peripherals, maybe one at a time, and see if they do not cause problems when you try to suspend to RAM. So, first with peripherals removed, try:
$ sudo s2ram
The machine should suspend. If it does, leave it for a while, maybe for just a very short while, then touch any key of the keyboard.
The machine should resume. And now try the same with some of the peripherals. If all is well, great! That's all you need to know to be able to use s2ram.
And if you will get the suspend to disk to work, you're all set! But there's a little more work to do.
Patching your install
Before I explain the suspend to disk to you, you need to know that you will have to apply the patch to one of the files that we listed with apt-file list uswsusp above, in some way, possibly the simple user way, so you don't need to panic.
Pls. read this bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=933944
The programmer's way is compile the package with this patch: https://bugs.launchpad.net/ubuntu/+source/uswsusp/+patches
What is explained in this section is the user-way patching that is needed. Easier for non-advanced users, but more talk needed to explain it.
All you really need to do is (this is one possible way), in this file:
/usr/share/initramfs-tools/scripts/local-premount/uswsusp
insert a "#" character at the start of the line that reads:
[ -n "${resume}" ] || exit 0;so that it looks like this:
#[ -n "${resume}" ] || exit 0;You can also insert a line like this just above (but that's nicety, it'll work without it just fine):
# bug 933944
Suspend to disk
Suspend to disk currently wouldn't work without patching and compiling, or simply user-way patching as I explained above.
And in my machine it still does not work. Actually s2disk does not work, as the package currently ships it. It would not suspend my machine to disk.
However, just the first few lines of this tutorial: https://www.kernel.org/doc/html/latest/power/basic-pm-debugging.html were enough to get my suspend to disk to work.
# echo platform > /sys/power/disk # echo disk > /sys/power/state
Just not via that s2disk binary, as it should.
Troubleshooting
If you encounter problems with uswsusp, this is where you can start: https://qa.debian.org/developer.php?login=kix@debian.org#uswsusp