Enabling Hibernation on Linux Mint 22
Tagged with hibernation, linux, workspaces, zram on September 15, 2024
When I previously wrote about enabling hibernation on Linux Mint Cinnamon, it was the first time I ever attempted to enable hibernation on any Linux distribution. The changes I wrote about didn’t make things easier for me. When I bought my mini PC, I didn’t even consider another attempt.
While browsing Linux forums mentioning Linux Mint 22 (which I installed from scratch), I spotted a post where someone was trying to enable hibernation on this version and asked for help. One of the answers included a BASH script to automate the entire process. The script is on this page, and all you have to do to find it is to search for “setup-hibernate.sh”.
After thinking about it for a while, I decided to test that script on an external USB drive, with another Linux Mint 22 installation on it.
Preparing for and Enabling Hibernation
Since that external USB drive is basically a duplicate setup, I would have to complete all the same steps if I ever decide to enable hibernation on the mini PC internal drive itself.
The zram swapping mechanism is enabled and there isn’t a swap file. If I had a swap file, and it was referenced in “/etc/fstab”, I would have to delete it before using the script to enable hibernation. It creates any swap file size needed and collects information required to restore from hibernation.
I disabled zram and then ran the script. I chose to make the swap file the same size as my 16 gigabytes of RAM. When the script finished, I checked the swap file in the root directory, and then I checked “/etc/fstab” to make sure the line for it was added.
Then I opened the “/etc/default/grub” file with sudo and I inserted “zswap.enabled=1 zswap.zpool=z3fold zswap.compressor=lz4” to the line that started with “GRUB_CMDLINE_LINUX_DEFAULT”, right after the word “splash” (separated by a space, of course). I ran “sudo update grub” and rebooted.
After rebooting, I ran “dmesg | grep zswap” to make sure it was enabled. I found “z3fold” was not included as a module when booting, so I had to run “sudo echo z3fold >> /etc/initramfs-tools/modules” and then “sudo update-initramfs -u”. I rebooted again, checked again, and everything was fine.
Results
I opened several applications, including a Windows 11 virtual machine. After I clicked on hibernate option in the power menu, the screen blinked once or twice (I don’t remember), but the computer did not hibernate and shut down.
Then I remembered the Windows 11 virtual machine size was set to eight gigabytes, so I ran “free -h”. There wasn’t enough swap space to handle it. So… I reduced the virtual machine to four gigabytes and tried again. This time it worked.
Alternatives to Hibernation
I have no need for hibernation. The suspend option works fine for me. I usually just click on that, wait for the power light to go out, and turn off the monitor. Sometimes I forget to suspend and simply turn off the monitor. The only time I shut down completely is when there’s a power outage, or when I just feel like it.
I don’t use workspaces. Having applications hidden from me just confuses me. Besides, I run all of my applications maximized, so I only see one at a time. I have the applications I use most in the grouped windows list in the panel, and I can also alt-tab to them. Anything more is overkill.
Setting up hibernation like this was simply a test. I sometimes do things like this just because I’m bored, with absolutely nothing else to interest me.
Image by Cinnamon developer, LGPL, via Wikimedia Commons
← Previous ArticleNext Article →