3

This question already has an answer here:

So I'm trying to hibernate my Ubuntu laptop, using sudo systemctl hibernate, in turn it says "Failed to hibernate system via logind: Not enough swap space for hibernation".

I already tried this before, so before using hibernate, I set up different swapfiles to accomodate the RAM my laptop has (8G), overall my total swap space (from free -h) is total used free shared buff/cache Mem: 7.7Gi 2.7Gi 4.4Gi 135Mi 741Mi
Swap: 16Gi 1.4Gi 14Gi

So is there any difference between swapfiles and swap partitions? Is there any more settings I can do to properly hibernate?

As a side note, I tried installing pm-utils and use pm-hibernate, the system hangs for a moment, the screen turns off, but then it would turn back on and resume as normal, (probably because also of the lacking swap space).

Is there a step I forgot or whatever?

EDIT: Related screenshot, enter image description here

marked as duplicate by Fabby, karel, Elder Geek, Eric Carvalho, Eliah Kagan Jun 21 at 0:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • that's a weird message for this bug. normally 19.04 doesn't need swap. do you have a swap partition at all? – tatsu Jun 17 at 12:53
  • i read up on it a bit an saw the table at the bottom of this article : itsfoss.com/swap-size so swap is good but not necessary and I guess for hibernation it's best to have the same size swap as your ram plus a GB or two. but I hibernate my computer every other 15 minutes and I have no swap so this bug is weird to me. – tatsu Jun 17 at 13:01
  • Welcome to AskUbuntu! The swap size in your related screenshot is clearly insufficient for hibernnation as it's smaller than your RAM size – Elder Geek Jun 19 at 12:33
1

Hibernation requires swap space on a separate partition. Although it also can work on a swap file, the swap file must be contiguous and the offsets indicating the physical location of the file must be specified, so setup is more complex.

If you want to try hibernation, create a swap partition first. The size of the swap partition should be at least the size of your computer RAM: hibernation involves that all content of RAM is written out to SWAP space before the system shuts down; on restart, the contents os read again from the SWAP space into RAM.

Be aware that hibernation may not work properly on your computer, even if you have set up proper SWAP space. This is because computer manufacturers tend not to document how they implemented power management. As a result, hibernate does not work well on quite a lot of hardware.

  • Ah okay, makes sense since the swap files I used weren't contigous. I'll try deleting those and setting a single 9G swap file. If I may ask however, if using dd is also limited by ram or whatever since using dd to create a 9G swap file throws some errors for me. – DepChemical Jun 20 at 7:08
  • As I indicated in my answer, using a swap file for hibernation is more complicated. I advise to go for a separate swap partition. With dd, you can make files, size being limited by the file system in use. – vanadium Jun 20 at 7:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.