Can’t Suspend? Try Hibernation.

Sean Davis
4 min readSep 19, 2021

A disabled feature may give your laptop a longer life.

Linux penguin “Tux” wearing a sleeping cap, next to the text “Hibernation on Linux”

A few weeks ago, my laptop forgot how to suspend. I closed the lid, waited for the light to power off as expected, and it should have safely been asleep. Later I opened the lid, and… what? The laptop posted, I saw the GRUB bootloader, and everything continued from the beginning. I switched through a few distros and saw the same behavior. “Must be the age of the laptop; the kernel has moved on,” I figured. Then I installed Windows because if anything worked, Windows absolutely would. Except it didn’t. Great.

I did some research and found that this issue isn’t uncommon for my laptop, the venerable ASUS Q550LF, a gaming laptop from 2013. For many folks, it happened much earlier in the laptop’s life. Mine waited until old age. While there are plenty of reports, the solutions are varied and inconsistent. So, resigning myself to a reduced-functionality laptop, I checked on current laptop prices. Unfortunately, those aren’t an option either (curse you chip shortage!).

A few weeks later, I decided to give my laptop another chance. I remembered that hibernation was a thing and that it was fundamentally storing your memory to disk and shutting the device down. I also remembered that hibernation support was really bad in Linux, but that was years ago, and surely we’ve solved those problems by now. I was wrong. Somehow, hibernating your Linux laptop is even more complicated than it was ten years ago.

Hibernation on Linux: A Primer

Hibernation works by writing the contents of your RAM (volatile memory) to your hard disk (non-volatile memory) before powering your computer off. The next time that you boot, the memory stored on disk is restored to RAM. On Linux, hibernation writes your memory to swap. When resuming, the bootloader has to be able to access and read the swap space. If your swap is encrypted, it has to be decrypted, adding more complexity.

Problem 1. Swap Files

Since around 2016/17, major Linux distributions have been using swap files instead of swap partitions by default. Since the bootloader has to access swap to resume, the swap file makes things difficult. While it’s possible to hibernate to a swap file, it isn’t straightforward. If you want to enable hibernation, I strongly recommend using a separate partition.

Problem 2. Swap Size

Since hibernation writes the entirety of RAM to disk, your swap partition or file has to be as large as the amount of RAM you have. 32GB? You need 32GB of swap to hold it all. Laptops are still shipping with little disk space, so all disk usage is at a premium.

Problem 3. Encryption

If you’re using an encrypted swap (and you really should), hibernation gets even trickier. Unfortunately, you’ll also be in unsupported territory, and the Ubuntu guide makes it clear that Canonical does not support this method. Essentially, you’ll be setting a new password that will be required every time you boot or resume from hibernation.

Problem 4. Documentation

Search online for instructions on setting up hibernation, and you’ll get a lot of very different answers. And with each of those answers, you’ll find both positive and negative feedback. What gives? Even in Fedora 34, which seems like it may support hibernation out of the box, there are conflicting instructions on setting it up.

Making It Work

Since I’ve got an older laptop and mainly use it to write at home, I’ve opted not to encrypt my partitions. I first tried with elementary 6 Odin, but attempts to hibernate with various guides would only lock my session. However, I wanted instant gratification, so my next attempt was with Fedora 34. With 16GB of RAM and two disks, I opted for a btrfs root filesystem, ext4 home, and 32GB of swap (I wanted to make sure it works).

Following this guide on ctrl.blog, I started setting everything up. Surprisingly, /etc/default/grub was already configured with the correct resume parameters. Confused but confident, I continued the guide and updated /etc/systemd/sleep.conf accordingly. After a reboot, I tested hibernation with systemctl hibernate and it worked like a charm! My laptop can’t suspend, but it hibernates!

To apply some finishing touches and give me a better sense of control, I loaded up the GNOME power settings and ensured the device would never suspend. Since then, I’ve hibernated a few times and successfully resumed every time.

Suspend? Never again.

Wrapping Up

I can’t guarantee that setting up hibernation will be this easy for you. However, I was pleasantly surprised that it worked as easily as it did. So if you’ve got a device that cannot suspend, whether it’s because suspension doesn’t work, or perhaps your battery has given up on life, give hibernation a try. It might just spare you an expensive laptop purchase.

Do you enable hibernation on your Linux or BSD computer? What loops do you have to jump through to make it work? Any guides I should link to below? Let me know in the comments?

Useful Links

Main Image Credits

--

--

Sean Davis

Xubuntu, Xfce, and elementary contributor. Free software advocate. My opinions are my own. Writing about FOSS, gaming, tech, and more. https://bluesabre.org