Difference between suspend and hibernate in Ubuntu and how to execute them from command line

Computer Dreaming
Image: Computer Dreaming (License: CC-BY-NC-SA)

Suspend, hibernate and shutdown Linux from command line

Published:
Last modified:

Overview

Exploring the differences between suspending, hibernating and shutting down a computer with Ubuntu.

In Ubuntu, power management commands are handled with systemd services.

systemd is a suite of basic building blocks for a Linux system. It provides a system and service manager that runs as PID 1 and starts the rest of the system.”1 and services are simply unit configuration files whose name ends in .service. systemd environment.

Options

The system’s power management can be done in several ways:

  • Power Off
    • “Print a wall message to all users, shut down and power-off the system.” 2
  • Reboot
    • “Print a wall message to all users, shut down and reboot the system.”3
  • Suspend
  • Hibernate
  • HybridSleep hibernated+suspended

The basic idea of putting a computer to sleep is to change its state into a “pausing mode”, so when we resume its operation, we have the same applications running and files opened as we had before sleep.

Main strategies involves using volatile storage like RAM or non-volatile memory HDD

TL;DR

Suspend saves its state to the RAM , hibernation saves it to disk.

Suspension is quicker but doesn’t work when running out of energy, while hibernating can deal with running out of power but it is slower.

Differences chart

#Suspend / SleepHibernate
Saves state intoRAMHDD
RequirementsContinuous power supply.Swap space.
Power consumptionLowNone
Resume timeFast. Recovers data from RAMSlow. Has to deal with disk's lower response time.
Risk of data lossIn a power outageNo risk. Data is saved in non-volatile storage

Suspend

Suspend means basically to **Suspend to RAM ** to consume less energy.

when placed in sleep mode, the computer cuts power to unneeded subsystems and places the RAM into a minimum power state, just sufficient to retain its data. Because of the large power saving, most laptops automatically enter this mode when the computer is running on batteries and the lid is closed

From command line it can be called with: systemctl suspend

  • systemd files
    • service: /lib/systemd/system/systemd-suspend.service
    • execs /lib/systemd/systemd-sleep suspend

Hibernate

Hibernate, or Suspend to Disk, “is powering down a computer while retaining its state”.4

saves all computer operational data on the fixed disk before turning the computer off completely. On switching the computer back on, the computer is restored to its state prior to hibernation, with all programs and files open, and unsaved data intact. In contrast with standby mode, hibernation mode saves the computer's state on the hard disk, which requires no power to maintain, whereas standby mode saves the computer's state in RAM , which requires a small amount of power to maintain

From command line it can be executed with: systemctl hibernate

  • systemd files
    • service: /lib/systemd/system/systemd-hibernate.service
    • execs /lib/systemd/systemd-sleep hibernate

Hybrid

hybrid-sleep Hibernate and suspend the system

A third approach is to suspend to copy the contents to RAM , and then hibernate which would also copy the contents of the RAM to the disk, so the power on is faster than powering on a computer and restoring the state manually.

From command line it can be executed with: systemctl hybrid-sleep

  • Sleep
    • service: systemd-hibernate.service/systemd-hybrid-sleep.service
    • execs /lib/systemd/systemd-sleep hybrid-sleep

Suspend & hibernate

“Suspend the system, wake after a period of time and put it into hibernate”5

From command line it can be executed with: systemctl suspend-then-hibernate

  • Suspend & Hibernate
    • exec /lib/systemd/systemd-sleep suspend-then-hibernate
    • service: /lib/systemd/system/systemd-suspend-then-hibernate.service
  • /usr/lib/systemd/system-sleep

Summary

  • To suspend from command line: systemctl suspend.
  • To hibernate: systemctl hibernate.
  • An hybrid approach: systemctl hybrid-sleep
  • Suspend and hibernate: systemctl suspend-then-hibernate

References

Uruguay
Marcelo Canina
I'm Marcelo Canina, a developer from Uruguay. I build websites and web-based applications from the ground up and share what I learn here.
comments powered by Disqus


Differences between power management commands in Ubuntu Linux.

Clutter-free software concepts.
Translations English Español

Except as otherwise noted, the content of this page is licensed under CC BY-NC-ND 4.0 . Terms and Policy.

Powered by SimpleIT Hugo Theme

·