BACK
Doc
Incrementals
Index
Official
OldStuff
Software suspend under Linux

Software suspend mini-HOWTO

Version SGML Source file Date and size Change Log HTML version
0.1 .SGML.GZ 17/08/2012 12:41
6546 octets
This is the Software-suspend mini-HOWTO. Please read it carefully before installing software suspension. .HTML

Software suspend FAQ

It doesn't suspend ! PLEASE read this carefully since it is a TOO frequently asqued question and that's documented: RTFM ;)

You have to tell kernel its suspend partition using the resume=/dev/XXX option. If you forget this option, the kernel simply disables software suspension feature. The resume option is mandatory, even together with the noresume option. This partition MUST be ide. It MUST be activated by swapon (hence you have to format it using mkswap if you plan to use a new one). It is however possible to use your existing swap partition if it is large enough.

If you have other problem, read the FAQ below and the mini-HOWTO above. It is likely that you'll find your answer there (at least you'll find how to subscribe to the mailing list ;-)

Why software suspend isn't a kernel module ? Resuming must occur at the very beginning of kernel initialization. Modules are not available at such an early stage.
Why SysRq-d doesn't suspend ? Use of SysRq-d is deprecated since 2.4.18-beta7. Since 2.4.18-beta9, one can use the /proc/sys/kernel/swsusp interface even with a vanilla kernel (without acpi nor apm) but it is better to use the suspend.sh script instead of using the raw interface. If you need to activate swsusp at the lowest level login as root and use one of these command:
sysctl kernel.swsusp="1 0 0"
echo -n "1 0 0" > /proc/sys/kernel/swsusp

By default, suspend console is enabled and you should switch to console and get the swsusp progressing screen:

Suspension Console

It doesn't power off, but hangs for ever. If you haven't acpi or apm enabled in your kernel, it can't tells the hardware to shutoff, but if you reach the following stage (with progressing bar completed), the suspension is over and you can manually power off.

Suspension Console

It doesn't power off, but reboots immediately. This is not a bug, it's a test feature ;-). This allows scripts as follows to perform 20 suspend/resume cycles automatically:
count=20;
while [ $count -gt 0 ]; do
    echo "Suspension $count";
    echo "1 1 0" > /proc/sys/kernel/swsusp;
    sleep 2;
    echo "Resume $count";
    sleep 2;
    count=$[$count - 1];
done
Anterior to 2.4.18-beta9, it is likely that you have TEST_SWSUSP set to 1 in kernel/suspend.c file. Beginning with 2.4.18-beta9, change the third parameter of /proc/sys/kernel/swsusp (see above) for instance with echo -n "0 0 0" > /proc/sys/kernel/swsusp.
It resumes but hangs. I can't boot any more. You have to tell kernel to ignore resume partition using the noresume option. On the lilo prompt, type something like "linux noresume". You then have to reformat the swap partition by mkswap /dev/hdXY and activate it by swapon -a. You may find useful to have one of your lilo option launch your kernel with the noresume option.
You now have to figure out why it doesn't work ;-)
What remains to do ? Plenty ! SCSI is not supported if used on root/swap partitions, only IDE. A lot of hardware is not restored properly, including some graphic chipset. This means that this hardware is in a different state upon resume than the kernel think it is. For the kernel the hardware is initialized though it has been reset by BIOS. Sometimes, this may be solved by setting BIOS option (if it exists) to non PnP OS.
I use ide-scsi or other scsi module, can I use swsusp ? Yes, provided you can unload the corresponding scsi modules before suspension. This is why you can't have an SCSI root or swap partition with swsusp until SCSI is properly supported.
How do I feedback ? Use the mailing list. If you had subscribed to the old lister.fornax.hu mailing list, please unsubscribe from it and switch to the new sourceforge mailing list above.
I use ext3fs, can I use software suspend ? Yes! You should even be able to have an ext3 root partition. However, you *must* use e2fsprogs in version 1.25 or later, otherwise you are likely to crash your filesystem and loose all your datas.
I use reiserfs, can I use software suspend ? Yes! Feedback is welcome.
I have "strange mdrecoveryd task not stopped" message and suspension is aborted, what can I do ? This is the RAID device daemon. It seems to be activated by default under some Red Hat distributions, even when no RAID device is present. This should be fixed since beta11.

