- Published on
How to Hibernate and Suspend Your Artix Linux
3 min read
Table of Contents
Introduction
There are three methods of suspending:
Hibernate (suspend to disk)
Saves the machine's state into swap space and completely powers off the machine. When the machine is powered on, the state is restored. Until then, there is zero power consumption.
Sleep (suspend to RAM)
Works by cutting off power to most parts of the machine aside from the RAM, which is required to restore the machine's state. Because of the large power savings, it is advisable for laptops to automatically enter this mode when the computer is running on batteries and the lid is closed (or the user is inactive for some time).
Suspend to both
A hybrid of the aforementioned methods. Saves the machine's state into swap space, but does not power off the machine. Instead, it invokes usual suspend to RAM. Therefore, if the battery is not depleted, the system can resume from RAM. If the battery is depleted, the system can be resumed from disk, which is much slower than resuming from RAM, but the machine's state has not been lost.
Hibernation
To be able to use hibernation you should do:
- Uncomment all parameters in Sleep section in file
/etc/elogind/logind.conf
.
# /etc/elogind/logind.conf
[Sleep]
AllowSuspend=yes
AllowHibernation=yes
AllowSuspendThenHibernate=yes
AllowHybridSleep=yes
AllowPowerOffInterrupts=no
BroadcastPowerOffInterrupts=yes
AllowSuspendInterrupts=no
BroadcastSuspendInterrupts=yes
HandleNvidiaSleep=no
SuspendState=mem standby freeze
SuspendMode=deep
HibernateState=disk
HibernateMode=platform shutdown
HybridSleepState=disk
HybridSleepMode=suspend platform shutdown
HibernateDelaySec=10800
- Add
resume
hook afterudev
in file/etc/mkinitcpio.conf
.
# /etc/mkinitcpio.conf
HOOKS=(base udev autodetect modconf block filesystems keyboard resume fsck)
The reason why after udev
because the swap partition is referred to with a udev
device node, so the resume
hook must go after the udev
hook.
Then regenerate the initramfs
for these changes to take effect.
sudo mkinitcpio -p linux
- Add
resume
kernel parameter.
You Need to check what is UUID
of your swap partition.
$ lsblk -fs
NAME FSTYPE LABEL UUID MOUNTPOINTS
. . . SOME OUTPUT . . .
sda3 swap SWAP 5b069c37-9ece-41cf-abf6-74b9d35758ac [SWAP]
└─sda
. . . MORE OUTPUT . . .
So resume=UUID=5b069c37-9ece-41cf-abf6-74b9d35758ac
.
Now lets use it and put it in /etc/default/grub
.
# /etc/default/grub
GRUB_CMDLINE_LINUX="resume=UUID=5b069c37-9ece-41cf-abf6-74b9d35758ac"
The kernel parameters will only take effect after rebooting. To be able to hibernate right away, obtain the volume's major and minor device numbers from lsblk
:
lsblk --include=8
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 465.8G 0 disk
... output ...
├─sda3 8:3 0 10G 0 part [SWAP]
... more output ...
And echo them in format major:minor
to /sys/power/resume
.
echo 8:3 > /sys/power/resume
If using a swap file refere to archwiki
And then regenerate grub.cfg via:
sudo grub-mkconfig -o /boot/grub/grub.cfg
And finally test your setup:
loginctl hibernate
Sleep
loginctl suspend
Hybrid Sleep (suspend to both)
loginctl hybrid-sleep
Suspend then hibernate
Suspend the system and hibernate it after the delay specified in logind.conf.
loginctl suspend-then-hibernate