Laptop Suspend & Hibernate
Basic Concepts
| Mode | Name | Description |
|---|---|---|
| Suspend | Suspend (S3) | State saved to RAM, low power, fast resume |
| Hibernate | Hibernate (S4) | State written to disk swap, fully powered off, slower resume |
| Hybrid Sleep | Hybrid Sleep | State saved to both RAM and disk, balancing speed and safety |
Testing Suspend
# Suspend to RAM
sudo systemctl suspend
# Check supported sleep modes
cat /sys/power/stateConfiguring Hibernate
Prerequisites
Hibernate requires swap space no smaller than the physical memory size.
# Check memory and swap
free -h
# Check swap partition/file
swapon --showUsing a Swap File for Hibernate
If using a swap file instead of a swap partition:
# Create a swap file equal to RAM size (example: 16GB)
sudo fallocate -l 16G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
# Write to /etc/fstab for persistence
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstabConfiguring Kernel Parameters
Find the physical offset of the swap file:
sudo filefrag -v /swapfile | head -4Note the physical_offset value from the first row. Then find the UUID of the partition containing the swap file:
findmnt -no UUID -T /swapfileEdit the GRUB configuration:
sudo nano /etc/default/grubModify GRUB_CMDLINE_LINUX_DEFAULT:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=YOUR_UUID resume_offset=OFFSET_VALUE"Update GRUB and initramfs:
sudo update-grub
# Ubuntu 26.04 generates the initramfs with Dracut by default:
sudo dracut -f --regenerate-all
# On legacy initramfs-tools systems use instead: sudo update-initramfs -u -k allTesting Hibernate
sudo systemctl hibernateHybrid Sleep
sudo systemctl hybrid-sleepLid Close and Power Button Behavior
Edit /etc/systemd/logind.conf:
[Login]
HandleLidSwitch=suspend
HandleLidSwitchExternalPower=ignore
HandlePowerKey=poweroff
HandleSuspendKey=suspendAvailable values: ignore, poweroff, reboot, halt, suspend, hibernate, hybrid-sleep, lock
Restart the service after making changes:
sudo systemctl restart systemd-logindCommon Issues
Cannot wake up after suspend
- Check kernel logs:
journalctl -b -1 | grep -i "suspend\|resume\|sleep"- Try adding kernel parameters in GRUB:
acpi_osi=Linux acpi_backlight=vendor- For NVIDIA GPU users, make sure the driver version is recent and power management is enabled:
sudo systemctl enable nvidia-suspend nvidia-resume nvidia-hibernateCannot resume after hibernate
Confirm that the resume parameters are correctly configured, and check whether initramfs includes the resume module:
# Ubuntu 26.04 uses Dracut by default; list initramfs contents with lsinitrd:
sudo lsinitrd /boot/initrd.img-$(uname -r) | grep resume
# On legacy initramfs-tools systems use instead: lsinitramfs /boot/initrd.img-$(uname -r) | grep resumeWi-Fi unavailable after wake
sudo systemctl restart NetworkManager
# Or reload the wireless module
sudo modprobe -r iwlwifi && sudo modprobe iwlwifiBluetooth unavailable after wake
sudo systemctl restart bluetooth
sudo rfkill unblock bluetoothPower Management Optimization
Install TLP for laptop power optimization:
sudo apt install tlp tlp-rdw
sudo systemctl enable tlp
sudo tlp startCheck battery status:
tlp-stat -bLast updated on