*obsoleted* You have to figure how to deactivate this daemon in your boot sequence. It should not be useful if you haven't a raid device. Please report how to deactivate it.

Why can't I use several swap partitions or swapfiles with software suspend ? This is fixed since v29alpha. You still need to use a single partition for suspension as set by resume=/dev/hdXX boot kernel option. If this device is too small, suspension should abort smoothly (but this is not fully tested). Since v29alpha, you may have several other swap devices.

*new* this has been reported to be broken since 2.4.19. Currently under investigation.

Suspending and resuming takes ages, what can I do ? For myself, most of the delay is due to the necessity of stopping drivers in a script before suspending and restarting them after resume. Suspending will never be as fast as you imagine it, at least as long as hardware drivers will not correctly handle suspending events. You may try to use the freemem feature instead of eatmem but you'll need huge RAM (or low RAM consumption) for this to work.
Can I switch from Windows to Linux using Software Suspend ? Yes, but the result is guaranteed only if the linux and windows partitions are totally independant. If for instance you use a FAT partition to share data between the two operating systems, you *must* unmount the partition before suspending. Otherwise, modification of datas under Windows may be canceled when resuming Linux. Conversely, modification of datas under Linux *will* be canceled if Windows2000 own software suspension feature is used.

Doug has posted the following message on the swsusp mailing list concerning unmounting of drives in XP (not verified):

> It is posible, there is iirc something in disk manager about this, I 
> will pay about with my win2k box and see if I can find it, but I have 
> definatly seen something about it.
>
> http://support.microsoft.com/default.aspx?scid=KB;EN-US;q314449&
> might be the right sort of area
>
> -- 
>      Tim Fletcher                 


Actually that link looks dead on.  Run mountvol from the command line with
no parameters and you get a list of volume IDs(hideously long strings) and
locations where they are mounted and details on sytanx for how to mount 
and unmount drives.  I've attached the screen output below.  
To automate it just go to 

http://www.budja.com/shutdown/

to get a simple little command-line program for hibernating and then write
yourself a little .bat file to put it all together.

