Hibernation in Linux is for many years already no longer a priority for distro maintainers, kernel maintainers, video driver maintainers, and so on. Currently, the only distro that explicitly supports hibernation by actively helping the user to enable it is MX Linux (via MX Tweak, part of their MX Tools). Of course, I’ve always used hibernation with all the distros I’ve used, but in each case it required some tinkering; in most cases it tends not to work nowadays, whereas prior to 2006-2008, if my memory serves well, it was a piece of cake in most distros of the time. I understand that there are several levels of mass stupidity, including ZRAM, that made people unwilling to suspend-to-disk, but I won’t go with the flow of retards. (See also my last year’s post, Hibernation, ZRAM and mental retardation in Linux.)

Manjaro XFCE (to start with)

I have yet to test hibernation on my old laptop (which however used to support it), so what I describe below as “working” is on an HP ProDesk 400 G6 Desktop Mini PC, in the 44G38ES configuration (Intel i5-10400T, 8GB RAM, 256GB NVMe SSD, Intel UHD Graphics 630, sold with FreeDOS) which I first reported about last November.

I’m afraid I’m going to add very little over what Vegard Skjefstad wrote on January 9, 2021, in his blog post that I used as a reference (the reference!): How To Enable Hibernation in Manjaro. I merely added a few specifics.

Prerequisites, so that things work:

  • I never use disk encryption. Personal Computer means it’s of no interest for NSA, CIA, FSB, MOSSAD, MI6. Also, I don’t sell drugs, I don’t have pictures of my dick, and I’m not interested in children doing inappropriate things.
  • I don’t use anymore any dual-booting with Windows.
  • I don’t care about Nvidia, because they don’t produce graphics cards anymore, but gaming and crypto-mining cards, and buggy at that. To me, the GPU that comes with the CPU is just fine. I’m still with Intel simply because AMD is too expensive; however, I’m also told that their GPUs are sometimes problematic with hibernation. I don’t want to know about nvidia, nouveau, radeon, amdgpu; nor do I care about Vulkan. Also, screw Wayland.
  • It’s better to have the swap partition (not swap file) configured during the installation of Linux. For Manjaro, you should be able to select “Swap (with Hibernate)” in the partitioning screen. I made it 8 GB for my 8 GB of RAM, because the usable RAM is actually less than that.
  • Finally, this works with GRUB. I tried to adapt it to systemd-boot, but, despite having performed the required steps (with guidance from elsewhere), upon resuming the screen is dark and the keyboard doesn’t work, so I went back to GRUB, as infamous as it might be.
  • My experience is with XFCE, which I prefer because it doesn’t change disruptively like KDE, and also because GNOME is ergonomically unusable in many ways. Bear in mind that this is Manjaro’s customization of XFCE, not the upstream defaults.

What I did while following the steps described in the aforementioned blog post

■ Check the swap partition:

[ludditus@ProDesk ~]$ swapon
NAME TYPE SIZE USED PRIO
/dev/nvme0n1p3 partition 8.8G 0B -2

■ Find its UUID:

[ludditus@ProDesk ~]$ sudo blkid
/dev/nvme0n1p3: LABEL="swap" UUID="3e48466f-5419-4cd5-b30f-811dacc91b1d" TYPE="swap" PARTUUID="0d7738c5-e532-4e4d-87a0-4a596e49f0df"

■ Copy this string to clipboard (notice that the quotes need to be removed):

UUID=3e48466f-5419-4cd5-b30f-811dacc91b1d

■ Open for edit (sudo <preferred_editor>) /etc/default/grub, look for the line with GRUB_CMDLINE_LINUX_DEFAULT, and add or insert a resume option with the above UUID string, like so:

GRUB_CMDLINE_LINUX_DEFAULT="apparmor=1 security=apparmor resume=UUID=3e48466f-5419-4cd5-b30f-811dacc91b1d udev.log_priority=3"

■ Make GRUB happy:

sudo grub-mkconfig -o /boot/grub/grub.cfg

Ignore such a thing, if it shows up:

/usr/bin/grub-probe: warning: unknown device type nvme0n1.

■ Open for edit (sudo <preferred_editor>) /etc/mkinitcpio.conf, look for the line starting with HOOKS and make sure you add resume somewhere after udev:

HOOKS="base udev autodetect modconf block keyboard keymap consolefont resume filesystems fsck"

Note that, if you’re using systemd-boot instead of GRUB, you should add systemd instead of resume, but this won’t be enough for resume to work properly.

■ The last step:

sudo mkinitcpio -P

■ After a reboot, hibernation should in theory work with sudo systemctl hibernate or using the specific buttons in your desktop environment (which, depending on the distro, might require further configuration).

Manjaro XFCE specifics

Normally, one should also edit /etc/systemd/sleep.conf to enable or disable suspend, hibernate, hybrid-sleep, suspend-then-hibernate (see Suspend and hibernate on Arch’s Wiki). In Manjaro, all the [Sleep] options are commented out, and in the case of Manjaro’s XFCE, this means everything active by default:

To only allow the hibernation, one possible set of options is this:

[Sleep]
AllowSuspendThenHibernate=no
AllowSuspend=no
AllowHibernation=yes
HibernateState=disk

Don’t panic on this one!

Even if it works on your system (which, by the way, is not guaranteed, so consider yourself lucky if it does!), you might notice that sometimes… it feels like it refuses to go to sleep! That is, it starts to hibernate, but then… it doesn’t!

[ludditus@ProDesk ~]$ journalctl|grep systemd-sleep|grep Failed
Sep 05 13:53:54 ProDesk systemd-sleep[1746]: Failed to put system to sleep. System resumed again: Device or resource busy

My take is that, either the stopping of some device gives a timeout and fails, or, more probably, the swap partition was actually in use as a swap (that’s its original purpose, right?). In all cases, the second attempt to hibernate should work, meaning that the suspend-to-disk mechanism is smart enough to clear enough memory so that the swap isn’t needed as a RAM extension. Still, this takes some time, and a timeout is possible.

Ludditus specifics

On what I call my personal computers, I configure the OS to automatically log in without the need to ask me for a password. I also don’t like to have the screen locked after a timeout.

By default, resuming from hibernation asked me to enter my password, so I made sure the following XFCE settings are configured so that no prompt bothers me upon resuming (yay, almost like in Windows 3.1!):