System hibernation allows you to power down the computer and resume your work later. Assuming you’re using different physical storage disks for each operating system (OS), you can even boot into a different OS like Windows 10 while your Linux distribution is hibernating. Fedora Workstation doesn’t support system hibernation (suspend-to-disk) by default. Here’s how to enable it.
This tutorial assumes you’ve already created and configured a swap partition large enough to fit your entire system memory capacity plus any normal swap pressure (RAM + normal swap usage + decompressed ZRAM usage.) Avoid using a swap file; use a swap partition. The swap partition must be configured to mount on start-up. This part of the configuration is outside the scope of this article. Set up a swap partition or dedicated swap device first, preferably with LUKS encryption, and return to this article once you’re set up.
Update (): The above assumption is no longer the default. Starting with version 33, Fedora no longer creates a swap partition by default, but relies on ZRAM instead. You still need a storage drive backed swap partition as you still can’t swap volatile memory into itself when the system powers down.
Warning: In this article, you’ll be adding Kernel boot parameters and make changes to the boot environment. It’s unlikely, but it can break your system and put it in a state where it can’t be booted. Be patient and make sure you set aside enough time to troubleshoot and restore if anything goes wrong. As always, ensure you have complete and up-to-date backups.
Enabling hibernation and dumping the system memory to disk is relatively straight-forward. The real trick is getting the system to resume from the swapped session! So let us start from that end and configure session resume first.
You’ll need to include the
resume module in the initial RAM file system (
initramfs); the temporary environment the bootloader runs in. Create a new configuration file at
/etc/dracut.conf.d/resume.conf (you can edit
/etc/dracut.conf directly if your distribution doesn’t have this subdirectory) and include the following option:
The whitespace in the above code snippet is significant. Make sure you set the option exactly as shown. Next, you must execute the
dracut -f command to generate your new
Next, the GRUB bootloader needs to be told that it should look for a suspended session and resume it if it finds one. It also needs to know which disk the system has swapped the session onto. Identify your swap partition’s UUID by executing the command
blkid | grep swap | cut -d: -f1. Double-check your swap configuration if the command doesn’t return anything.
/etc/default/grub and append the following to the end of your
GRUB_CMDLINE_LINUX option. Replace
your-swap-identifier with the UUID for the swap partition you identified above. ([…] is a placeholder for the existing values in your configuration.)
You also need a second parameter if you’ve enabled LUKS-encryption on your swap-partition. You may already have the second parameter in your configuration so make sure you don’t duplicate it. When your device hibernates, everything in the system memory — including passwords and other sensitive data — will be written to disk. It’s recommended to enable LUKS-encryption on swap partitions.
You then need to regenerate your GRUB configuration. The exact path may vary in your Linux distribution and version. Check your distribution’s installation documentation and double-check this path before proceeding. You can also check to see if this file already exists in this path on your system.
Lastly, check that hibernation is enabled on your system. Open the file
/etc/systemd/sleep.conf and make sure it includes the following options. You may need to uncomment or add them if they’re not present in your configuration.
You should be set up at this point. Reboot your system. Afterward, you can cross your fingers and execute
systemctl hibernate. Wait for your system to power down. Power it back up again and it should resume your last session.
You should hibernate and resume your system a few times to make sure it works properly. Check sound, microphones, networking, and other hardware each time. It’s not unheard of that some device drivers don’t work properly when resuming from hibernation.
Double-check your swap partition mounting options in
/etc/fstab if the system just boots normally when you expect it to resume. You’ve probably got incompatible hardware or a broken driver if the system only partially resumes, e.g. a blank screen. If you get stuck in such a mode, you can pause on the GRUB screen and modify the Linux kernel options. Remove the
resume=[…] option and try booting into the system again.
This article was last updated for Fedora 34 with notes left in for older versions. The article should be applicable to other Linux distributions that boot using the same toolset as Fedora.