Hibernation = Reboot

Which Linux distro are you using? Arch

Which release version?
Today

Which kernel are you using? 7.0.14

Which BIOS version are you using? 3.05

Which Framework Laptop 16 model are you using? (AMD Ryzen™ 7040 Series)

My laptop utilizes systemctl suspend-then-hibernate mode when the system is idle for too long. When it eventually hibernates and turns back on, it should bring back everything that I was working on at the moment. However, when I turn it back on, it’s just an empty desktop. I have to once again open the apps and catch up on the lost work. Is this because my swap is only 4GB?

I don’t use Arch btw.

I don’t know the specifics for your distro, but I remembered reading something for the one I used, that it needs a separate swap for hibernate, I choose not to use it, because of the storage it needed.

Did a quick search:

To enable hibernation on Linux, you need a dedicated swap partition (or swap file) at least the size of your RAM.

Seems a common thing.

I made the swap file with 200GB, did the swapon command for it, and edited the fstab configuration file by adding ‘/swapfile none swap defaults 0 0’ below the 4GB swap partition entry. It still doesn’t restore my workspace after hibernation.

Did you follow through what is on the wiki?

You can actually get away with quite a bit less than ram size but it makes it less reliable (it only needs enough space to keep the currently used memory in compressed form). When you don’t have enough swap space it would not reboot but just fail to go down.

The symptoms here look like it goes down for hibernate fine but the bootloader does not figure out it should resume from hibernation and just does a normal boot.

Do you have anything in dmesg after your hibernation reboot concerning failed resume?

While systemd-boot can apparently figure out where stuff is pretty well these days it may still be worth adding the resume uuid and offset to your boot parameters manually to see if that helps.

Kind of. When echoing specific words into specific files, it was always denied, even after I did it after using the command ‘sudo chmod 700 [insert file here]’. Still didn’t work, so I used nvim to manually edit the files like resume or resume_offset and forcefully save changes (:wq!). Still didn’t work, according to the error message I got. However, it did, just not entirely.

When I let the laptop sit there, it’ll naturally go into idle mode (requiring me to input my password). Then it’ll hibernate after more time. I’ll turn it on, input my password at the login screen, and then I get my workspace back intact. However, when I close my laptop and open it back up, it shows nothing but a black screen, despite the power button still shining bright. Any more ideas?

Are you running btrfs? Cause then you need to use different steps, it actually wen’t from not possible to having the most convenient tooling for this stuff.

Can you try just hibernating deliberately so we can check if that part is working or how exactly it isn’t, doing the whole suspend then hibernate or suspend and hibernate adds more variables to the issue.

Indeed I am running btrfs. Where can I find the different steps?

I let it hibernate naturally, but when I turned it back on, my workspace was bare. I guess I’m back to square one.

btrfs themselves has actually documented this decently well.

You can create the swapfile using btrfs filesystem mkswapfile --size 2G swapfile which will set it up correctly for btrfs with all the disabling cow and excluding from snapshots and stuff that needs to be done, also since it is done by the fs it is very fast. Not sure how you made your existing swapfile but may be worth redoing if you are not sure.

with btrfs inspect-internal map-swapfile -r swapfile you can then get the correct offset for the swapfile to put into your boot parameters. The uuid is the one for the btrfs volume.

can you post your /proc/cmdline so we can see how that looks?

For the sake of eliminating variables it is better to just deliberately trigger hibernate instead at least for testing, once deliberate hibernate works you can move on to testing the more complicated hybrid stuff. Just a simple sudo systemctl hibernate

I tried to implement this command: btrfs filesystem mkswapfile --size 200G swapfile

However, I got this error message instead: fish: Unknown command: btrfs

I swear I did use btrfs when mounting my root partition, but I guess I need to do more?

You may need to install the btrfs userpace utilities. You not having this is a strong indicator that your current swapfile probably was not made correctly.

Maybe also confirm your root partition actually is btrfs while you are at it.