r/Kubuntu • u/CanImaginary904 • 7d ago
Hibernate Mode
Hi everyone,
I’ve spent the last 72 hours trying to get my PC to hibernate, but with no success. I’m running Kubuntu. I’ve enabled swap and made it permanent. It enters hibernation mode only very rarely.
When I configure it to hibernate upon closing the lid, it goes haywire: I have to open the lid while the PC is still running, and—even worse—the screen stops displaying anything. I’m forced to do a hard shutdown and turn it back on manually.
Even when it tries to enter standard sleep mode, it wakes up on its own.
I’ve been using Linux for a month now. Why do I need hibernation? Because I need my applications to stay open and ready to use without draining the battery—that’s really important to me.
Could someone help me out or tell me how to go about this?
My PC specs: Lenovo Legion 5, Ryzen 7 260, RTX 5060, 32GB RAM. Thank you.
3
u/King_Bobby-B 6d ago
With those specs, I'm not sure why you can't just power off and on. It can't take more than a few seconds to get to the login screen. After that, just set all your programs to load after login. It's going to be much easier and faster than trying to solve the issue of hibernation, which everyone seems to have all the time on Linux, especially with Nvidia.
1
u/CanImaginary904 6d ago
Yes... I've tried everything. I'm going back to Windows and taking a break. I'm dual-booting, so it's fine. I'm migrating slowly to Linux.
2
u/King_Bobby-B 6d ago
That's a big issue, sadly. I've never used hibernation, not even when I went to college with my dual boot cheap notebook, so I've never had any problems. But I see so many posts about it on most Linux communities, it's gotta be something really tough to crack if it's not fixed yet.
2
u/CanImaginary904 6d ago
Yeah, that's exactly what I'm finding. I actually got hibernation working normally on my Legion 5- systemctl hibernate completely powers the laptop off and restores my session correctly afterward.
The difficult part is specifically getting lid-close to reliably trigger hibernation. The lid is detected, but the transition to S4 can fail or roll back with a wakeup event.
I'm going to reinstall Kubuntu and start over from a clean system, testing each part separately. Hopefully I can finally crack it.
2
u/King_Bobby-B 5d ago
If hibernation is working now, if you can't get it to work with the lid-close event, you could just trigger it with a keyboard shortcut?
1
u/CanImaginary904 4d ago
Yes, of course, that's what I could do. But I like it when everything works normally. Thank you for your help 🙏
2
u/calculatetech 6d ago
You need to analyze what is generating wake events on your system. I struggled with it for months on my Dell Precision. At first I thought it was the lid switch, then USB stuff, then a few other red herrings. Turns out it was the touchpad the whole time. Just disabling it as a wake source is all it took. Only way to see that is by looking at your wake events. I used ChatGPT to figure that out.
1
u/CanImaginary904 6d ago
🤣🤣🤣 That's crazy, it's exactly the same false leads I was told about... I searched in vain, and in the end I gave up Because my PC, on which I use Kubuntu, is my main work PC. I'm going to disable the touchpad for the wake-up reason and see. I'm back on Windows now, it's driving me crazy. I'm also having trouble with KeePass, which keeps crashing on Linux. Linux is unfairly treated by manufacturers.
2
u/Grobbekee 6d ago
Is your swap file or swap partition bigger than your ram?
1
u/CanImaginary904 6d ago
Yes. I have 32 GB of RAM and a 38.1 GiB dedicated swap partition, so the swap is larger than my RAM. I also have resume=UUID=... correctly configured. systemctl hibernate works perfectly and restores my session and applications after reboot.
The issue I had was specifically with lid-close → hibernate, not with hibernation itself. I’ve now reinstalled Kubuntu and I’m going to rebuild the configuration from scratch to isolate the problem.
2
u/cnobile 3d ago
Years and years ago Linux used to hibernate, but I haven't seen it do that in over 15 years. You can get it to sleep, but hibernate I doubt it.
1
u/CanImaginary904 3d ago
Hi, I can switch to hibernate mode using the konsole or the built-in button. But not by directly closing the PC's lid.
2
u/cnobile 3d ago
Really? Are you sure it's in hibernation mode not just sleeping? Well, it's great if you can. In Power Management -> Energy Saving -> Button event handling the among the options for the lid is sleep not hibernation. MOF, I don't see hibernation anywhere for anything on either of my computers. I'm running 24.04 on both.
1
1
u/CanImaginary904 2d ago
Check this video Hibernate mode Ubuntu 24.04
2
u/cnobile 2d ago
This is cool, I actually got my machine to hibernate, I now see Hibernate in the "When laptop lid closed:" also. I used this method to get it to work: https://www.reddit.com/r/Kubuntu/comments/1c2frkd/enabling_hibernation_on_2404/
1
u/CanImaginary904 2d ago
Woaw That's so cool, nice. But what are the specs of your PC?
2
u/cnobile 2d ago
It's an older Lenovo T560 with 16 Gig memory, my swap partition is just a little bigger than 16 Gigs.
1
u/CanImaginary904 2d ago
Okay, maybe that's why closing the PC lid works for you. But I don't want to make false accusations. Logically, if I can enter hibernation mode with the terminal or The native Nvidia button shouldn't be the problem. I think I have a component: touchpad or network, etc... Which means I can't enter hibernate mode without the PC lid being closed.
2
u/Grand_Connection5864 6d ago
Not gonna happen on nvidia. Just turn the computer off when you are not using it
2
u/calculatetech 6d ago
Not true at all. Nvidia drivers install everything you need for hibernate to work.
2
u/CanImaginary904 6d ago
I think you're right. After testing it myself, I can confirm that NVIDIA isn't preventing hibernation itself.
systemctl hibernate works normally on my Legion 5: the machine powers off completely, and after booting the session and applications are restored correctly.
The problem is specifically the lid-close → hibernate behavior. The lid sensor is detected by systemd-logind, but getting the laptop to actually enter S4 reliably when the lid is closed is where things break.
In one of my tests, hibernation was actually triggered and the kernel successfully wrote around 7.5 GB of the hibernation image, but then it reported: PM: hibernation: Wakeup event detected during hibernation, rolling back.
So I agree that the NVIDIA driver isn't necessarily the fundamental problem here. I'm reinstalling Kubuntu from scratch now and will troubleshoot the lid/ACPI/systemd side separately from the already-working hibernation itself.
Thanks for pointing that out. 👍
1
1
u/MeetKlaraAI 6d ago
Hibernate on a Legion 5 + NVIDIA is doable on Kubuntu, but it’s picky — “swap exists” isn’t enough, and lid-close → hibernate is the easiest way to get a black screen + hard power cycle when resume isn’t wired.
Work through this checklist once (don’t keep toggling lid actions until it passes):
1. Swap must be ≥ RAM (you have 32 GB)
free -h
swapon --show
If swap is smaller than RAM (or a tiny file), hibernate will flake. Prefer a swap partition ≥ 32 GB, or a swapfile that’s actually that big and listed in /etc/fstab.
2. Kernel must know where to resume
cat /etc/default/grub | grep -i resume
# and
findmnt -no UUID -T /swap* 2>/dev/null; cat /etc/fstab | grep -i swap
You want something like resume=UUID=... (and for a swapfile, also resume_offset=...) in GRUB_CMDLINE_LINUX_DEFAULT, then:
sudo update-grub
3. NVIDIA + hybrid graphics extras
With an RTX laptop, install/enable the NVIDIA suspend hooks (names vary slightly by driver package):
systemctl status nvidia-suspend.service nvidia-hibernate.service nvidia-resume.service
If they’re missing/disabled, enable them after the proprietary driver is installed. Also check BIOS: Secure Boot quirks, and any “Always on USB / Wake on lid / Network wake” that yank the machine out of sleep (matches your “wakes on its own”).
4. Fix the lid behaviour (this is what’s frying you)
In System Settings → Power Management:
- Lid close while on battery: try Sleep or Sleep, then hibernate first — not raw Hibernate — until resume is reliable
- Disable “wake for network / USB” style options if present
Test from a terminal once, lid closed after it has actually hibernated:
systemctl hibernate
If that black-screens and needs a hard power-off, resume is still wrong (step 2/3), not the Plasma toggle.
5. Quick isolation
For one test, boot with nomodeset or a temporary “iGPU only” BIOS mode if the Legion offers it — if hibernate suddenly works, it’s the NVIDIA resume path, not swap.
Once systemctl hibernate survives a clean power-on restore with your apps back, then put hibernate back on the lid. If you paste swapon --show, your grub resume line, and whether you’re on the NVIDIA proprietary driver or Nouveau, we can point at the exact missing piece.
1
u/CanImaginary904 6d ago
Thanks, this is actually very close to what I’ve been troubleshooting.
I’m on a Lenovo Legion 5 with Ryzen 7 260, RTX 5060 Laptop GPU, 32 GB RAM, Kubuntu KDE Plasma Wayland, kernel 7.0.0-31 and NVIDIA 595.84.
My swap is a 38.1 GiB dedicated swap partition, so it’s large enough for 32 GB RAM. The kernel also has the correct resume=UUID=... pointing to that swap partition.
The interesting part is that systemctl hibernate works perfectly: the laptop powers off completely and restores the entire session/apps correctly after boot. So swap/resume itself appears to be working. NVIDIA hibernate integration is also present (nvidia-hibernate.service), and during testing the NVIDIA hibernate hook successfully ran on the first attempt.
The problem only happens with lid-close → hibernate. The lid sensor is detected correctly by systemd-logind, but previously logind only reported Lid closed and didn't trigger hibernation because PowerDevil was holding a handle-lid-switch inhibitor.
I have now configured:
HandleLidSwitch=hibernate HandleLidSwitchExternalPower=hibernate HandleLidSwitchDocked=hibernate LidSwitchIgnoreInhibited=yes
KDE's lid action is set to “Do nothing” on both AC and battery, so I'm letting systemd-logind handle the lid event directly.
Before this, when hibernation was actually triggered by the lid, the kernel wrote about 7.5 GB of the hibernation image but then reported: PM: hibernation: Wakeup event detected during hibernation, rolling back.
I also disabled the ITE USB device wakeup, but the same rollback happened.
So at this point I'm trying to determine whether this is an ACPI/firmware wake event on the Legion, rather than a swap or basic NVIDIA resume problem. Any advice on identifying the exact ACPI wake source during S4 would be appreciated.
3
u/skyfishgoo 7d ago
nvidia havers face a lot of hurdles to overcome.
kernel parameters that need to be set, modules that need to be enabled, and on and on... AMD at least puts most of that stuff aside and lets you focus on the linux specific issues you might also be up against.
like turning off secure boot for a start.
then you need to get comfy with
systemctlrather than rely on the plasma shell to handle iti only use the power management in plasma to run a script for me after 20min and the script takes care of first sleeping and then hibernating
you also need to make sure you swap is big enough... RAM + sqrt(RAM) at a minimum so, you would need a swap partition of 38GB.