50
submitted 8 months ago by WbrJr@lemmy.ml to c/linux@lemmy.ml

Hi there!

I need some help with my framework laptop and fedora. I want to switch to linux more permanently, but fedora does not enter hibernation properly when closing the lid. I dont care 10-20sec of wakeup time when opening it again. (even windows is more efficient?!) The relatively bad performance on battery life is OK for me, I already installed TLP instead of the default power management. But when closing the lid, the battery drains about 80% over night (10h?) which seems to be more than what other people reported.

I could not find a guide on this, which i understood (still a massive noob to afraid to mess up my carefully crafted linux partition :D).

If you have any advice I appreciate it! Thanks a lot! :)

top 28 comments
sorted by: hot top controversial new old
[-] nitrolife@rekabu.ru 17 points 8 months ago

In first you need understand what type of suspend you use:

Suspend to RAM (aka suspend, aka sleep) The S3 sleeping state as defined by ACPI. Works by cutting off power to most parts of the machine aside from the RAM, which is required to restore the machine's state. Because of the large power savings, it is advisable for laptops to automatically enter this mode when the computer is running on batteries and the lid is closed (or the user is inactive for some time). Suspend to disk (aka hibernate) The S4 sleeping state as defined by ACPI. Saves the machine's state into swap space and completely powers off the machine. When the machine is powered on, the state is restored. Until then, there is zero power consumption. Hybrid suspend (aka hybrid sleep) A hybrid of suspending and hibernating, sometimes called suspend to both. Saves the machine's state into swap space, but does not power off the machine. Instead, it invokes the default suspend. Therefore, if the battery is not depleted, the system can resume instantly. If the battery is depleted, the system can be resumed from disk, which is much slower than resuming from RAM, but the machine's state has not been lost.

I think you use Hybrid suspend. Hybrid suspend store memory to disk (20 seconds lag) and then lost battery for memory renew. Need you Suspend to RAM maybe? 20 Seconds lag will fixed with that.

Then check

cat /sys/power/mem_sleep

If you see

[s2idle] shallow deep

check first if your UEFI advertises some settings for it, generally under Power or Sleep state or similar wording, with options named Windows 10, Windows and Linux or S3/Modern standby support for S0ix, and Legacy, Linux, Linux S3 or S3 enabled for S3 sleep.

If you don't see anything you can swap sleep mode to Suspend to disk. That slow but don't use any power. Or try fix sleep status.

More information you can find here: https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate

[-] WbrJr@lemmy.ml 3 points 8 months ago

Thank you for your reply. It says: [s2idle] deep I don't think i have the swap partition, I will try to create that. Thanks!

[-] Frederic@beehaw.org 17 points 8 months ago

Hibernation or suspend? 2 different things. For hibernation you need a swap space at least the size of your RAM, and then the laptop is powered off after this.

For suspend, in your dmesg, see if you have:

ACPI: PM: (supports S0 S3 S4 S5)

if you have S3 your laptop should lost only a few percent.

do a:

cat /sys/power/mem_sleep

what does it says?

New CPU/BIOS/PC/Laptop only support something called "s0 idle" meaning it is like a cellphone, everything is running, and each drivers/components/os should enter low power themselves, if they do not, well, your battery is draining.

S3 means "suspend to RAM", only RAM is powered and everything else is off, your laptop can stay like this for days. I don't know who decided that this is bad and your laptop should be like your cellphone, always running?!?

Modern Fedora doesn't enable swap by default and configures zram instead. Of course, you can't hibernate to zram, so getting basic hibernation to work involves either disabling zram and configuring swap, or using callbacks to temporarily disable zram and enable swap right before suspending.

Neither is very beginner friendly, unfortunately.

[-] Vincent@kbin.social 4 points 8 months ago

I'm assuming you've already found it, but just in case you didn't: Framework has setup guides for Fedora, which presumably should make everything work as intended. Find your device on this page, then click "Fedora 39 Setup Guide" on the right-hand side: https://frame.work/linux

[-] baseless_discourse@mander.xyz 4 points 8 months ago

Hibernate in general has pretty poor support across all distros: https://askubuntu.com/questions/1146326/why-is-hibernation-so-complicated-on-ubuntu-and-other-linux-distributions This is also true across other OS, IIRC Windows also hides its hibernate feature.

Personally I just use suspend or power off.

[-] chitak166@lemmy.world 4 points 8 months ago

I just want to say, power management needs to be improved across the entire Linux ecosystem.

[-] PainInTheAES@lemmy.world 4 points 8 months ago

See: https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate

You're probably missing a swap position or file. Modern Linux distro don't really support hibernate out of the box.

Also depending on ports you can have worse sleeping power draw. All USB C will give you the best battery life.

[-] WbrJr@lemmy.ml 1 points 8 months ago

I have read this about the expansion cards and only use 2c and 2A. A bit stupid considering you can hack the hdmi port into suspending on its own.. Did not expect this from fw.

