I have ubuntu 16.04 installed on LUKS encrypted partition that is on the mdadm raid-0.

I want to activate suspend to disk. I used this instruction (for unencrypted partition), but it doesn't work. Computer shutdowns but doesn't resume, it starts as after hard reboot.

Can I setup hibernation on my configuration? If it is possible how can I do it?

  • When you did the step echo "resume=UUID=<your UUID> resume_offset=<youroffset>" | sudo tee /etc/initramfs-tools/conf.d/resume, what exactly did you run (i.e., what did you fill in the blanks with)? Mar 3 '17 at 3:47
  • <your UUID> - uuid of root partition (or I tried resume=/dev/mapper/<root_partition> too) <youroffset> - output of swap-offset /swapfile
    – Timur
    Mar 3 '17 at 9:20

I did a lot of testing regarding this, and I found out the issue isn't actually related to encryption. The real reason that it isn't working is solely because you're using a swap file instead of a swap partition. Note the following at the end of /usr/share/initramfs-tools/scripts/local-premount/resume:

SWAPTYPE=$(wait-for-root "${resume}" ${RESUMEDELAY:-5})

case "${SWAPTYPE}" in
        if [ -x /bin/plymouth ] && plymouth --ping; then
                plymouth message --text="Resuming from $resume"

        # hardcode path, uswsusp ships an resume binary too
        if [ -n "${resume_offset}" ]; then
                /bin/resume ${resume} ${resume_offset}
                /bin/resume ${resume}

Here, ${resume} and ${resume_offset} have the values that you put in /etc/initramfs-tools/conf.d/resume. When it calls wait-for-root, it's looking at the partition type of ${resume}, which isn't swap (it's ext4 or whatever type your root partition is). It then compares this to its list of suspended swap types, and (unsurprisingly) doesn't find a match, so it doesn't resume. It looks like they intend for swap files to work since they use ${resume_offset} at all, so this appears to be a bug in Ubuntu's initramfs-tools system. (Edit: This is apparently a known issue, as mentioned on their SwapFaq wiki page.)

As a workaround, you can avoid the need to have a swap file by using LVM on top of your encrypted partition and then putting a swap partition inside of it along with your root partition, which will work fine with no special steps required.

  • I have already installed OS, and shrinking partitions in my configuration is so hard. Is there a solution without modifying partition table?
    – Timur
    Mar 8 '17 at 0:36
  • As I know it should work with swapfile on unencrypted partition.
    – Timur
    Mar 8 '17 at 4:23
  • I tried it myself with an unencrypted swap file and it didn't work, for the same reason. Mar 8 '17 at 11:57
  • 1
    In fact, hibernation to a swap file on an encrypted volume works just fine on Ubuntu, even with swsusp. The only things stopping it from resuming is the piece of code you found - the FAQ is incorrect claiming that swsusp won't work with swap files. There is already a bug report on this, without real activity unfortunately. May 30 '17 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.