Hi.
It has been 11 years since my last post on Ubuntu Forums. I hope that someone still finds this information useful.
I had a problem with suspend on Acer Apire Vero laptop (i5 1155G7, Iris Xe) running Xubuntu 22.04.1 LTS with stock kernel (5.15.0-48-generic). It turned out that after closing the lid or clicking Menu - Logout - Suspend button the computer did not enter deep sleep mode. The processes were suspended but the fan was still running for a while. Leaving laptop unplugged in that state for 10 hours resulted in 11% of battery loss. According to the document below, the system was entering S0 state (s2idle). This is the "shallowest" of sleep modes. The processes are stopped but the power consumption is not reduced to minimum.
https://www.kernel.org/doc/Documenta...wer/states.txt
Code:
copter@plastic:~$ journalctl | grep -C 2 suspend
Oct 02 19:39:04 plastic systemd[1]: Starting Record successful boot for GRUB...
Oct 02 19:39:04 plastic systemd[1]: Starting System Suspend...
Oct 02 19:39:04 plastic kernel: PM: suspend entry (s2idle)
Oct 02 19:39:04 plastic systemd-sleep[2917]: Entering sleep state 'suspend'...
Oct 02 19:39:04 plastic systemd[1]: grub-common.service: Deactivated successfully.
Oct 02 19:39:04 plastic systemd[1]: Finished Record successful boot for GRUB.
On this system both S0 and S3 states were available but S0 was selected as a default:
Code:
copter@plastic:~$ cat /sys/power/mem_sleep
[s2idle] deep
What is interesting is that on another laptop with Xubuntu 20.04.5 LTS, mem_sleep also returned s2idle but the system seemed to correctly suspend into S3.
The fix was to change mem_sleep to deep (through sudo / root):
Code:
root@plastic:~# cat /sys/power/mem_sleep
[s2idle] deep
root@plastic:~# echo "deep" > /sys/power/mem_sleep
root@plastic:~# cat /sys/power/mem_sleep
s2idle [deep]
To persist this setting I have created a script in root's home:
Code:
root@plastic:~# cat /root/fix-sleep.sh
#!/bin/bash
echo "deep" > /sys/power/mem_sleep
logger "fix-sleep mem sleep: $(cat /sys/power/mem_sleep)"
find /sys/bus/usb/devices/*/power/wakeup -exec sh -c "echo disabled > {}" \;
grep . /sys/bus/usb/devices/*/power/wakeup | while read -r line ; do
logger "fix-sleep usb wakeup: $line"
done
Code:
root@plastic:~# chmod +x /root/fix-sleep.sh
root@plastic:~# ls -l /root/fix-sleep.sh
-rwxr-xr-x 1 root root 216 Oct 2 21:34 /root/fix-sleep.sh
This script is doing few things. It sets deep sleep mode and logs the information in system log. Additionally it disables all USB devices from waking up the computer from sleep. In my case it addressed an annoying issue as moving a mouse cause the system resume.
Next thing to do is to call this script on system startup. For sake of simplicity I decided to use crontab for that. As a
root user edit the crontab with the following command
Code:
root@plastic:~# crontab -e
Add the following line at the end
Code:
@reboot /root/fix-sleep.sh
To verify that the script is actually called during the startup, execute this command (as any user):
Code:
copter@plastic:~$ journalctl | grep fix-sleep
Oct 02 21:34:10 plastic root[6433]: fix-sleep mem sleep: s2idle [deep]
Oct 02 21:34:10 plastic root[6436]: fix-sleep usb wakeup: /sys/bus/usb/devices/1-10/power/wakeup:disabled
Oct 02 21:34:10 plastic root[6437]: fix-sleep usb wakeup: /sys/bus/usb/devices/1-5/power/wakeup:disabled
Oct 02 21:34:10 plastic root[6438]: fix-sleep usb wakeup: /sys/bus/usb/devices/1-7/power/wakeup:disabled
Oct 02 21:34:10 plastic root[6439]: fix-sleep usb wakeup: /sys/bus/usb/devices/usb1/power/wakeup:disabled
Oct 02 21:34:10 plastic root[6440]: fix-sleep usb wakeup: /sys/bus/usb/devices/usb2/power/wakeup:disabled
For testing, after resuming from suspend execute this command. You should see "suspend entry (deep)":
Code:
copter@plastic:~$ journalctl | grep -C 2 suspend
Oct 02 19:40:06 plastic systemd[1]: Starting Record successful boot for GRUB...
Oct 02 19:40:06 plastic systemd[1]: Starting System Suspend...
Oct 02 19:40:06 plastic systemd-sleep[3154]: Entering sleep state 'suspend'...
Oct 02 19:40:06 plastic kernel: PM: suspend entry (deep)
Oct 02 19:40:06 plastic systemd[1]: grub-common.service: Deactivated successfully.
Oct 02 19:40:06 plastic systemd[1]: Finished Record successful boot for GRUB.
To verify that the fans were properly stopped I used the stress tool. It is available in the repository.
Code:
copter@plastic:~$ sudo apt install stress
The following commands results in 100% CPU usage on 4 physical cores. It can be stopped with CTRL-C.
Code:
copter@plastic:~$ stress --cpu 4
stress: info: [3762] dispatching hogs: 4 cpu, 0 io, 0 vm, 0 hdd
You should hear the noise from fans in few seconds. After they are quite loud close the lid or suspend the computer through the menu button. If the fans completely stop in about 5 seconds, then you are in the deep sleep state (S3, suspend to RAM). If the fans continue to spin and will gradually slow down within 1-10 minutes, then most likely you are in S0 state. Let me know and we will try to figure it out together
If you have also problems with screen locking and screen saver, install light locker:
Code:
copter@plastic:~$ sudo apt install light-locker
In my case, default screen locking through xfce4-screensaver resulted in blank screen and no password prompt after resume. It worked just fine with light locker.
Good luck!