5

I have a Linux box with a swap partition of size RAM + x. Suppose more than x of the swap is already in use. Now I try to hibernate. Will the kernel

  • randomly kill sleeping and/or not sleeping processes until there is enough swap free to hold the RAM
  • not hibernate and warn/ask to proceed?

Or will this situation never happen because the kernel always reserves enough swap to safely hibernate?

Can I configure the behavior?

Edit: If this makes a difference, I'm currently using Ubuntu 12.04 with Linux 3.2.0-39-generic and hibernate with pm-hibernate.

  • Don't really know how linux filesystems work, or if this is relevant, but I tried running a Wordpress install on a server with 128MB of RAM and it didn't handle traffic well - the server would literally freeze to where I couldn't even input commands to stop Wordpress / reset - had to actually press the button.. My guess would be that it wouldn't kill any processes, but that's just a guess. – cutrightjm Apr 3 '13 at 15:53
  • from my experience it will freeze your computer. At least it did that for me on arch linux.. – dashboard Apr 3 '13 at 16:07
2

on later versions of linux kernels you are required to have a swap to hibernate. But there are work arounds. you can setup a swap file anywhere without partitioning.

Read about it here. https://www.kernel.org/doc/Documentation/power/swsusp-and-swap-files.txt

a quick solution (credit to Robert Munteanu)

Create the swap file : dd if=/dev/zero of=/swapfile bs=1024 count=8388608 ( 8GB )
Setup the swap file: mkswap /swapfile
Only when you need to set suspend you can activate it: swapon /swapfile
When you resume you can deactivate it: swapoff /swapfile
| improve this answer | |
  • Thanks! Is there a way to trigger swapoff /swapfile automatically after resuming? – Simon S Apr 4 '13 at 17:41
  • I will ask a friend. I am sure its possible. Ill let you know asap – user213584 Apr 8 '13 at 5:43

Your Answer

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

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