Difference between suspend and hibernate in Ubuntu and how to execute them from command line
Suspend, hibernate and shutdown Linux from command line
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 / Sleep | Hibernate |
---|---|---|
Saves state into | RAM | HDD |
Requirements | Continuous power supply. | Swap space. |
Power consumption | Low | None |
Resume time | Fast. Recovers data from RAM | Slow. Has to deal with disk's lower response time. |
Risk of data loss | In a power outage | No 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
- service:
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
- service:
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
- service:
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
- exec
- /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
- https://www.freedesktop.org/wiki/Software/systemd/
- https://en.wikipedia.org/wiki/Hibernation_(computing)
- https://en.wikipedia.org/wiki/Sleep_mode
- How to activate tap to click touchpad's feature in Ubuntu in 4 stepsMarch 4, 2021
- Difference between suspend and hibernate in Ubuntu and how to execute them from command line
- Solving Google Chrome's gpu-process error message in Ubuntu LinuxJanuary 7, 2019
- Solving Google Chrome's secret service operation error message in Ubuntu LinuxJanuary 7, 2019
- Start Emacs In Ubuntu The Right WayJune 10, 2017
Articles
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
·