Detecting Hibernation Phases: Suspend vs. Hibernate on Ubuntu

Abstract: Distinguish between suspend and hibernate on Ubuntu by checking sysfs capabilities and systemd journal logs.

Created: 2026-10-24 by

On Ubuntu systems, you can distinguish between suspend and hibernate by checking the /sys/power/state file for available modes and examining /sys/power/mem_sleep to see which is currently default. Additionally, systemd journal logs provide definitive proof of the last sleep state entered via specific log entries.

Understanding System Power States

Before diving into detection methods, it is crucial to understand what these states actually do at the hardware level. Suspend, often referred to as RAM sleep or S3 state, keeps the system's memory powered while shutting down most other components. This allows for a very fast resume time but requires continuous power; if the battery dies, all unsaved work is lost. Hibernate, on the other hand, writes the contents of the RAM to the swap partition or a dedicated hibernation file on disk before powering off completely. Because no power is needed to retain state, the battery drain is negligible during hibernation, but the resume process is significantly slower due to disk I/O operations. Ubuntu uses systemd as its init system, which manages these power transitions through standardized interfaces. The kernel exposes these capabilities through sysfs, making them easily queryable without needing complex external tools. Understanding this distinction helps in troubleshooting why a laptop might behave unexpectedly when plugged in versus running on battery, or why certain services fail to restart correctly after waking up from sleep.

Checking Available States via Sysfs

The most direct way to verify if your system supports hibernation is to inspect the kernel's power management interface. You can do this by reading the content of the /sys/power/state file. Run the following command in your terminal:
cat /sys/power/state
If the output includes mem, your system supports suspend-to-RAM. If it includes disk, it supports suspend-to-disk (hibernation). On many modern laptops, especially those with UEFI firmware and secure boot enabled, the disk option may be absent because the kernel cannot safely write the memory image to disk without compromising security or encountering driver issues. In such cases, hibernation is effectively disabled at the kernel level, and any attempt to trigger it will fall back to suspend or fail entirely. It is also worth noting that some systems support s2idle (Suspend-to-Idle), which is a lighter form of suspend where the CPU remains mostly active but interrupts are minimized. This is different from the traditional mem state. You can check the current preferred mem-sleep state by looking at /sys/power/mem_sleep:
cat /sys/power/mem_sleep
The output will look something like [s2idle] deep. The value inside the brackets indicates the current default. If you see only [s2idle], your system is configured to use the lighter suspend mode, which might explain why hibernation feels sluggish or unavailable in the GUI.

Using Journalctl to Verify Last Sleep State

While sysfs tells you what *can* happen, the systemd journal tells you what *did* happen. To determine if your machine recently suspended or hibernated, you can search the system logs for specific messages generated by the systemd-logind service. Use the journalctl command with the -b -1 flag to view logs from the previous boot session:
journalctl -b -1 | grep -i "systemd-logind"
Look for lines containing "Going to sleep" or "Resume from". A typical suspend entry looks like:
Jan 01 12:00:00 hostname systemd-logind[1234]: Suspending...
A hibernation entry will explicitly mention "Hibernate" or "Disk":
Jan 01 12:00:00 hostname systemd-logind[1234]: Hibernate...
This method is particularly useful for debugging scripts that need to run different actions depending on whether the system woke up from a short nap or a long rest. For instance, network managers might need to re-authenticate after hibernation but not after suspend.

Configuring Suspend-Then-Hibernate

Many users prefer a hybrid approach known as "suspend-then-hibernate." In this mode, the system enters suspend immediately to allow for quick wake-ups, but if the battery reaches a critical threshold while suspended, it automatically hibernates to preserve data. This feature is managed by systemd timers and targets. To enable this behavior, you typically need to create or edit a configuration file in /etc/systemd/sleep.conf. Add the following line under the [Sleep] section:
SuspendMode=suspend-then-hibernate
You may also want to set SuspendDelaySec=15m to specify how long the system should stay in suspend before transitioning to hibernate. After saving the file, reload the systemd daemon:
sudo systemctl daemon-reload
This configuration ensures that your data is safe even if the battery dies during a long period of inactivity, combining the speed of suspend with the safety of hibernate. This is particularly relevant for mobile users who rely on Ubuntu for daily tasks and cannot afford to lose work due to unexpected power loss. For more information on securing your Ubuntu environment against various threats, including power-related vulnerabilities, you might find Securing an Ubuntu Server for Development Purposes helpful.

Troubleshooting Common Issues

If you detect that hibernation is not working despite disk being present in /sys/power/state, check your swap space. Hibernation requires swap space equal to or larger than your used RAM. If your swap is too small, the kernel will refuse to hibernate. You can check swap size with swapon --show. Additionally, ensure that your GRUB configuration allows for proper resume. Sometimes, the resume parameter needs to be added to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub if the system fails to wake up correctly. After modifying GRUB, always run sudo update-grub to apply changes. For those managing virtual machines, detecting sleep states can be tricky since the guest OS does not control the physical hardware directly. If you are running Ubuntu in a VM, refer to Ubuntu 22.04 VM on KVM/virt-manager Not Connecting to Internet for related infrastructure insights, though note that VMs generally do not support true hibernation in the same way bare-metal systems do.

Frequently Asked Questions

Can I hibernate if my swap is smaller than my RAM?

No, hibernation requires enough swap space to store the entire contents of RAM. If your swap is insufficient, the kernel will block the hibernation process to prevent data corruption. You must increase your swap size or disable hibernation.

Why does my laptop only show s2idle in mem_sleep?

This usually indicates that the kernel has determined the deeper deep sleep state is incompatible with your hardware, often due to driver issues or BIOS limitations. You may need to update your kernel or adjust BIOS settings to enable deeper sleep states.

Does enabling suspend-then-hibernate affect performance?

There is no noticeable performance impact on daily usage. The transition from suspend to hibernate happens in the background only when the battery is low, so normal operation remains unaffected.

How do I force a hibernate command manually?

You can use the command sudo systemctl hibernate. However, if the system falls back to suspend, it means hibernation is not properly configured or supported on your hardware.

Is hibernation supported on Ubuntu 22.04 out of the box?

It depends on the hardware. While the software stack supports it, many manufacturers disable it in firmware or require specific kernel parameters. Check /sys/power/state to confirm availability on your specific device.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More