Battery Life: Change sleep mode from s2idle to deep - junaruga/framework-laptop-config GitHub Wiki

On Fedora 35 on Framework Laptop, there is an issue [1] about s2idle sleep on kernel 5.16.5. The deep sleep is also better to have a battery life than s2idle. And even when there is no such kind of issue, it is reported that deep sleep is better [2] for the battery life than s2idle.

This page is how to change the default sleep s2idle to deep.

My environment

  • Fedora Linux 35.

  • Kernel version: 5.15.18-200.fc35.x86_64

    $ uname -r
    5.15.18-200.fc35.x86_64
    

Change temporarily

If you want to change the sleep mode to deep temporarily. Here is the steps. This case could be used to test the battery performance.

Check the current sleep mode. The sleep mode is s2idle in this case.

$ cat /sys/power/mem_sleep
[s2idle] deep

Run the following command to change to the deep sleep. Note this sys file is unlike normal file. The following command changes the sleep mode to deep file.

# echo deep > /sys/power/mem_sleep

or

$ echo deep | sudo tee /sys/power/mem_sleep
deep

Note that the following command with sudo doesn't work, because the shell redirection > file is executed on user shell not on sudo.

$ sudo echo deep > /sys/power/mem_sleep
bash: /sys/power/mem_sleep: Permission denied

Then you can check the mode is changed to deep sleep.

$ cat /sys/power/mem_sleep
s2idle [deep]

If you want to change back to s2idle, run

# echo s2idle > /sys/power/mem_sleep

$ cat /sys/power/mem_sleep
[s2idle] deep

Change permanently

Change the setting

According to Fedora GRUB2 wiki page [3], it is better to run the command grubby rather than modifying the grub2 config file directly.

First check the current grub settings.

$ sudo grubby --info=ALL
index=0
kernel="/boot/vmlinuz-5.15.18-200.fc35.x86_64"
args="ro rootflags=subvol=root rd.luks.uuid=luks-09538e5a-f802-40a6-bc22-328604dc2312 rhgb quiet"
root="UUID=be430ab5-ebda-4f4f-a01e-427d18fb12f1"
initrd="/boot/initramfs-5.15.18-200.fc35.x86_64.img"
title="Fedora Linux (5.15.18-200.fc35.x86_64) 35 (Workstation Edition)"
id="80e9c3d2b9dc4e93a3ab129c79655481-5.15.18-200.fc35.x86_64"
index=1
kernel="/boot/vmlinuz-5.15.16-200.fc35.x86_64"
args="ro rootflags=subvol=root rd.luks.uuid=luks-09538e5a-f802-40a6-bc22-328604dc2312 rhgb quiet"
root="UUID=be430ab5-ebda-4f4f-a01e-427d18fb12f1"
initrd="/boot/initramfs-5.15.16-200.fc35.x86_64.img"
title="Fedora Linux (5.15.16-200.fc35.x86_64) 35 (Workstation Edition)"
id="80e9c3d2b9dc4e93a3ab129c79655481-5.15.16-200.fc35.x86_64"
index=2
kernel="/boot/vmlinuz-5.15.10-200.fc35.x86_64"
args="ro rootflags=subvol=root rd.luks.uuid=luks-09538e5a-f802-40a6-bc22-328604dc2312 rhgb quiet"
root="UUID=be430ab5-ebda-4f4f-a01e-427d18fb12f1"
initrd="/boot/initramfs-5.15.10-200.fc35.x86_64.img"
title="Fedora Linux (5.15.10-200.fc35.x86_64) 35 (Workstation Edition)"
id="80e9c3d2b9dc4e93a3ab129c79655481-5.15.10-200.fc35.x86_64"
index=3
kernel="/boot/vmlinuz-0-rescue-80e9c3d2b9dc4e93a3ab129c79655481"
args="ro rootflags=subvol=root rd.luks.uuid=luks-09538e5a-f802-40a6-bc22-328604dc2312 rhgb quiet"
root="UUID=be430ab5-ebda-4f4f-a01e-427d18fb12f1"
initrd="/boot/initramfs-0-rescue-80e9c3d2b9dc4e93a3ab129c79655481.img"
title="Fedora Linux (0-rescue-80e9c3d2b9dc4e93a3ab129c79655481) 35 (Workstation Edition)"
id="80e9c3d2b9dc4e93a3ab129c79655481-0-rescue"

Run to modify the grub settings to use the kernel argument mem_sleep_default=deep for all the kernels.

$ sudo grubby --update-kernel=ALL --args=mem_sleep_default=deep

You see the mem_sleep_default=deep is added to each args= line.

