Suspend, Hibernate and Sleep States: Why Your Laptop Does Not Wake Up

Suspend, Hibernate and Sleep States: Why Your Laptop Does Not Wake Up

A laptop that drains from 100% to 40% overnight while closed is not broken. It is using s2idle, which is not really suspend, and that has become the default on most new hardware.

The states

StateNamePowerResume
s2idleSuspend to idle, S0ixLow but not negligibleFast
deepSuspend to RAM, S3Very lowFast
diskHibernate, S4NoneSlow
hybridSuspend plus disk imageLike suspendFast, or slow after power loss
# what does your machine support
cat /sys/power/state
# freeze mem disk

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

The bracketed entry is active. If s2idle is bracketed and deep is listed, you can change it. If deep is not listed at all, the firmware does not offer it.

# switch to deep for this boot
echo deep | sudo tee /sys/power/mem_sleep

# permanently, on the kernel command line
# mem_sleep_default=deep

Our kernel parameters guide covers adding that persistently.

Why s2idle took over

Not a mistake, and not an improvement for everyone.

S3 genuinely suspends: the CPU is off, RAM is in self-refresh, and power draw is close to nothing. Resume reinitialises everything from a known state.

s2idle keeps the system running in a very low idle state. Nothing is truly off. The advantage is that the machine can do things while “asleep”, which is how Windows Modern Standby delivers notifications and background sync.

The costs on Linux are real:

  • Higher drain, because components are still powered
  • Dependent on every driver cooperating with low-power idle, and one that does not keeps the whole machine awake
  • Harder to diagnose, since the failure is a machine that is warm rather than one that will not wake

Several vendors have shipped firmware that implements only s2idle, removing S3 entirely. On such a machine cat /sys/power/mem_sleep shows no deep, and the only lever is a firmware setting if one exists.

# how much are you actually losing
# before
cat /sys/class/power_supply/BAT0/capacity
systemctl suspend
# after waking, compare
cat /sys/class/power_supply/BAT0/capacity

Our sysfs guide covers reading battery state and our power management guide covers the wider picture.

What is keeping it awake

# wakeup sources, which is where overnight wakes come from
cat /proc/acpi/wakeup

# anything with enabled can wake the machine
grep enabled /proc/acpi/wakeup

# disable one, by its device name from that file
echo XHC1 | sudo tee /proc/acpi/wakeup

The usual culprits are USB controllers and network cards with wake-on-LAN. A machine that wakes in a bag, runs hot and drains is frequently an enabled wakeup source rather than a suspend problem.

# wake-on-LAN state
sudo ethtool eth0 | grep -i wake
sudo ethtool -s eth0 wol d

# what woke it last time
sudo journalctl -b | grep -iE 'ACPI.*wake|PM: .*wakeup'
# s2idle residency, on Intel: are you reaching the low power states
sudo turbostat --quiet --show Pkg%pc2,Pkg%pc3,Pkg%pc6,SYS%LPI --interval 5

SYS%LPI near zero during s2idle means the system is not reaching its low-power state, which is the measurable version of “drains overnight”. Our lm-sensors guide covers reading the thermal consequence.

Hibernate

Writes memory to swap and powers off. No drain at all, at the cost of a slow resume.

# swap must be large enough for the memory in use
free -h
swapon --show

Swap needs to be at least as large as the memory you want to save. Distributions usually hide the hibernate option when there is no suitable swap, which is why the menu entry is missing rather than the feature being absent.

With a swap partition

# find the UUID
swapon --show
blkid /dev/sda2
# kernel command line
resume=UUID=abcd-1234

With a swap file

Fiddlier, because the kernel needs the physical offset as well as the device.

# the device holding the swap file
findmnt -no SOURCE -T /swapfile

# the offset, which is the first physical block
sudo filefrag -v /swapfile | awk '$1=="0:" {print substr($4, 1, length($4)-2)}'
# kernel command line, both are required
resume=UUID=<root-fs-uuid> resume_offset=<the-number>
# regenerate the initramfs so the resume hook has it
sudo update-initramfs -u            # Debian and Ubuntu
sudo dracut --force                 # Fedora
sudo mkinitcpio -P                  # Arch

Our initramfs guide covers why resume happens there, and our swap guide covers sizing.

On Btrfs, swap files have extra requirements: no copy-on-write, no compression, and the file must be created in a specific way. Our chattr guide covers the +C flag that is part of it, and it must be set before data goes in.

# test it
sudo systemctl hibernate

# did it work, and what did it say
sudo journalctl -b -1 | grep -iE 'hibernat|PM: ' | tail -30

Hibernate and Secure Boot

