Swap space requirements on large memory - given hibernation needed

This been long debated, back since the days that 1GB was considered too much memory :slight_smile: :slight_smile:

Explained in Swap FAQs:

https://help.ubuntu.com/community/SwapFaq#:~:text=reduced%20or%20eliminated.-,How%20much%20swap%20do%20I%20need?,Example%20Scenarios

however, could not find a recent updated explanation on how much SWAP is needed to allow system HIBERNATION:

# systemctl hibernate
Call to Hibernate failed: Not enough suitable swap space for hibernation available on compatible block devices and file systems

most say, same amount of RAM, is that true for 96GB system? set up 96GB swap ? :slight_smile:

Suspend works fine, but hibernation does not… in fact, even with more swap setup:

# free -m
               total        used        free      shared  buff/cache   available
Mem:           77949        2770       19929           2       56072       75179
Swap:          81919        1258       80661

here 16GB RAM was given to VRAM, so left with 77GB, but still it fails even with more swap setup… the reason being, the swap device(s) are not one whole size… is that true? one needs amount of RAM in contiguous swap partition/file ?

Would be happy to find if there’s a way to somehow “compress” that memory during the hibernation process so that less than RAM in required in contiguous partition…

As fas as I know your swap should at least (worst case) be as large as the sum of your RAM and graphics memory together. All volatile memory needs to be written to disk.

Right, system has 96GB total, from that 16gb go to vram, now added more swap:

# free -m
               total        used        free      shared  buff/cache   available
Mem:           77949        2842         665           2       75264       75107
Swap:         118783         778      118005

still, hibernate says not enough same as before, suspect it must be contiguous chunk…

Also, are there any plans/ways to ZIP/compress that before/during hibernation?

hibernation compresses the memory image by default with lzo algorithm.

As I said before: memory compression is the default.

And the memory image needs to reside on just one swap device. The reason is the resume= kernel parameter. It defines only one swap device by UUID. This can be a file or a partition. The image can not extend over several swap devices.

Maybe arch wiki Suspend and hibernate is of some help. There’s also a section on image compression algorithms.

I have swap on my machines for hibernation, although not in your dimensions (just 4-8 GB RAM).
I’ve never gotten hibernation to work reliably with a swap file.
In my experience you need a dedicated swap partition with a swap filesystem.
YMMV.

@g-schick thanks for that link, nice deeper info… what seen thus far:

  1. it appears ADDED swap is not detected for hibernation until next reboot. then, it allowed to hibernate even though did not add anything extra.
  2. seems the hibernation allows even with split devices, but it does not RESUME properly :slight_smile: in that case one must create a contiguous device/partition…
  3. If compression is there, sounds like a lot LESS than full size of RAM would be needed…

anyways, noticed some issues with resume, sometimes display is not activated fully… will need to dive deeper, system is pretty new and only now stopped crashing due to running the LLM on the GPU instead of just CPU :slight_smile:

Thanks, will experiment further based on above info.

NVIDIA GPU? Yes, it will almost certainly have “trouble” waking from hibernation.

I have had numerous NVIDIA and non-NVIDIA machines over the years, and the only ones that won’t wake from hibernate in a functional state are those with NVIDIA GPU and the binary NVIDIA driver. It’s never worked as far as I can tell.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.