My understanding is that suspend-to-swap (swsusp) will fail if there is not enough free space in swap.

Is there a way to reserve swap space for swsusp, such that the space will never be used for "normal" swap purposes?

I have seen another answer that suggests creating a swap partition, let it mount, and set vm.swappiness = 0. But there are two issues with that solution:

  1. It's not bullet-proof; vm.swappiness = 0 doesn't completely prevent the kernel to use swap - it only makes the kernel really hold off using swap until it absolutely needs it.
  2. And if the kernel holds off using swap, well, I don't get to use regular swap at all.

What I'm envisioning is to have two separate swap partitions:

  • swap1 will be exactly as big as my RAM and reserved for swsusp hibernation;
  • swap2 will be whatever size I want and used for normal swap.

Is that setup possible?

That would be similar to how Windows works; in Windows, you would have:

  • pagefile.sys for normal swap
  • hiberfile.sys reserved for hibernation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.