Worth knowing: with Secure Boot and lockdown enabled, hibernation is disabled by default on many kernels, because the hibernation image is unsigned memory being restored into a verified kernel. That is a deliberate restriction rather than a bug.

cat /sys/kernel/security/lockdown 2>/dev/null
mokutil --sb-state

Our Secure Boot guide covers the model.

When resume fails

A methodical sequence, because guessing is slow.

# 1. read the previous boot's log, which is where the evidence is
sudo journalctl -b -1 -n 100 --no-pager
sudo journalctl -b -1 | grep -iE 'PM: |ACPI|dpm_run_callback|failed'

# 2. did it even try
sudo journalctl -b -1 | grep -i 'PM: suspend entry'
# 3. test from a text console, bypassing the display stack
sudo systemctl stop display-manager
# Ctrl+Alt+F3, log in, then
sudo systemctl suspend

If console suspend works and desktop suspend does not, the problem is graphics, which narrows it enormously. Our GPU drivers guide and NVIDIA guide cover the resume path, and NVIDIA specifically needs its suspend services enabled:

systemctl status nvidia-suspend nvidia-resume nvidia-hibernate
# 4. narrow it with the kernel's own test modes
echo devices | sudo tee /sys/power/pm_test
sudo systemctl suspend     # tests without actually suspending
echo none | sudo tee /sys/power/pm_test

pm_test is underused. It runs the suspend sequence up to a chosen stage and returns, so a failure in device suspend is identified without the machine going dark. Values are freezer, devices, platform, processors, core.

# 5. find the device that fails
echo 1 | sudo tee /sys/power/pm_print_times
sudo systemctl suspend
# after resume
sudo dmesg | grep -i 'PM: ' | sort -k3 -rn | head

That prints how long each device took to suspend and resume, which usually identifies the one that hangs.

Lid and idle behaviour

Configured by systemd-logind.

# /etc/systemd/logind.conf.d/10-lid.conf
[Login]
HandleLidSwitch=suspend
HandleLidSwitchExternalPower=suspend
HandleLidSwitchDocked=ignore
IdleAction=suspend
IdleActionSec=30min
sudo systemctl restart systemd-logind
loginctl show-session "$(loginctl --no-legend | awk 'NR==1{print $1}')" | grep -i idle

Restarting logind can end your graphical session on some setups, so do it from a console or accept a logout.

# suspend then hibernate, which is the best of both on a laptop
sudo systemctl suspend-then-hibernate
# /etc/systemd/sleep.conf.d/10-hibernate-delay.conf
[Sleep]
HibernateDelaySec=2h

suspend-then-hibernate suspends immediately and hibernates after a delay, so closing the lid gives a fast resume for the first couple of hours and no battery drain after that. This is the configuration most laptops should be using and very few have by default.

Turning it off

A legitimate workaround on hardware where resume is unreliable.

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
# /etc/systemd/logind.conf.d/20-nosuspend.conf
[Login]
HandleLidSwitch=ignore
HandleSuspendKey=ignore
IdleAction=ignore

The caveat: a laptop closed and running gets hot in a bag, and will throttle or shut down thermally. If you do this, also stop the lid from being the only cue, per our sensors guide.

Frequently Asked Questions

What is the difference between suspend and hibernate?

Suspend keeps memory powered and the rest of the machine mostly off, so it resumes in a second or two and consumes a little battery. Hibernate writes memory to swap and powers off completely, so it uses no power and takes much longer to resume. Hybrid sleep does both, suspending but with an image on disk as insurance.

Why does my laptop drain its battery overnight while suspended?

Almost certainly because it is using s2idle rather than deep S3 suspend. s2idle keeps the CPU in a low power idle state rather than genuinely suspending, so it consumes considerably more. Many modern laptops do not implement S3 at all, in which case the firmware setting may be the only lever.

How do I enable hibernate when the option is missing?

Hibernate needs swap at least as large as the memory you want to save, and the kernel needs to be told where to resume from. Most distributions hide the option when no suitable swap exists. Check swap size first, then the resume parameter on the kernel command line.

Why does hibernate fail on a system with a swap file instead of a partition?

Because the kernel needs the physical offset of the swap file as well as the device, which a swap partition does not require. The resume_offset parameter supplies it, and the value comes from filefrag. Btrfs swap files also have specific requirements that make this fiddlier.

What should I check when resume produces a black screen?

The graphics driver first, since resume reinitialises the GPU and that is where most failures occur. Read the journal from the previous boot for the resume sequence, and test whether suspending from a text console works, because a successful console resume points at the display stack rather than the kernel.

Is it safe to disable suspend entirely?

Yes, and it is a reasonable workaround on a machine where resume is unreliable. Mask the sleep targets in systemd and configure the lid switch to do nothing, with the caveat that a laptop closed and running gets hot in a bag.