Never resumes from hibernation, boots as if shut down

I have Manjaro Linux with KDE.

When I hibernate via the Plasma GUI, and then resume, instead of resuming the system just boots as if it had been shut down. Nothing from the previous session is remembered.

I’ve had this problem with EVERY SINGLE linux distro I’ve tried in the last 20 years (on several computers). Ubuntu, OpenSUSE among others. On Ubuntu at some point they hid the Hibernate option, I guess they knew it wasn’t working.

Is there a way to get it to work at all?

Operating System: Manjaro Linux
KDE Plasma Version: 6.0.5
KDE Frameworks Version: 6.5.0
Qt Version: 6.7.2
Kernel Version: 6.6.47-1-MANJARO (64-bit)
Graphics Platform: Wayland
Processors: 12 × 12th Gen Intel® Core™ i7-1255U
Memory: 15.3 GiB of RAM
Graphics Processor: Mesa Intel® Graphics
Manufacturer: ASUSTeK COMPUTER INC.
Product Name: Vivobook_ASUSLaptop X1502ZA_F1502ZA
System Version: 1.0

$ swapon --show                                                                                                                                        
NAME      TYPE SIZE USED PRIO
/swapfile file  20G   0B   -2
2 Likes

You should probably configure a dedicated swap partition, which will provide the contiguous space required for hibernation; a swap file seldom works as one might expect.

If you habitually create a swap file instead of a partition, this might be contributing to your issue; though other reasons are possible.

Cheers.


Some related links, if useful:

2 Likes

Check /etc/default/grub

the line starting with:
GRUB_CMDLINE_LINUX_DEFAULT=

grep GRUB_CMDLINE_LINUX_DEFAULT= /etc/default/grub

There, the swap file needs to be referenced
as well as it’s starting point on the file system via the
resume_offset=
parameter.

This is what it looks like for my system:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mitigations=off nowatchdog audit=0 resume=UUID=e3d59116-1204-4700-b8c4-4f496790d85c resume_offset=4171776"

(the last two parameters in the example above)


I don’t think that the Manjaro installer (or any installer, for that matter) does this automatically
and as a result, you cannot hibernate or, more precisely, expect to properly come out of hibernation.

Simply having a swap file is just not enough.
The system / grub needs to “know” where on the disk the swap file is to be able to find it and resume from it …

Here is how to do it:

Power management/Suspend and hibernate - ArchWiki



It is working - if it is properly set up.
Arch, Ubuntu, Mint, whatever - they all work the same way
and I guess none of them have an installer that does this set up for you
in the case of a swap file.

It’s a little easier for a swap partition - the resume_offset is not needed then.

1 Like

I agree that a swap partition is the best way to go. Keeps things simple and you won’t be unexpectedly filling up e.g. your / where I guess a swap file normally resides. I guess it also avoids extra system “defragmentation” overhead, which may be relevant on spinning disks.

With a swap partition, you just need to edit fstab accordingly, and have an entry in etc/default/grub like this:

cat /etc/default/grub | grep -i resume
GRUB_CMDLINE_LINUX_DEFAULT="resume=UUID=1f0xxxxb-4xxx-491e-xxxx-b17xxxxdc706"
1 Like

Think it is also mentioned in the Calamares choices (swap to file, or swap partition (hibernation support), or no swap).

Calamares is the installer program most distros use, Ubuntu uses its own I think.

Maybe a full sentence about this would make it clearer for most people, instead of the info inside brackets.

KDE should also remove the hibernation button if no swap or swap file is selected, resp. if the latter needs manual reconfig.

2 Likes

When I installed Manjaro, I don’t remember what choices the installer offered me, but I am 100% sure I did not choose “no swap”. The only way that could have happened is if that was the default (which would be a stupid default as a system with no swap is basically unusable for normal use) and the choice was hidden enough that I missed it.
Either it didn’t offer me a choice, or it did and then didn’t honor it, because it didn’t create any swap partition or file.

I just assumed swap was set up and working (because that’s something that is needed and that nobody in any OS other than Linux has ever had to worry about), and only several months later, when I got tired of the system constantly freezing and crashing, I investigated and figured out I had no swap at all, so I created a swap file, because at that point it would have been too much of a pain in the *** to re-partition the disk.

At that time I read this guide:

It doesn’t say there’s any reason to prefer a swap partition over a swap file.
It says “In current Linux kernels, it is possible to use a swap file instead of a dedicated partition and as from kernel 2.6 onwards there is no performance difference any more between the two.”

It also doesn’t mention that you need any extra configuration steps to make hibernation work (although I understand it’s a swap guide, not a hibernation guide, but it does mention hibernation).

Why would a swap file fill up your /? Isn’t it just a single file with a fixed maximum size?

How do I determine the correct values for resume and resume_offset?

The resume parameter needs the UUID of the filesystem the swapfile resides on, you can find this using lsblk -f, as for the offset:

3 Likes

default is Swap File

what @dmt said and:
the green text in my post is a link

1 Like

sudo cat /boot/grub/grub.cfg | grep resume

This will show your set values.

Calamares, IIRC. At least I think that’s what Mint uses.

I’m not sure the file size is limited by default, which is why I mentioned it.

I am also uncomfortable with the idea of temporary data being put in the same partition as the system root. Even back when I was using Windows, I’d created separate partitions for stuff like that (System, DATA, Cache, etc.); helped kept those systems running for years. I only found out when I first switched to Linux, that I was doing it sort-of “The Linux Way” without even realizing it at the time.

I don’t have a swap file as I always define a separate partition for that.

I think the suggestion was more that a swap file does intrude on the amount of space available for / (root).

Calamares choices vary according to which partitioning method is used during installation:

  • Erase Disk – These swap choices are offered when using this method (example assumes 16GB system RAM). It defaults to No Swap as you are expected to make a conscious choice here.
Preference Size Description
No Swap 0 If no Swap is defined, and later you need it, a Swap partition or file must be manually configured. It is recommended to configure Swap now; during installation.
Swap (No Hibernate) 8.80 GiB Default swap partition size is approximately half the amount of your system RAM if ‘No Hibernate’ is selected.
Swap (With Hibernate) 17.18 GiB Default swap partition size is approximately equal to the amount of your system RAM if ‘With Hibernate’ is selected.
Swap to file dynamic Swap file will be created under / (root) by default.
  • Replace a Partition – A limitation of this particular method is that no swap preference is offered; you are expected to create swap post-install. Many (newer) users might opt to create a swap file as it seems the easiest (though creating a swap partition isn’t difficult).

  • Manual Partitioning – This is the most versatile partitioning method, but it requires the user to manually create a swap partition (if desired) during installation, along with all other partitions required for the system.

  • Install Alongside – This I can’t comment on in terms of swap space, as I have never used this method.

So, if you chose Erase Disk then you didn’t configure swap at all during installation. If you chose Replace a Partition you were oblivious to the need to configure swap post-install. And if you knew enough to choose Manual Partitioning we wouldn’t be having this conversation.

And that might be a common assumption by those who have only ever used Windows.

Welcome to Manjaro, and your continuing Linux journey.

Cheers.


I think I understood that. :wink:

Using the Erase Disk partitioning method, the swap options also change the swap file/partition size accordingly; the other methods are a little more murky.

2 Likes

This has been my observation, I have had multiple Distros fail to install or require a reboot before being able to start the install because of the power/screen settings. I think it would be a great improvement if the screen locking and power options were adjusted (disabled) for the Live environment to avoid these issues.

The majority of my experience in Linux has been that it is allergic to sleep/hibernating. I think that has improved recently. I now have a swap partition as large as my RAM.

1 Like

Welcome to the Forum!

I agree 100% with this, and think I’ve mentioned it on here already:

And for this:

I’m probably one of the rare “cases” who did set up separate “swap” (cache) partitions for Windows systems, which then ran for years without the usual issues with fragmentation, etc. — plus a separate “cache” partition for the likes of Nero to use.

Also, I wish there were more than just the “like” for quality posts like yours.

  • Replace a Partition – A limitation of this particular method is that no swap preference is offered; you are expected to create swap post-install.

It must be that I chose this option. If I had chosen erase disk, there’s no way I would have chosen no swap (BTW if that’s the default, it’s a wrong default. The default should be something with swap. That “you are expected to make a conscious choice” is not a valid reason for having a bad default).

Does it warn you that you’ll need to create swap post install?
Either way, there’s no reason why it shouldn’t also offer you the option to create a swap file just like in the Erase Disk case.

Also, in Erase Disk, if you choose “swap to file”, I assume it also configures hibernation accordingly? Otherwise that’s broken too.

The bottom line is, the installer should ensure that you end up with a system that has swap and hibernation working unless you very explicitly express a desire to not have one or either of them set up.

Not necessarily. Did you install to a new (empty) disk or were there already existing partitions?

OK, let’s try this another way. There are options that depend on whether or not you wish to use hibernation. These choices change the size requirement of the swap partition needed… Calamares doesn’t have a crystal ball; it cannot know the amount or type of swap that you want or need. With me so far?

Think about it. The most logical initial state is No Swap, as you have to make that choice, anyway. It really doesn’t take much to notice the dropdown with No Swap selected, and think “Gee, I wonder what choices there are if I click the dropdown”. That’s the Erase Disk method…

Now, when choosing Replace a Partition, I agree that some kind of notification might be beneficial. Personally, I prefer to have full control over a fresh installation. Manual Partitioning is my obvious choice; there is no default configuration, hand-holding, or automation of any kind with this method.

Well, there obviously are reason(s) otherwise there would likely be provision for it much as you suggest.

Choosing “Swap to file” does not automagically configure hibernation.

Isn’t that strange? Choosing “Swap to file” doesn’t, and choosing “Swap (With Hibernation)” does. A swap file isn’t compatible with hibernation.

It’s not broken at all.

That said, you can have both a swap file and partition work together to allow hibernation. This takes manual configuration and requires additional software. I previously posted some links that might be useful if you’re genuinely interested.

Linux doesn’t do that; and nor should it.

Windows does… but, Windows is not Linux… and this is something you must deal with if you wish to use Linux.

The Windows mindset that the OS should do everything the way you want it ‘out of the box’ is an invalid way of thinking with Linux.

There is no box; think outside of it. That’s the bottom line.

Cheers.

1 Like