systemctl hibernate error: "Call to Hibernate failed: Invalid argument"

Bug #2057687 reported by Dmitry-a-durnev
92
This bug affects 17 people
Affects Status Importance Assigned to Milestone
initramfs-tools (Ubuntu)
Confirmed
Undecided
Unassigned
systemd (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

After upgrading systemd to 255(255.2-3ubuntu2) hibernate stopped working.

Trying to hibernate:
systemctl hibernate

I get:
Call to Hibernate failed: Invalid argument

systemctl status systemd-hibernate.service

---------------------------------------------
× systemd-hibernate.service - Hibernate
     Loaded: loaded (/usr/lib/systemd/system/systemd-hibernate.service; static)
     Active: failed (Result: exit-code) since Tue 2024-03-12 18:48:12 MSK; 1min 33s ago
       Docs: man:systemd-hibernate.service(8)
    Process: 4473 ExecStart=/usr/lib/systemd/systemd-sleep hibernate (code=exited, status=1/FAILURE)
   Main PID: 4473 (code=exited, status=1/FAILURE)
        CPU: 5ms

мар 12 18:48:12 ASUSPRO-P3540FA systemd[1]: Starting systemd-hibernate.service - Hibernate...
мар 12 18:48:12 ASUSPRO-P3540FA systemd-sleep[4473]: Failed to find location to hibernate to: Invalid argument
мар 12 18:48:12 ASUSPRO-P3540FA systemd[1]: systemd-hibernate.service: Main process exited, code=exited, status=1/FAILURE
мар 12 18:48:12 ASUSPRO-P3540FA systemd[1]: systemd-hibernate.service: Failed with result 'exit-code'.
мар 12 18:48:12 ASUSPRO-P3540FA systemd[1]: Failed to start systemd-hibernate.service - Hibernate.
--------------------------------------------------

Previous version (254.x) worked: swapfile(on EXT4 fs) is used to hibernate/resume, resume with resume_offset kernel parameters.

Related branches

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in systemd (Ubuntu):
status: New → Confirmed
Revision history for this message
Dmitry-a-durnev (dmitry-a-durnev) wrote :

Somehow this was fixed for me by the following (almost random) sequence of steps:

1. remove resume/resume_offset kernel parameters from /etc/default/grub
2. update-grub, reboot: hibernate options appear in ubuntu shutdown menu
3. hibernate: works, no more "invalid argument" error.
4. resume(power on): not works - just regular power on. Tried several times.
5. return resume/resume_offset kernel parameters back to /etc/default/grub.
6. initramfs -c -k all : maybe this fixed it? (should not be necessary to do)
7. update-grub
8. hibernate
9. resume: works (!)

Revision history for this message
Balazs Pere (perebal-sze) wrote :

It does not work for me :-(

Revision history for this message
Dmitry-a-durnev (dmitry-a-durnev) wrote :

Actually it's more simple than that, initramfs(step 6) is not required. After each kernel upgrade (during apt dist/full upgrade) I face the "invalid argument" error and each time I fix it only by steps

1, 2, 5, 7, 8, 9.

Revision history for this message
cc (xstack) wrote :

The "Call to Hibernate failed: Invalid argument" problem, i try to resolve it by using a separate swap partition(i used a swap file before upgrade to 24.04), changing the /etc/default/grub by removing the resume=xxx and resume_offset=xxx kernel parameter, changing the /etc/initramfs-tools/conf.d/resume by adding resume=xxx, then sudo update-grub2, sudo update-initramfs -c -k all.

My config file and swap partition looks like:
$ blkid
/dev/mapper/vgubuntu-swap: UUID="a01cbd0d-9dcc-405a-9a5e-a3d2687419fc" TYPE="swap"

$ cat /etc/default/grub|grep LINUX
GRUB_CMDLINE_LINUX_DEFAULT="splash"
GRUB_CMDLINE_LINUX=""

$ cat /etc/initramfs-tools/conf.d/resume
resume=UUID=a01cbd0d-9dcc-405a-9a5e-a3d2687419fc

Test and check the log.
$ sudo systemctl hibernate
It works.

$ journalctl -x --no-pager --since='2024-04-29 13:45:00'

Some log looks like below:
The system has now entered the hibernate sleep state.
......
kernel: ACPI: PM: Preparing to enter system sleep state S4
......
kernel: ACPI: PM: Waking up from system sleep state S4
......

If anyone met the "Wakeup event detected during hibernation, rolling back" problem, change the /etc/modprobe.d/blacklist.conf and add blacklist kernel module, for example:
blacklist intel_hid

FYI.
https://bbs.archlinux.org/viewtopic.php?id=294111
Bug 218634 - Hibernate fails with "Wakeup event detected during hibernation, rolling back"
https://bugzilla.kernel.org/show_bug.cgi?id=218634

Revision history for this message
Jan Rathmann (kaiserclaudius) wrote :

@Dmitry I have tried your workaround from #2, but step 8. (the second hibernate) fails for me with a "Not enough swap space" error message.

On my setup I'm using a swapfile on a Btrfs formatted Logical Volume. This worked fine in regards of hibernating on Kubuntu 23.10.

Revision history for this message
Rahim (rahim-one) wrote :

for me I fixed it by not using that file `swap.img` and created new one called `swapfile` as old versions. so it's working now.
about if this maybe a bad idea, unrecomended, or any issue may I face later idk :)

Revision history for this message
Martin Schaaf (mascha) wrote :

My workaround is this command: "sudo fwts s4"
It hibernates the system without any change to the setup.
It is not very nice but works for now.

Revision history for this message
Steven Walter (stevenrwalter) wrote :

The issue seems to be that /sys/power/resume contains 0:0, rather than the major:minor of the hibernate device. If I manually populate /sys/power/resume, then I can "systemctl hibernate" successfully and successfully resume.

Revision history for this message
Dmitry-a-durnev (dmitry-a-durnev) wrote :

Yes, for me

# echo MAJ:MIN > /sys/power/resume

helps! Set MAJ:MIN to your swap partition device major:minor numbers.

Revision history for this message
Jan Rathmann (kaiserclaudius) wrote :

@stevenrwalter
Can confirm that manually populating /sys/power/resume works as workaround for me too.

Revision history for this message
Joe Zendle (joe-zendle) wrote :

Can confirm that manually populating /sys/power/resume works for me as well.

to get maj:min of root partition:

$ df /
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/nvme0n1p2 121969296 33951580 81775876 30% /

ls -l /dev/nvme0n1p2
brw-rw---- 1 root disk 259, 2 May 12 09:47 /dev/nvme0n1p2

in this case maj:min is 259:2

Revision history for this message
Ben (bernd-gill) wrote :

Answers #4, #10, and #12 worked for me on Ubuntu 24.04 LTS, using /swap.img.
Thank you!!!

Revision history for this message
Joris Jansen (jorisjansen) wrote :

I tried the maj:min trick a view times now.
Every time I have the same result, it looks like my laptop is hibernating, the screen goes black.
After a while the ubuntu log in screen is shown again ...

Btw, I'm using a LVM setup with encryption.

Revision history for this message
Mustafa Nasser (mustafanasser1515) wrote :

@Joris I guess you need to calculate the offset in a different way since you 're using logical volume
Reply to #14

Revision history for this message
Marc Dumon (dumon-marc) wrote :

I have tried your workaround from #2 and hibernate works. Thanks Dmitry-a-durnev !
However, when I reboot my pc, I'm back to square one. Hibernate stops working till I execute the steps in #2 again.
Any idea's ?

Revision history for this message
mash (mash-econs) wrote :

I had successfully enabled Hibernate in Ubuntu 23.10 (using the very clear tutorial https://ubuntuhandbook.org/index.php/2021/08/enable-hibernate-ubuntu-21-10/) but hibernate stopped working on the upgrade to Ubuntu 24.04 LTS.

At first, I received
systemctl hibernate error: "Call to Hibernate failed: Invalid argument"
which is the subject of this bug.

I implemented the maj:min fix recommended in #10 (@dmitry-a-durnev) and that resolved this error.

But hibernate still fails. I have the experienced described in #5 (@xstack) and #14 (@jorisjansen). Here is the relevant item from dmesg:

[ 3676.283879] PM: hibernation: Wakeup event detected during hibernation, rolling back.

I do not understand the advice in #5:

If anyone met the "Wakeup event detected during hibernation, rolling back" problem, change the /etc/modprobe.d/blacklist.conf and add blacklist kernel module, for example:
blacklist intel_hid

FYI.
https://bbs.archlinux.org/viewtopic.php?id=294111
Bug 218634 - Hibernate fails with "Wakeup event detected during hibernation, rolling back"
https://bugzilla.kernel.org/show_bug.cgi?id=218634

Would it please be possible to explain this fix in more detail? Thank you,

Revision history for this message
mash (mash-econs) wrote :

I added the line "blacklist intel_hid" to /etc/modprobe.d/blacklist.conf and then ran

sudo update-grub
sudo update-initramfs -c -k all

and now hibernate works again (mostly -- hibernate works with "systemctl hibernate" and with closing the lid, but hibernate does not work with selecting hibernate from the gnome Power Off menu).

I would be grateful for an explanation but I seem to be back in business in terms of hibernation. Thank you @xstack

Revision history for this message
Sebastián Salgado (cebas) wrote :

I have the same problem and found a workaround:

$ sudo pm-hibernate

It's in the package pm-utils
Cheers!

Revision history for this message
Dna222 (dna222) wrote :

Hi, manually populating /sys/power/resume works also for me.
Thanks to Joe Zendle (joe-zendle) in #12 for the instructions.

systemctl hibernate error is now ok.

Still i can't use hibernate from power button.
Some news?

Thanks to everyone!

Claudio

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in initramfs-tools (Ubuntu):
status: New → Confirmed
Revision history for this message
misko (michael-wagner-gmx) wrote :

I am affected as well (using a swap-file on a LUKS-encrypted partition).
The workaround with populating /sys/power/resume works!

Regarding:
> Still i can't use hibernate from power button.
> Some news?

After performing step 4 of https://ubuntuhandbook.org/index.php/2021/08/enable-hibernate-ubuntu-21-10/ (polkit) I can assign hibernate also to button/lid-events - however, I am using KDE.

Revision history for this message
Dna222 (dna222) wrote :

Thanks!
With #22 i resolved everyhing!

Thank you very much for your work!

Claudio

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.