Difference between revisions of "Suspend"
(Added part about reloading lirc modules) |
(Suspend to disk) |
||
Line 1: | Line 1: | ||
− | This article describes how to suspend your MD to RAM. | + | This article describes how to suspend your MD to RAM (standby) or to disk (hibernation). |
Line 70: | Line 70: | ||
− | == | + | == Suspend to RAM == |
− | + | Run | |
hibernate-ram | hibernate-ram | ||
to suspends the MD to ram. The script first checks if it recognizes your hardware, to take the correct actions before suspending. | to suspends the MD to ram. The script first checks if it recognizes your hardware, to take the correct actions before suspending. | ||
Line 78: | Line 78: | ||
USuspendRamForce yes | USuspendRamForce yes | ||
line, to force it to suspend anyway. | line, to force it to suspend anyway. | ||
+ | |||
+ | == Suspend to disk / Hibernation == | ||
+ | |||
+ | Before trying to set up suspend to disk, I recommend that you first get suspend to ram working. All setup needed for suspend to RAM is also required for suspend to disk. | ||
+ | |||
+ | To enable suspend to disk, you will need to set up a swap partition on the MD in question. This is because the suspend implementation in the current kernel can only save the memory to the swap area. To achieve this on a diskless MD, you might use a CF card and a CF/IDE adapter. A CF card with 1 or 2 GB should be sufficient. | ||
+ | |||
+ | |||
+ | Edit the /etc/fstab file for the MD and add an entry for the swap partition | ||
+ | /dev/sda1 none swap sw 0 0 | ||
+ | Adjust the partition to match your swap partition. Make sure you select the right one, or you WILL destroy your data. In the case of a diskless MD, you will probably only have one partition (a CF card for instance). | ||
+ | |||
+ | |||
+ | Copy two files from /usr/share/initramfs-tools/scripts/local-premount/ (resume, uswsusp) into /etc/initramfs-tools/scripts/nfs-premount/ | ||
+ | Not sure if both files are required, but it doesn't hurt. | ||
+ | |||
+ | These scripts will run before any file systems have been mounted, and after any disk drivers has been loaded. Both are important: mounting any file systems before resuming can corrupt your data, according to the documentation. And we need to have the drivers loaded to access the suspended image. | ||
+ | |||
+ | |||
+ | After copying the two files, run | ||
+ | update-initramfs -u | ||
+ | to update the initramfs image, which includes the scripts in the boot up process. | ||
+ | |||
+ | |||
+ | Now reboot your MD. When it has started up again, you can type | ||
+ | hibernate-disk | ||
+ | to initiate suspend to disk. | ||
== References == | == References == |
Revision as of 20:45, 8 January 2008
This article describes how to suspend your MD to RAM (standby) or to disk (hibernation).
Contents
Motivation
- Saving power
- Quick boot (usefull if your MD is noisy and you turn it off when not in use)
Setup
There are several different ways of achiving suspend, this is one using the hibernate scripts, which can be configured to use different ways of suspending the machine.
On the MD in question, make sure you have the uswsusp and hibernate packages installed.
apt-get install uswsusp hibernate
Check your BIOS setting to make sure that suspend to ram is enabled.
Using NVidia graphics card
Edit your xorg.conf file and add this line to the "Device" section:
Option "NvAGP" "1"
Also make sure no other vendor AGP modules are loaded, like intel_agp, sis_agp etc. The agpgart module is fine, though. Use
lspci | grep agp
to list all loaded agp modules.
If you see any agp modules besides agpgart, add a line to /etc/modprobe.d/blacklist to blacklist the module.
Edit the /etc/hibernate/ram.conf file, and comment the two lines
#EnableVbeTool yes #VbetoolPost yes
Edit the /etc/hibernate/blacklisted-modules, and comment the line:
#nvidia
Enable wake on lan
To enable wake on lan, to let the core wake up the MD, you have to run a command to enable this before going to sleep. The normal shutdown process does this, but this is not run when suspending the computer. Hibernate provides a way of including our own scripts before suspending.
Add a file (i.e. enableWOL) to the /etc/hibernate/scriptlets.d/ folder:
AddSuspendHook 15 EnableWOL EnableWOL() { ethtool -s eth0 wol g }
Lirc module unloading and reloading
Some lirc modules (at least lirc_serial) needs reloading after suspend. Like for enabling wol, we add a file in the /etc/hibernate/scriptlets.d/ folder, with a descriptive name lirc.
# Stops and unloads the current lirc module before suspending, and # restarts lirc when resuming AddSuspendHook 30 UnloadLirc AddResumeHook 30 StartLirc UnloadLirc() { /etc/init.d/lirc stop if [ -f /etc/lirc/hardware.conf ];then . /etc/lirc/hardware.conf rmmod $MODULES fi } StartLirc() { /etc/init.d/lirc start }
Suspend to RAM
Run
hibernate-ram
to suspends the MD to ram. The script first checks if it recognizes your hardware, to take the correct actions before suspending. If you get a message that your machine is unknown, edit the /etc/hibernate/ususpend-ram.conf file, and un-comment the
USuspendRamForce yes
line, to force it to suspend anyway.
Suspend to disk / Hibernation
Before trying to set up suspend to disk, I recommend that you first get suspend to ram working. All setup needed for suspend to RAM is also required for suspend to disk.
To enable suspend to disk, you will need to set up a swap partition on the MD in question. This is because the suspend implementation in the current kernel can only save the memory to the swap area. To achieve this on a diskless MD, you might use a CF card and a CF/IDE adapter. A CF card with 1 or 2 GB should be sufficient.
Edit the /etc/fstab file for the MD and add an entry for the swap partition
/dev/sda1 none swap sw 0 0
Adjust the partition to match your swap partition. Make sure you select the right one, or you WILL destroy your data. In the case of a diskless MD, you will probably only have one partition (a CF card for instance).
Copy two files from /usr/share/initramfs-tools/scripts/local-premount/ (resume, uswsusp) into /etc/initramfs-tools/scripts/nfs-premount/
Not sure if both files are required, but it doesn't hurt.
These scripts will run before any file systems have been mounted, and after any disk drivers has been loaded. Both are important: mounting any file systems before resuming can corrupt your data, according to the documentation. And we need to have the drivers loaded to access the suspended image.
After copying the two files, run
update-initramfs -u
to update the initramfs image, which includes the scripts in the boot up process.
Now reboot your MD. When it has started up again, you can type
hibernate-disk
to initiate suspend to disk.
References
The hibernate script uses uswsusp by default when trying to suspend to ram. For more information about the s2ram utility used, read the S2ram howto