Differences between revisions 34 and 36 (spanning 2 versions)
Revision 34 as of 2012-09-14 20:00:09
Size: 3298
Comment:
Revision 36 as of 2012-12-17 06:28:50
Size: 4128
Editor: ?JacquesDeBroin
Comment:
Deletions are marked like this. Additions are marked like this.
Line 25: Line 25:
Edit the last line of /etc/sysctl.conf so it sticks: Create a file called local.conf in /etc/sysctl.d and add the kernel variable there so it sticks:
Line 39: Line 39:
Configure uswsusp:
{{{
dpkg-reconfigure -pmedium uswsusp
}}}
At the "Continue without a valid swap space?" question, answer Yes.

At the "Swap space to resume from:" prompt, select the partition where the file above was created.

Answer the "Encrypt snapshot?" and "Show splash screen?" questions as you please.
Line 79: Line 89:
If you want to lock the screen, save the swap to disk (in case your system runs out of power) and suspend to ram (to resume quickly if it still has power), create a script called /usr/local/bin/gotosleep containing:
{{{
/usr/bin/xscreensaver-command -lock
sleep 2
sudo /usr/sbin/s2both
}}}

Make sure sudo does not prompt you for a password:
{{{
sudo visudo -f /etc/sudoers.d/local

%powerdev ALL=NOPASSWD: /usr/sbin/s2both, /usr/sbin/s2ram
}}}
 

Translations : Deutsch

How to use hibernation without a swap partition.

First, create a swap file:

fallocate -l 256m /swap

mkswap /swap 

"256" refers to the size in MBs ('m' after it). Set this for at least half the size of your RAM. "/swap" is a location of your swap file. It can be located on any partition (root or home, for example).

Add this to /etc/fstab:

/swap   swap    swap    defaults        0       0 

Now stop the kernel from using the swap file for swapping:

sysctl -w vm.swappiness=1 

Create a file called local.conf in /etc/sysctl.d and add the kernel variable there so it sticks:

vm.swappiness=1

Activate the swap file:

swapon /swap

Now use uswsusp which is an alternate suspend method for the linux kernel that can use a swap file instead of a swap partition and also supports features like compression and encryption.

Install it:

aptitude install uswsusp

Configure uswsusp:

dpkg-reconfigure -pmedium uswsusp

At the "Continue without a valid swap space?" question, answer Yes.

At the "Swap space to resume from:" prompt, select the partition where the file above was created.

Answer the "Encrypt snapshot?" and "Show splash screen?" questions as you please.

You might have to add yourself to the powerdev group.

Typically a uswsusp.conf file looks like this:

# /etc/uswsusp.conf(8) -- Configuration file for s2disk/s2both

resume device = /dev/sda1

compress = y

early writeout = y

image size = 238941634

RSA key file = /etc/uswsusp.key

shutdown method = platform

resume offset = 8288

The "resume offset = 8288" is where the swapfile actually is, and "resume device" must be the partition and not the swap file.

To test it:

s2disk

This will write the content of the RAM to the swap file and shutdown the eee. Press the power button on the eee to wake it up. To enable this method as the default system for hibernation, edit /usr/lib/hal/scripts/linux/hal-system-power-hibernate . There is a bug in this script and it will look for s2disk in the wrong place, you will have to edit it so it looks like this:

/sbin/s2disk

This script is in the HAL package, which means it will break if HAL is updated. If hibernate doesn't work after an update, you will have to re-edit /usr/lib/hal/scripts/linux/hal-system-power-hibernate . A good idea would be to make a backup of the file for quick re-insertion after an update breakage.

If s2disk hibernates, but initramfs fails to see your swap file on startup and system continues to boot up normally like the swap file is not there, you'll need to add the "resume" hook to your /etc/default/grub:

GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/sda1 quiet"

where "/dev/sda1" is a partition where your swap file is located.

After that, issue "update-grub" to recreate initramfs.

If you want to lock the screen, save the swap to disk (in case your system runs out of power) and suspend to ram (to resume quickly if it still has power), create a script called /usr/local/bin/gotosleep containing:

/usr/bin/xscreensaver-command -lock
sleep 2
sudo /usr/sbin/s2both

Make sure sudo does not prompt you for a password:

sudo visudo -f /etc/sudoers.d/local

%powerdev ALL=NOPASSWD: /usr/sbin/s2both, /usr/sbin/s2ram

Caveats. -- The console is apparently broken. More on this later.

To-Do -- Create the swapfile at the moment of hibernation - and delete (optionally) after resuming.

For more on Partitioning, Swap and Hibernation - see -