$ sudo grubby --info=ALL
index=0
kernel="/boot/vmlinuz-5.15.18-200.fc35.x86_64"
args="ro rootflags=subvol=root rd.luks.uuid=luks-09538e5a-f802-40a6-bc22-328604dc2312 rhgb quiet mem_sleep_default=deep"
root="UUID=be430ab5-ebda-4f4f-a01e-427d18fb12f1"
initrd="/boot/initramfs-5.15.18-200.fc35.x86_64.img"
title="Fedora Linux (5.15.18-200.fc35.x86_64) 35 (Workstation Edition)"
id="80e9c3d2b9dc4e93a3ab129c79655481-5.15.18-200.fc35.x86_64"
index=1
kernel="/boot/vmlinuz-5.15.16-200.fc35.x86_64"
args="ro rootflags=subvol=root rd.luks.uuid=luks-09538e5a-f802-40a6-bc22-328604dc2312 rhgb quiet mem_sleep_default=deep"
root="UUID=be430ab5-ebda-4f4f-a01e-427d18fb12f1"
initrd="/boot/initramfs-5.15.16-200.fc35.x86_64.img"
title="Fedora Linux (5.15.16-200.fc35.x86_64) 35 (Workstation Edition)"
id="80e9c3d2b9dc4e93a3ab129c79655481-5.15.16-200.fc35.x86_64"
index=2
kernel="/boot/vmlinuz-5.15.10-200.fc35.x86_64"
args="ro rootflags=subvol=root rd.luks.uuid=luks-09538e5a-f802-40a6-bc22-328604dc2312 rhgb quiet mem_sleep_default=deep"
root="UUID=be430ab5-ebda-4f4f-a01e-427d18fb12f1"
initrd="/boot/initramfs-5.15.10-200.fc35.x86_64.img"
title="Fedora Linux (5.15.10-200.fc35.x86_64) 35 (Workstation Edition)"
id="80e9c3d2b9dc4e93a3ab129c79655481-5.15.10-200.fc35.x86_64"
index=3
kernel="/boot/vmlinuz-0-rescue-80e9c3d2b9dc4e93a3ab129c79655481"
args="ro rootflags=subvol=root rd.luks.uuid=luks-09538e5a-f802-40a6-bc22-328604dc2312 rhgb quiet mem_sleep_default=deep"
root="UUID=be430ab5-ebda-4f4f-a01e-427d18fb12f1"
initrd="/boot/initramfs-0-rescue-80e9c3d2b9dc4e93a3ab129c79655481.img"
title="Fedora Linux (0-rescue-80e9c3d2b9dc4e93a3ab129c79655481) 35 (Workstation Edition)"
id="80e9c3d2b9dc4e93a3ab129c79655481-0-rescue"

Reboot OS.

$ sudo reboot

You see the sleep mode is deep.

$ cat /sys/power/mem_sleep
s2idle [deep]

Change back the setting

If you want to remove the argument mem_sleep_default=deep you added, the command is like this.

$ sudo grubby --update-kernel=ALL --remove-args=mem_sleep_default

$ sudo grubby --info=ALL
index=0
kernel="/boot/vmlinuz-5.15.18-200.fc35.x86_64"
args="ro rootflags=subvol=root rd.luks.uuid=luks-09538e5a-f802-40a6-bc22-328604dc2312 rhgb quiet"
root="UUID=be430ab5-ebda-4f4f-a01e-427d18fb12f1"
initrd="/boot/initramfs-5.15.18-200.fc35.x86_64.img"
title="Fedora Linux (5.15.18-200.fc35.x86_64) 35 (Workstation Edition)"
id="80e9c3d2b9dc4e93a3ab129c79655481-5.15.18-200.fc35.x86_64"
index=1
kernel="/boot/vmlinuz-5.15.16-200.fc35.x86_64"
args="ro rootflags=subvol=root rd.luks.uuid=luks-09538e5a-f802-40a6-bc22-328604dc2312 rhgb quiet"
root="UUID=be430ab5-ebda-4f4f-a01e-427d18fb12f1"
initrd="/boot/initramfs-5.15.16-200.fc35.x86_64.img"
title="Fedora Linux (5.15.16-200.fc35.x86_64) 35 (Workstation Edition)"
id="80e9c3d2b9dc4e93a3ab129c79655481-5.15.16-200.fc35.x86_64"
index=2
kernel="/boot/vmlinuz-5.15.10-200.fc35.x86_64"
args="ro rootflags=subvol=root rd.luks.uuid=luks-09538e5a-f802-40a6-bc22-328604dc2312 rhgb quiet"
root="UUID=be430ab5-ebda-4f4f-a01e-427d18fb12f1"
initrd="/boot/initramfs-5.15.10-200.fc35.x86_64.img"
title="Fedora Linux (5.15.10-200.fc35.x86_64) 35 (Workstation Edition)"
id="80e9c3d2b9dc4e93a3ab129c79655481-5.15.10-200.fc35.x86_64"
index=3
kernel="/boot/vmlinuz-0-rescue-80e9c3d2b9dc4e93a3ab129c79655481"
args="ro rootflags=subvol=root rd.luks.uuid=luks-09538e5a-f802-40a6-bc22-328604dc2312 rhgb quiet"
root="UUID=be430ab5-ebda-4f4f-a01e-427d18fb12f1"
initrd="/boot/initramfs-0-rescue-80e9c3d2b9dc4e93a3ab129c79655481.img"
title="Fedora Linux (0-rescue-80e9c3d2b9dc4e93a3ab129c79655481) 35 (Workstation Edition)"
id="80e9c3d2b9dc4e93a3ab129c79655481-0-rescue"

Reboot OS.

$ sudo reboot

References