on-demand swap space?
Hi,
So my laptop has a funny "feature" that is quite annoying. It likes to wake itself up whenever the battery gets low, the time it really needs to stay asleep. I checked the BIOS for some setting, but it seems that ASUS made this a hardwired feature. Present in windows as well. Anyway, under normal conditions, I don't want to waste disk space for swap that never gets used, but it seems the only way to stop my computer from running itself to the ground is to hibernate it. So my question is this: how can I make swap space on demand? I saw some code in someone's signature here, but I could not find it again. I was thinking about adding something like this to my sleep scripts: Code:
#!/bin/sh thanks, rabbit2345 |
Do you have a small hard drive?
To hibernate, your swap should be the size of your RAM maximum. |
Actually, his question is pertinent to SSDs as well, as having a persistent swap space is counter-productive on SSD drives (dedicating a place to wear out as opposed to allowing it to be more dynamic, to take better advantage of wear-leveling), as is frequent logging, ... I'm actually looking into this for an older-ish EEE PC I have (1st gen., 8GB SSD). It's a low priority issue for me,... But, if I come up with a practical solution before anyone else does, I'll let you know,...
Oh,... and to safeguard against frequent swapping, set your swappiness to something low, like 5, or even 1... Default is typically 60 (which translates roughly as 60% likely to push something to swap). |
Is it waking up to do a full shutdown?
|
Hi,
After working on this a bit, I came up with this script and placed it into /usr/lib/pm-utils/sleep.d/00amkswap: Code:
#!/bin/bash When pm-hibernate is called, everything is good, but the system is unable to find a swap device, despite there being swap space present, and recorded in /etc/fstab. PM complains "cannot find swap device, try swapon -a" However, if I boot up with resume=/dev/sda4 resume_offset=12345, then the first suspend works fine, since my script replaces the offset with the real one. But any hibernates after that fail. Any ideas? thanks, rabbit2345 |
Have a look at this thread in the Ubuntu forums;
http://ubuntuforums.org/showthread.php?t=1042946 Similar, but do not appear to be deleting the swap file... Maybe you can adjust your approach. |
All times are GMT -5. The time now is 07:45 AM. |