I will check out the link, thanks!

[-] PainInTheAES@lemmy.world 1 points 8 months ago

IIRC framework is working on addressing the expansion card issue via firmware/BIOS but it's been a while since I've seen any updates.

I generally lose 20-40% battery overnight with USBC and USBA in deep sleep mode. But I have set up hibernate in the past and had it working.

[-] WbrJr@lemmy.ml 1 points 8 months ago

That is almost equivalent to 1h of browsing in Linux! :D \s Other expension cards are drawing about 1W of power, even without use! That's crazy much I think..

[-] PainInTheAES@lemmy.world 2 points 8 months ago

Kinda true though. I wish Framework would focus on power usage a bit. As much as I love the concept and laptop the battery life is not one of its strong points. I've done a lot of tuning and squeeze about 6-7 hrs out at ~40% screen brightness.

[-] WbrJr@lemmy.ml 1 points 8 months ago

In Linux?! That's quite a bit. With heavy workload?

[-] PainInTheAES@lemmy.world 1 points 8 months ago

Yeah, but with a light workload (browsing, some videos, office applications). It lasts longer than Windows where I get like 5 hours.

[-] WbrJr@lemmy.ml 1 points 8 months ago

Yo lol, that's impressive :D

[-] sir_pronoun@lemmy.world 3 points 8 months ago

Did you set up a swap partition?

[-] hottari@lemmy.ml 2 points 8 months ago

Am on Arch and hibernation is currently broken with systemd 255 in my case. They introduced a lot of breaking changes for it. It works after enabling some workarounds for dracut 059 but it completely does a full power cycle. Your best bet is sticking with suspend until systemd unfucks hibernation.

[-] SquigglyEmpire@lemmy.world 2 points 8 months ago

Which model do you have? There's a known issue affecting the sleep/hibernate for the chipset on the new AMD model on the, I believe AMD has already submitted patches to fix it in the next kernel release though.

[-] WbrJr@lemmy.ml 3 points 8 months ago

I have the first European batch

[-] SquigglyEmpire@lemmy.world 1 points 7 months ago

Hopefully this will make it in as an update for currently supported kernels, but if not it should be in the upcoming 6.8 release:

https://www.phoronix.com/news/Framework-13-AMD-Lid-Suspend

Framework has a guide for you. You'll need to disable either power-profiles-daemon or TLP depending on what CPU you have.

As for hibernation: TL;DR: it's a mess. Fedora doesn't support it out of the box. You can make it work with some elbow grease.

However, you shouldn't need hibernation if your laptop goes to sleep like it should. If you can't get it to sleep right, or still really want hibernation, here are some pointers:

  • many Linux distros don't consider hibernation to be a stable feature. The default Fedora setup doesn't even come with a swap partition by default, which makes hibernation impossible. You'll need to allocate some swap space before you can hibernate your computer.
  • make sure your swap partition is encrypted if the rest of your laptop is encrypted as well. If you use a swap file, you can make this work, too, but it'll be slightly more complicated
  • make sure your swap partition is big enough (at least RAM size + the amount of swap in use at the point of hibernation)
  • if you're fine with disabling zram and using normal, this guide will show you how to hibernate a normal Linux system: https://www.ctrl.blog/entry/fedora-hibernate.html
  • if you don't have a partition for swap and don't want to create one, or if you want to keep using zram (compressed memory, enabled by default on Fedora, probably recommended to keep enabled), then this guide and its comments will tell you how to get a swap file to work. Make sure you read the update with more details too, and there's also a comment further down specifically about Intel Framework laptops (need to disable a certain Intel driver that breaks hibernation).
  • disable secure boot in your BIOS. Linux doesn't support the security features that Windows has to validate the state of boot SECURITY (even with custom secure boot keys), so when you're running in secure boot mode (and the kernel is in lockdown mode), the Linux kernel disables hibernation. Alternatively, there are guides that'll show you how to patch that check out, but that involves compiling your own kernel and that's not worth the effort IMO.
  • configure your laptop for suspend-then-hibernate for best performance. I believe hybrid-sleep will also work. The Github gist I linked has details
  • you will probably need to enter your password when resuming from hibernation. This is a security feature. You can configure your laptop to use the TPM to decrypt the disk, skipping the encryption password entirely, it you don't mind thieves having the ability to access your data when they steal the laptop.

You may be wondering why this is so complicated. A big reason is that Linux wants to be secure, but hibernation comes with unique security challenges. Linux also wants to be fast and efficient (by compressing RAM rather than writing it to disk) but that messes with the presumptions the hibernation system makes. Fedora dorky sorry hibernation out of the box, but they're working on it, albeit not as fast as you might hope: https://pagure.io/fedora-workstation/issue/121

this post was submitted on 19 Dec 2023
50 points (96.3% liked)

Linux

46672 readers
1416 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS