Sleep Is a Spectrum (And Linux Takes That Literally)
On Windows you hit sleep and stuff works. On Linux, you might suspend successfully for a week and then one day wake up to a hung system, a blank screen, or a kernel panic that takes your session with it. It’s not Linux’s fault specifically — the firmware, hardware, and drivers are all conspiring against you — but you need to understand what’s happening to fix it.
There are multiple sleep states. They trade power savings for complexity and resume reliability. Here’s the breakdown:
The Sleep States (S1 through S4)
The ACPI spec defines sleep states S1 through S5 (S5 is powered off). The useful ones:
S1 — CPU Stop Grant: CPU stops executing instructions, RAM stays powered. Very fast resume, almost no power savings. Almost nobody uses this.
S2 — Similar to S1: CPU powered off. Rare. Not really a thing on modern hardware.
S3 — Suspend to RAM (STR): The one you call “sleep.” CPU and most devices powered off. RAM stays powered to retain state. Typically uses 1-5 watts. Resume in 1-3 seconds. This is what systemctl suspend does.
S4 — Hibernate (Suspend to Disk): Everything written to swap/disk, then powered off completely. Uses 0 watts. Resume in 10-30 seconds (basically a specialized boot). This is what systemctl hibernate does.
Hybrid Sleep: Saves state to disk (like hibernate) but also stays in S3 (like suspend). If power is lost, it can resume from disk. Best of both worlds, slightly slower to enter than pure suspend.
# What sleep states does your hardware support?cat /sys/power/state# Typical output: freeze mem disk
# Check supported hibernation modescat /sys/power/disk# Typical output: platform shutdown reboot suspend [platform]Suspend to RAM: Usually Just Works
# Suspend immediatelysystemctl suspend
# Or the old wayecho mem > /sys/power/stateSuspend usually works on modern hardware. When it doesn’t, the problems are:
- GPU driver not supporting suspend/resume (nouveau is a frequent offender)
- USB controllers not waking properly
- Wi-Fi firmware not supporting power state transitions
Debug it:
# Check what happened during last suspend/resume cyclejournalctl -b -1 -u systemd-sleepjournalctl -b -1 | grep -i "suspend\|resume\|wake"
# See what's blocking suspendcat /sys/power/wakeup_countcat /proc/acpi/wakeupHibernate: Requires More Setup
Hibernate is trickier because it requires a properly configured swap space and the initramfs needs to know where to find it.
Step 1: Make Sure You Have Enough Swap
For hibernate, you need swap space at least as large as your RAM. More is better because your RAM might not be 100% used.
# Check current swapswapon --showfree -h
# If you need more swap — create a swapfilesudo fallocate -l 16G /swapfilesudo chmod 600 /swapfilesudo mkswap /swapfilesudo swapon /swapfile
# Make it permanentecho '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstabFor a dedicated swap partition, the partition already exists in most installs — just verify it’s large enough.
Step 2: Find the Resume Device
You need to tell the kernel where to find the saved hibernate image on boot.
# Find your swap partition or file's UUIDsudo blkid | grep swap# OR for a swapfile:stat /swapfile# Note the device it's on
# For a swapfile, get the offsetsudo filefrag -v /swapfile | head -5# The first extent's physical_offset is what you needStep 3: Configure GRUB for Resume
Edit your GRUB config:
sudo nano /etc/default/grubFor a swap partition:
GRUB_CMDLINE_LINUX="resume=UUID=your-swap-uuid-here"For a swapfile (replace with your actual device UUID and offset):
GRUB_CMDLINE_LINUX="resume=UUID=your-root-device-uuid resume_offset=12345678"Then update GRUB:
# Debian/Ubuntusudo update-grub
# RHEL/Fedorasudo grub2-mkconfig -o /boot/grub2/grub.cfgStep 4: Update the Initramfs
The initramfs needs to include the resume hook so it can restore the hibernate image on boot:
# Ubuntu/Debian — edit initramfs configcat /etc/initramfs-tools/conf.d/resume# Should contain: RESUME=UUID=your-swap-uuid
# If it doesn't exist or is wrong, create/edit it:echo "RESUME=UUID=$(findmnt -no UUID /swapfile 2>/dev/null || blkid -s UUID -o value /dev/sdX)" \ | sudo tee /etc/initramfs-tools/conf.d/resume
# Rebuild initramfssudo update-initramfs -u -k all
# Test hibernatesystemctl hibernateIf it works, your system powers off and comes back with your session intact. If it doesn’t, check journalctl -b -1 for clues.
UEFI Secure Boot Complications
Hibernate can fail with Secure Boot if the hibernate image is considered untrusted. The typical symptom: system resumes to a fresh session instead of your saved state, or refuses to load the hibernate image entirely.
The kernel checks that the hibernate image was created by a trusted kernel. If you’re using DKMS modules (like NVIDIA drivers or VirtualBox) and they’re not signed, Secure Boot can interfere.
Options:
- Disable Secure Boot in UEFI settings (easiest for home lab)
- Sign your kernel modules properly (the Right Way)
- Use
lockdown=integritykernel parameter and accept the limitations
# Check if Secure Boot is enabledmokutil --sb-state
# Check if lockdown is activecat /sys/kernel/security/lockdownHybrid Sleep: The Best Compromise
For laptops and machines where power cuts are possible, hybrid sleep is often the best option:
# Enable hybrid sleep as the default sleep modesudo nano /etc/systemd/sleep.conf[Sleep]SuspendMode=suspendHibernateMode=platform shutdownHybridSleepMode=suspend platform shutdownHybridSleepDelay=120minSuspendState=memHibernateState=diskHybridSleepState=disk# Test hybrid sleepsystemctl hybrid-sleepThe HybridSleepDelay option in newer systemd means: suspend normally, but if the system is still asleep after that duration, automatically hibernate. Brilliant for laptops — fast wakes for short naps, full hibernation for overnight.
Laptop Lid Close Behavior
This drives everyone insane at least once. Control it in /etc/systemd/logind.conf:
[Login]HandleLidSwitch=suspend # What to do when lid closesHandleLidSwitchExternalPower=suspend # When plugged inHandleLidSwitchDocked=ignore # When docked (connected to external display)IdleAction=suspend # What to do after idle timeoutIdleActionSec=30minsudo systemctl restart systemd-logindOptions for HandleLidSwitch: suspend, hibernate, hybrid-sleep, suspend-then-hibernate, poweroff, ignore.
Wake-on-LAN
Wake-on-LAN (WoL) lets you remotely wake a sleeping machine by sending a “magic packet” to its MAC address. Useful for home labs where you want a server to suspend when idle but wake on demand.
# Check if your NIC supports WoLsudo ethtool eth0 | grep -i wake
# Enable WoLsudo ethtool -s eth0 wol g # g = magic packet
# Make it persistent with a systemd service[Unit]Description=Enable Wake-on-LANAfter=network.target
[Service]Type=oneshotExecStart=/sbin/ethtool -s eth0 wol gRemainAfterExit=yes
[Install]WantedBy=multi-user.targetsudo systemctl enable --now wol.service
# Send the magic packet from another machine# Install wakeonlan: sudo apt install wakeonlanwakeonlan AA:BB:CC:DD:EE:FF# Or with etherwakesudo etherwake -i eth0 AA:BB:CC:DD:EE:FFFor WoL to work through suspension, you also need to enable it in the UEFI/BIOS settings under “Power Management” or similar.
Troubleshooting Common Failures
System suspends but wakes up immediately: Something is triggering a wakeup. Check:
cat /proc/acpi/wakeup# Disable a wakeup source (e.g., USB)echo USB3 | sudo tee /proc/acpi/wakeupBlank screen after resume: Usually a GPU driver issue. Try:
# For NVIDIAsudo systemctl enable nvidia-suspend.servicesudo systemctl enable nvidia-hibernate.servicesudo systemctl enable nvidia-resume.serviceHibernate fails with “not enough swap”: Your swap is too small. Add more swap space.
Resume from hibernate boots to login screen instead of session: Usually a display manager issue, not a hibernate failure. Your session is restored at the kernel level, but the display manager intercepts before showing it. Check if your DM has a “resume session” option.
System won’t hibernate, returns to running state immediately: Check systemd-inhibit --list — something is holding an inhibitor lock:
systemd-inhibit --list# Kill the offending process or wait for it to finishGetting suspend and hibernate working properly takes some tuning, but once it’s dialed in, you stop thinking about it entirely. The payoff — especially for laptops — is real: faster wake times than a full boot, battery preservation, and sessions that survive overnight without running your fans all night.
Your laptop deserves to sleep. Let it.