Below is one I wrote but you'll need to run mountvol to get the right
volume ID to put in here first before using it and put the right path in
for the shutdown command.  Of course I don't know yet what exactly
"unmounting" means here. Does it really synchronize the disk or whatever
is needed? I'll let ya know how the actual results are when using this to
suspend in and out of windows and linux a few times.  Next I'll try to get
my "Easy Acess Buttons" programmed and maybe I'll even be able to
reprogram the power button.  If not it's not so bad to have to click a
link somewhere to hibernate.  Oh yeah... might as well add the A drive to
this procedure... I doubt it matters though seeing as how you can pull
idle floppy's out of windows without causing any harm anyway.
I use acpi patch and I got some failed hunks when applying Software Suspend patch, what can I do ? Use the acpi version of swsusp patch instead of vanilla one.
When I suspend, the machine never stops and console is filled with star '*' characters, what can I do ? This is a bug, not a feature :-( It has been reported to be linked with usb mouses. Try to stop usbmgr service before suspending. Please report if you encounter this bug since it is supposed to be fixed since 2.4.18-beta6.
Can I change removable devices while suspending ? This can be done provided you stop the corresponding drivers. For this reason, it seems better to stop USB, PCMCIA and IRDA before suspending and start the services back on resume. Under SuSE the corresponding /etc/init.d scripts are named pcmcia, usbmgr and irda. Good precaution is also to unmount floppy.
I loose my usb devices on resume. What can I do ? You need to stop usb before suspension. You can use the suspend.sh script for that. If you are a Mandrake user, check that the /etc/init.d/usb script properly call usb_stop function in the stop section. It is uncorrectly commented out in 9.0 version.
Swsusp seems nice, but can I use it for doing snapshots. No you can't because the image you save is linked to your filesystem state, including root. You can only do that if the two systems are completely independant. It may be possible (but not guaranteed) that you could do that if your root partition is mounted read-only and you unmount all other read-write devices before suspending, but that would have absolutely no interest IMHO.
Suspension seems to occur correctly, but when I resume the suspend signature is not found. Double check that you have correctly set a resume=/dev/hdX option and that you have updated your lilo or grub configuration. Also check that you don't have an unwanted unresume option. If all this is OK than pehaps you have one of those disks with hardware cache. Try to use hdparm -W 0 /dev/hdX before suspending. This should disable hardware cache. Please report if you encounter this bug since it is supposed to be fixed since 2.4.18-beta8.
After resume, why is my clock at the time of suspending ? The system time is part of CPU memory that is saved during suspension. One needs to reset the clock using hwclock upon resume, since reading the CMOS is the only way for the system to know the real time. Use suspend.sh script in order to do that automatically.
How can I patch swsusp to have a script launched on resume ? You don't need that: this feature is natural with swsusp. See the suspend.sh script for instance.
Suspension seems to occur correctly, but when I resume mouse and keyboard are frozen. This seems to happen for some hardware configurations. We haven't find a proper way to fix that for the moment. Sometimes, it seems that stopping gpm before suspending and restarting it upon resume can help. In other case, just stopping gpm and never restarting it is even better.
Suspension occurs correctly, but when I resume my Xserver has lost 3D acceleration. This seems to happen for some hardware configurations, for instance Nvidia GEforce cards. Launching a fake xserver just after resume may solve the problem. This can be done by adding
xinit /bin/false -- :1
at the end of resume script. If you use suspend script, try the nvidia keyword in SWSUSP_LEAVE_X_BEFORE_SUSPEND option.
Using 2.5.X kernel, I get an endless loop of errors saying "bad: scheduling while atomic" when suspending. This happens with preemptible kernels, which are said to be not working, so set CONFIG_PREEMPT=NO.
It fails to suspend with not enough pages message ! The amount of memory needed depends on a lot of things. For most use sizeof(RAM)x1,3 is enough for the swap partition used by swsusp. However, if you wan't to use freemem instead of eatmem you will need a large enough RAM so that sizeof(RAM) roughly equals sizeof(RAM used)x2. This will let you resume and get a usable system faster (see Software suspend mini-Howto above for explanation).
It hangs upon resume when restarting pcmcia ! This has been reported on some hardware when using the kernel pcmcia support (yenta_socket). A workaround is to use pcmcia_cs support instead. Disable all PCMCIA kernel stuff and compile the pcmcia_cs package instead. Use PCIC=i82365 (less likely PCIC=tcic) option instead of yenta.
I get rejected hunks in processor.h when merging cpufreq patch and swsusp. What can I do ? This was posted by Karol Kozimor :
      Sujet: [Swsusp] Re: [Linux-l2d] swsusp and cpufreq (powernowK7) in one kernel
       Date: Wed, 26 Feb 2003 16:21:44 +0100
       Pour: linux-l2d@linuxpunk.org
      Copie: swsusp@lister.fornax.hu,
             cpufreq@www.linux.org.uk
Chemin de retour: 
 X-ASK-Info: Whitelist match

Thus wrote Jens Haug:
> It looks like cpufreq wants to take out these lines (sorry for the 
> line wraps):
> 
> -#define cpu_has_pge    (test_bit(X86_FEATURE_PGE,  
> boot_cpu_data.x86_capability))

Yep, it then puts those in include/asm-i386/cpufeature.h, in the format:
+#define cpu_has_pge            boot_cpu_has(X86_FEATURE_PGE)

> But swsusp wants to add this line:
> 
> +#define cpu_has_pse36  
> (test_bit(X86_FEATURE_PSE36,boot_cpu_data.x86_capability))

Adding

#define cpu_has_pse36           boot_cpu_has(X86_FEATURE_PSE36)

about line 80 works fine for me. Note that X86_FEATURE_PSE36 should be
defined earlier in that file.
BACK
Doc
Incrementals
Index
Official
OldStuff

Florent Chabaud
E-mail: florent.chabaud@m4x.org
GPG key: KEY