How can I set laptop's "mem_sleep" to "sleep" instead of "s2idle" to save more battery?

Hello Rocky community!

I was recently given a Dell Precision 3561 from my work and have installed Rocky Linux 9 (5.14.0-70.26.1.el9_0.x86_64) on it and I am using KDE X11 desktop environment.

A few days ago I was working on battery mode closed the lid and was expecting the laptop to be in deep sleep state but apparently that was not the case because when I turned it back on battery was drained. Did a new test by fully charging the battery, removed the power adapter, closed the lid and waited for an hour or so and the battery had dropped to 20% almost.

Checking what power states the system supports I get the following:

cat /sys/power/state 
freeze mem
cat /sys/power/mem_sleep
[s2idle]

As far as I can understand the s2idle is the least capable power saving mode. Is there something I can do or look for in order to save battery while in sleep mode? Like any BIOS setting to look for and adjust? Any other pointers?

Thanks in advance!

Click on the KDE battery icon (or search for Power Management) and you can select the action to perform when laptop lid is closed.

Check this KDE wiki for more details

Hi! Thanks for taking the time to reply to my question.

I have already done that but apparently the sleep mode (shown by mem_sleep above) that is supported (s2idle) is not saving enough battery. I should have had something else there like sleep there I suppose.

Since the title may be confusing I will try to update it to something more explanatory.

According to this: https://www.kernel.org/doc/Documentation/power/states.txt the valid options are:

  • s2idle
  • shallow
  • deep
  • disk

obviously s2idle is not great, because it’s a software option that doesn’t rely on any hardware-related power management options.

For example, on my laptop:

[root@elise ian]# cat /sys/power/mem_sleep 
s2idle [deep]

as you can see mine does actually show a hardware option that is in use and available. That said, this is Fedora 36, so not sure why yours isn’t showing anything else. Could well be that the kernel doesn’t recognise your power management hardware or perhaps other power management packages installed.

You could try enabling elrepo:

dnf install elrepo-release

and then install the mainline kernel, which is kernel 6.x, rather than the default 5.x kernel that comes with RHEL9/Rocky9.

dnf install kernel-ml --enablerepo=elrepo-kernel

reboot and see if that provides any other suspend options.

Hello @iwalker .

Tried that but got the below error:

INFO dkms: running auto installation service for kernel 6.0.2-1.el9.elrepo.x86_64
Sign command: /lib/modules/6.0.2-1.el9.elrepo.x86_64/build/scripts/sign-file
Binary /lib/modules/6.0.2-1.el9.elrepo.x86_64/build/scripts/sign-file not found, modules won't be signed
Error! Your kernel headers for kernel 6.0.2-1.el9.elrepo.x86_64 cannot be found at /lib/modules/6.0.2-1.el9.elrepo.x86_64/build or /lib/modules/6.0.2-1.el9.elrepo.x86_64/source.
Please install the linux-headers-6.0.2-1.el9.elrepo.x86_64 package or use the --kernelsourcedir option to tell DKMS where it's located.
 Done. 
dkms: running auto installation service for kernel 6.0.2-1.el9.elrepo.x86_64
Sign command: /lib/modules/6.0.2-1.el9.elrepo.x86_64/build/scripts/sign-file
Binary /lib/modules/6.0.2-1.el9.elrepo.x86_64/build/scripts/sign-file not found, modules won't be signed
Error! Your kernel headers for kernel 6.0.2-1.el9.elrepo.x86_64 cannot be found at /lib/modules/6.0.2-1.el9.elrepo.x86_64/build or /lib/modules/6.0.2-1.el9.elrepo.x86_64/source.
Please install the linux-headers-6.0.2-1.el9.elrepo.x86_64 package or use the --kernelsourcedir option to tell DKMS where it's located.
 Done. 

Then tried to do : dnf install kernel-ml kernel-ml-headers --enablerepo=elrepo-kernel
resulted in the following:

Error: Transaction test error:
  file /usr/include/asm-generic/fcntl.h from install of kernel-ml-headers-6.0.2-1.el9.elrepo.x86_64 conflicts with file from package kernel-headers-5.14.0-70.26.1.el9_0.x86_64
  file /usr/include/asm-generic/mman-common.h from install of kernel-ml-headers-6.0.2-1.el9.elrepo.x86_64 conflicts with file from package kernel-headers-5.14.0-70.26.1.el9_0.x86_64
  file /usr/include/asm-generic/poll.h from install of kernel-ml-headers-6.0.2-1.el9.elrepo.x86_64 conflicts with file from package kernel-headers-5.14.0-70.26.1.el9_0.x86_64
  file /usr/include/asm-generic/shmbuf.h from install of kernel-ml-headers-6.0.2-1.el9.elrepo.x86_64 

(etc. etc. etc.)

Forget about that…my bad…

I should have used kernel-ml-devel instead of headers .

Let’s reboot now to see what’s going to happen…

Unfortunately I wasn’t able to successfully boot in the new kernel.

The first time the kernel-ml was installed it couldn’t be loaded due to Secure Boot (most probably). I was getting the below error after selecting it at GRUB:

error: ../../grub-core/kern/efi/sb.c:183:bad shim signature.
error: ../../grub-core/loader/i386/efi/linux.c:233:you need to load the kernel first.

Press any key to continue...

So I decided to go the long way of trying to sign the new kernel, which I believe I was successful because the kernel started to boot but a few seconds after (~4sec) it was stopped as soon as the USB keyboard was detected.

I guess this has to do with the disk being encrypted since in the previous kernel at that point it was asking for the LUKS password of the encrypted disk.

With kernel-ml it just stayed there without being able to type anything.