Package: uswsusp
Version: 1.0+20120915-6.2
Severity: important
Tags: patch

Dear Maintainer,

Before installing the uswsusp package, I configured and activated a 1
GiB swap file inside my root partition, which was encrypted using the
Debian installer, adding it to /etc/fstab. Then I followed the configuration 
wizard, which set up
the correct defaults needed to use my swap file to hibernate, which can
be seen below.

Then I tried to use s2disk as root. The hibernation process worked fine, but
when turning on my computer again, the initramfs didn't seem to bother
resuming from the supposedly created image.

So I started to debug the cause of the problem. I figured out that, if I
manually added the "resume" and "resume_offset" kernel parameters (editing, in 
my case, the /etc/default/grub
file), everything worked fine, and the computer resumed well. However,
from a mantainance perspective, it's uncomfortable to have two settings in two 
different places
set to the same value (kernel parameters and /etc/uswsusp.conf), because it's 
error-prone. Therefore,
I continued inspecting the problem in order to come up with a better
solution.

I figured out, too, that initramfs-tools-core also includes a resume
script in the initramfs. That script is tightly integrated with the
$resume shell variable, which is initialized from the
/usr/share/initramfs-tools/conf.d/resume configuration file, or the
"resume" kernel parameter. That script basically bails out if the
$resume variable is empty, which in my case it was, because the conf.d
file set the RESUME variable to "none" (its default value). Moreover, as
I didn't use a kernel parameter in the first place, it remained empty.

So I tried to set the "resume" configuration file to the same value that
uswsusp correctly calculated, /dev/dm-1 (my encrypted root partition,
which gets properly decrypted by a previous cryptsetup script in the
initramfs). The result was that I was still unable to boot, because I
still had to provide the "resume_offset" kernel parameter... And, to be
honest, messing with this configuration file is still as messy as the
first solution, because configuration values are replicated all over the
place.

Finally, I inspected the uswsusp local-premount script, and observed
the apparently innocent line 24 on it:

[ -n "${resume}" ] || exit 0;

Which basically means that, if $resume is not set, then we bail out of
the script without error. But that's incorrect: uswsusp doesn't have
anything to do with the default resume initramfs script, including that
variable, and the uswsusp hints that things should work fine out
of the box:

"You will need to set up an initramfs which calls the resume program for
this to work. If you use a package distributed with your Linux
distribution, the kernel package which was made with the --initrd
option and you use mkinitramfs-tools, this package should include the
necessary parts on your initramfs."

Therefore, I commented out that line, ran update-initramfs -u, and tried
s2disk again.

Now my machine resumes from hibernation properly, using the
/etc/uswsusp.conf file that gets copied to the initramfs, and all the
resume-related configurations are centralized in a single place :)

-- System Information:
Debian Release: 10.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.19.0-5-amd64 (SMP w/4 CPU cores)
Kernel taint flags: TAINT_USER
Locale: LANG=es_ES.UTF-8, LC_CTYPE=es_ES.UTF-8 (charmap=UTF-8), 
LANGUAGE=es_ES.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages uswsusp depends on:
ii  debconf [debconf-2.0]  1.5.71
ii  libblkid1              2.33.1-0.1
ii  libc6                  2.28-10
ii  liblzo2-2              2.10-0.1
ii  libpci3                1:3.5.2-1
ii  libx86-1               1.1+ds1-10.2

Versions of packages uswsusp recommends:
ii  initramfs-tools  0.133
ii  mount            2.33.1-0.1

uswsusp suggests no packages.

-- debconf information:
  uswsusp/no_snapshot:
* uswsusp/image_size: 1073741824
* uswsusp/encrypt: false
  uswsusp/RSA_key_file: /etc/uswsusp.key
* uswsusp/compress: true
* uswsusp/early_writeout: true
  uswsusp/resume_offset: 1276408
* uswsusp/shutdown_method: platform
* uswsusp/continue_without_swap: false
  uswsusp/RSA_key_bits: 1024
  uswsusp/no_swap:
* uswsusp/snapshot_device:
* uswsusp/resume_device: /dev/dm-1
* uswsusp/max_loglevel: 6
* uswsusp/suspend_loglevel: 6
  uswsusp/create_RSA_key: false
* uswsusp/compute_checksum: true

Reply via email to