Image saving failed: -28 while hibernating Linux

A short one.

If you're trying to hibernate your system but it doesn't shut down, you'll probably try again. After a few attempts1, you go check dmesg and find this error message:

PM: Image saving failed: -28

I only thought about it now, but -28 is ENOSPC, no space error. This means that what you have in memory and swap does not fit in swap, even when it's compressed, which is how hibernate works:

$ free -h
            total        used        free      shared  buff/cache   available
Mem:            31Gi        14Gi        12Gi       2.7Gi       7.0Gi        16Gi
Swap:           47Gi        40Gi       7.8Gi

Unluckily, there's nothing that bubbles up this error to the user interface; hence, the retrying.

In my case, the solution was to stop the program that was using a lot of memory, but another one would be to create a temporary swap file big enough.


  1. my logs say I tried 4 times!