April 18, 2015, 10:51:49 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Visit our home page for VL info. To search the old message board go to The first VL forum is temporarily offline until we can find a host for it. Thanks for your patience.
Now powered by KnowledgeDex.
   Home   Help Search Login Register  
Please support VectorLinux!
Pages: [1] 2
Author Topic: HowTo: Enable Suspend2 Hibernation support on VectorLinux 5.8 Standard  (Read 9805 times)
Global Moderator
Posts: 2160

« on: March 13, 2007, 03:30:23 pm »

                    Enable Suspend2 Hibernation support on VectorLinux 5.8 Standard


This HowTo will guide you through the necessary steps to take in order to achieve full hibernation/suspend support on VectorLinux 5.8 Standard.
You may probably use this info for older or newer versions of VectorLinux, but then make sure you change relevant details as you go along (version numbers, etc...). Also don't hesitate to ask in the main forum if you have any doubts.

VectorLinux 5.8 SOHO and above will most likely have Suspend2 hibernation support patched in already.

It may be a good idea to read through this HowTo before doing anything. That way, you can have an idea of what you will need to do and plan ahead.
Get all your tools lined up before starting any job!

Some trivial information:

For most Windows users, using the "suspend" or "hibernate" with laptops (when closing the laptop lid or when the battery reaches a critically low charge) is very natural and taken for granted to a large extent.

Suspending a running session so that your computer can power off in a way that will enable you to resume that session seamlessly later on is not exactly child's play, considering that the risks involved are possible data loss and severe filesystem corruption.
So one could assume Microsoft has an army of engineers working on Windows' hibernation/suspend support to make sure that it works generically on most laptops.

The Linux kernel also has its own hibernate/suspend support called Software Suspend. But it is not very up-to-date when compared to the hibernate/suspend support provided by the Software Suspend 2 fork project (Suspend2 -

So we will be working with Suspend2 Smiley

1 - What you need:

 - A fresh install of VectorLinux 5.8 Standard (preferably).
 - A working Internet connection (128kbps or above, since you will need to download about 40MB of data).

2 - Before getting started:

Although Suspend2 provides a very stable and reliable way to hibernate your computer, it goes without saying that things can still go wrong!
And when dealing with things like machine hibernating, there is a risk that you may lose data (especially when running the initial tests), so MAKE SURE YOU BACKUP ALL YOUR DATA FIRST!

It may even be a good idea to run your first tests on an "expendable" installation of VectorLinux done on a separate partition.

3 - Get all the necessary source code

You will need to recompile your kernel (nothing extra-ordinary so don't run away yet! Wink), you will have to get the source code from the Linux Kernel project archives.
If you don't want to go to too much trouble then I suggest that you stick to 2.6.19.x at the most, since 2.6.20 doesn't seem to play nicely with VectorLinux 5.8 Standard's firewall.
You may compile a 2.6.20 kernel or above, but it might require a bit more tinkering with the iptables modules, which is not covered here.

At the time this HowTo was written, the newest 2.6.19 kernel was revision 7 (

So open a terminal and logon as root. Then navigate to /usr/src:

cd /usr/src/

Download the kernel source tarball with wget:


Extract the tarball:

tar xvfj linux-

That will probably take some time to extract. When its done, then enter the newly created source directory:

cd linux-

Next thing to do is to download the Suspend2 kernel source patch, which after applied will give the kernel Suspend2 support.


Decompress the patch:

bunzip2 suspend2-2.2.9-for-2.6.19.patch.bz2

Apply the patch with the following command:

patch -Np1 -i ./suspend2-2.2.9-for-2.6.19.patch

The patching should occur without ANY errors or warnings. You should see something like this in your terminal when its done (the list here is cut short because its very long):

root:# patch -Np1 -i ./suspend2-2.2.9-for-2.6.19.patch
patching file Documentation/kernel-parameters.txt
patching file Documentation/power/Suspend2-Changelog.txt
patching file Documentation/power/suspend2-internals.txt
patching file Documentation/power/suspend2.txt
patching file MAINTAINERS
patching file arch/arm/kernel/signal.c
patching file arch/avr32/kernel/signal.c
patching file arch/frv/kernel/signal.c
patching file arch/h8300/kernel/signal.c
patching file arch/i386/kernel/io_apic.c
patching file arch/i386/mm/init.c
patching file arch/i386/power/Makefile
patching file arch/m32r/kernel/signal.c
patching file arch/powerpc/kernel/Makefile
patching file arch/powerpc/kernel/signal_32.c
patching file arch/sh/kernel/signal.c
patching file arch/sh64/kernel/signal.c
patching file arch/x86_64/kernel/Makefile
patching file arch/x86_64/kernel/suspend.c
patching file arch/x86_64/kernel/time.c
patching file mm/pdflush.c
patching file mm/vmscan.c
patching file net/rxrpc/krxiod.c
patching file net/rxrpc/krxsecd.c
patching file net/rxrpc/krxtimod.c
patching file net/sunrpc/svcsock.c

4 - Configuring, building and installing your Suspend2 enabled kernel:

Configuring the kernel's sources can be tricky if you have to do it from scratch, but to get around that you can also simply use the kernel configuration that was provided by default with VectorLinux kernel.
This will save you lots of time, and is much easier if you are not familiar with the ins-and-outs of Linux kernel.

Still as root and in the kernel source directory(/usr/src/linux-, copy the default VL kernel configuration file:

cp /boot/config- ./.config

Now run this command to get the configuration editor:

make xconfig

You will see some stuff going on in you terminal. Shortly after a window will appear that looks like this:

Locate the option called "Suspend2" and mark the checkbox. A submenu will unfold on the right side of the window with more options. Mark the "Swap Allocator" option and make sure that "Replace swsusp by default" is also checked, as demonstrated in this screenshot:

Now scroll down the left side of the screen and click on "Cryptographic options". On the right side of the window, click on the "LZF compression algorithm" option box until you get a check-mark. Make sure you mark it with a check-mark and not a dot!
Here is another example screenshot:

If you know what you are doing, you can also add some extra customizations.
Otherwise, click on the Save button and then exit.

You should be returned to the command prompt.
Next issue this command:

make bzImage && make modules

This can take quite a while depending on how fast your computer is (but it will take at least an hour).
When it is finished, then do the following (still in the kernel source directory):
Copy the new kernel boot image to /boot:

cp ./arch/i386/boot/bzImage /boot/vmlinuz-

Copy the configure file you used and the new system map to /boot:

cp ./.config /boot/config-
cp ./ /boot/
Install the modules that you built:

make modules_install

Now we must enter the /boot directory and do update a few symbolic links:

cd /boot
rm vmlinuz config

ln -sf vmlinuz- vmlinuz
ln -sf config- config
ln -sf

Those new symbolic links will make the new kernel you built the default one.

Next, make some necessary changes to lilo (adding the swap drive to be used by Suspend2 and making a backup boot entry).
Open /etc/lilo.conf (with any editor you want, doesn't have to be mcedit):

mcedit /etc/lilo.conf

Add append = "resume2=swap:/dev/hdXY" to each lilo entry, where XY are the drive labels for your swap partition.
My swap partition is located on /dev/hda1, so the line will look like this:

append = "resume2=swap:/dev/hda1"

Here is my lilo.conf as an example:

# LILO configuration file
# generated by 'liloconfig'
# Start LILO global section
boot = /dev/hda2
default = linux
timeout = 1200
# Override dangerous defaults that rewrite the partition table:
bitmap = /boot/bitmap/boot.bmp
# Normal VGA console
#vga = normal
# VESA framebuffer console @ 1024x768x64k
# VESA framebuffer console @ 1024x768x32k
# vga=790
# VESA framebuffer console @ 1024x768x256
# vga=773
# VESA framebuffer console @ 800x600x64k
# vga=788
# VESA framebuffer console @ 800x600x32k
# vga=787
# VESA framebuffer console @ 800x600x256
# vga=771
# VESA framebuffer console @ 640x480x64k
# vga=785
# VESA framebuffer console @ 640x480x32k
# vga=784
# VESA framebuffer console @ 640x480x256
# vga=769

# End LILO global section
# Partition 1: Linux GUI mode
image = /boot/vmlinuz
    root = /dev/hda2
    label = linux
    append = "resume2=swap:/dev/hda1"
# Partition 2: Linux TUI mode
image = /boot/vmlinuz
    root = /dev/hda2
    label = linux-tui
    append = "2  resume2=swap:/dev/hda1"
# Partition 4: Linux
image = /boot/vmlinuz-
    root = /dev/hda2
    label =
    append = " "


As you can see, I added a backup entry called "", so that I can still boot the vmlinuz- kernel image if things go sour.

Save the file, and run:

lilo -v

If everything runs ok and lilo doesn't abort, then reboot your computer.

When the lilo splash comes up, then select the "linux" option, if you have the same settings as my lilo.conf (or whatever other label is associated to the new kernel you built).

Your computer should boot as usual. Once you have loged in, then open a terminal and type:

uname -ro

You should see this: GNU/Linux

That means your new kernel has booted and it up-and-running!

5 - Installing the hibernation/suspend scripts, configuration files and manual pages:

The next thing to do is to get the scripts that will provide the suspend/hibernate commands.

In your terminal, logon as root and then enter the /tmp directory:

cd /tmp

Download the Suspend2 hibernation scripts tarball:


There is a newer version, 1.94, but it seems to be either lacking a configuration file or a patch that then makes the install script fail.
Version 1.93 will work just fine though.

Decompress the tarball:

tar xvfz hibernate-script-1.93.tar.gz

Enter the newly created decompressed directory:

cd hibernate-script-1.93
Before running the installation script (, you must modify it so that it fits Vector's installation prefixes:

mcedit ./

Change this line:

[ -z "$PREFIX" ]        && PREFIX=/usr/local

To this:

[ -z "$PREFIX" ]        && PREFIX=/usr

Save the file, and then run it:

After the files have been installed, then go into /etc/hibernate so we can make some changes:

cd /etc/hibernate

cp common.conf.dist common.conf

Thats pretty much it as far as installing the scripts goes.

6 - Testing the hibernation support

After installing those scripts, a new executable file will appear in /usr/sbin called hibernate
That is the file you will be calling at the command line to hibernate or suspend your machine.

Note that all the configuration options that are set now are the default ones, so you will have to adjust settings as you go along.
The Suspend2 FAQ page lists several issues you might run into, depending on your hardware:

And you won't know if you have those problems until you test everything...

In your terminal emulator (still as root), run:

hibernate -v 3

The -v 3 switch will enable high verbosity, so if you encounter problems then they will show up in your terminal in great detail.

The hibernate process should start by blanking out the screen and reporting its progress until the computer powers down.

Now turn it on again and boot your new kernel as before.
If all goes well, then you should see the kernel booting as usual for the first few seconds, and then after scanning for devices it should saw something like "Suspend2 2.2.9: resume enabled" and it should resume to where you left off.

One of the first things that may not function properly is num-lock, but I found that pressing the num-lock key 3 times gets it going again Cheesy

For those with video acceleration drivers, you may (or may not) find that hardware acceleration is gone after resuming.
If that does happen, then append UseDummyXServer to /etc/hibernate/hibernate.conf:

mcedit /etc/hibernate/hibernate.conf

Add UseDummyXServer at the end, and save the file.
This option will force Suspend2 to give 3D acceleration modules (like nvidia and fglrx) a "wake-up nudge" by momentarily running a fake X server.

If your heatsink fans fail to turn on after waking up from the hibernation, then you will need to add the thermal and fan modules to the Suspend2 hibernate blacklist:

mcedit /etc/hibernate/blacklisted-modules

Add those two to the end of the file, and save it.

The blacklist file (/etc/hibernate/blacklisted-modules) will block potentially problematic modules from being loaded back into memory during the wake-up process. This doesn't mean that you won't be able to use them! It simple doesn't let them load while the un-suspending is taking place, but as soon as that process is completed, the modules will reload when the kernel calls for them.

If you browse through the blacklist you will see that a significant portion of the modules listed there are either network modules or USB modules.

After testing Suspend2 on my PC, the USB modules though blacklisted in Suspend2's blacklist file, are indeed reloaded in the background when I plug in my pendrive, so the blacklist isn't anything scary or to worry about!

For more information on extra blacklisting options, read the commented text at the beginning of /etc/hibernate/blacklisted-modules

7 - Letting all users hibernate

After you have tweaked your settings, its safe to let users access the hibernate function. This is indeed useful, especially for allowing hardware sensors to hibernate your laptop when the battery runs low, or when your PC's UPS reaches a critical charge.

In this section, you will be guided through creating a new sudo group and policy, and adding users to that group.

Firstly, you must change the hibernate script's access rules, so that only root can call it.
In your terminal, as root, type in this command:

chmod 744 /usr/sbin/hibernate

Now, to create a new group called hibernate:

groupadd hibernate

Make a backup of the sudoers file, and create a new sudo policy that will allow users belonging to that group to access /usr/sbin/hibernate will full root permissions:

cp /etc/sudoers /etc/sudoers.BAK

mcedit /etc/sudoers

Add these lines to the end of the file:

#Allow users to access the Suspend2 hibernate script:

%hibernate ALL=(root) NOPASSWD: /usr/sbin/hibernate

Next, you will need to create a file that will run the sudo command (and a few others too), that is accessible to all users:

mcedit /usr/bin/user-hibernate

Enter these lines into the file:


#Add any custom pre-hibernation commands here:


#Call sudo with hibernate script:

sudo /usr/sbin/hibernate $*

Save the file.
Make the file executable to all users:

chmod 755 /usr/bin/user-hibernate

Associate the user-hibernate script to the hibernate group:

chgrp hibernate /usr/bin/user-hibernate

Add your username to the hibernate group:

gpasswd -a xxxxx hibernate

Replace xxxxx with your username.
Repeat the gpasswd command for any other users you also wish to allow hibernate access.

Now to test the hibernate support as a regular user, open a terminal as a regular user and run:


If all goes well, your computer will hibernate properly, as though the command were run as root.

Note that once a hibernation has been resumed, the next time you reboot or shut down your computer will work as it usually does. Suspend2 won't interfere with anything unless you run the hibernation script.

8 - Making your laptop hibernate when the battery runs low:

If you are using VectorLinux 5.8 Standard and Xfce as your graphical environment, then you can use the Battery Monitor applet to call the user-hibernate script when your battery runs low on power.

You may already have the Battery Monitor applet active on your taskbar if you are using a laptop, but if you don't then right click on the Xfce panel, and select Add New item.
From the window that appears, select Battery Monitor and press Add.

A new applet will appear on your taskbar with a percentage bar indicating your battery's current status.
Right-click on the applet and select Properties.
A window will pop up with the Battery Monitor applet's options.

Depending on how well you know your battery, you may change the low and critical percentage values in the Battery Monitor window; however, since the hibernation process consumes lots of processing power and also generates a considerable amount of hard-drive activity, and thus consumes lots of precious battery power too, you don't want the battery to die on you while the suspend is taking place. So the safe zone for the critical percentage for a battle-worn battery is probably about 5 to 6%, and a new battery 2 to 3%.

In the Low battery action field, select Display a warning message from the drop-down menu. You don't necessarily have to set it to this value, but it is nice to be warned when your battery is on its last breath.

In the Critical battery action field, select Run command. Right beneath that, there is a text-box where you can enter the desired command when the battery reaches critical condition. So in the Command text-box, enter the user-hibernate script's full path, as follows: /usr/bin/user-hibernate

Here is also a complementary screenshot to help you in case you are having trouble:

For those not using Xfce (neither KDE), then this Gentoo Wiki section will help you configure ACPI to monitor you battery:

It is very detailed, so I wont echo it here.

9 - Taking protective measures to prevent data loss:

When Suspend2 hibernates your machine, it makes a "carbon copy" of whatever is loaded in your computer's memory, compresses that copy and stores it in your swap partition.
When you resume a hibernated session, Suspend2 will decompress and reload that copy it made.
That means that Suspend2 also expects to find your hard-drive in the exact same state as when it hibernated your computer.

So if Suspend2 reloads its "carbon copy" of your session and things have changed on your hard-drive (or pendrive for that matter), then there will be conflicting information about what data is supposed to exist.
This will lead to filesystem corruption, which means that your ENTIRE partition will get "scrambled". And in a very severe fashion too...
If you are using ext2 or ext3 filesystems, there way be a possibility of trying to recover from that filesystem crash by using the e2fsck command.

If you are using ReiserFS (which already has integrity problems of it own), then recovery of your partition is most likely futile.

So never modify the contents of a suspended drive!

This problem can be circumvented of course.
You may have noticed that the user-hibernate script runs vlh-umount before running the hibernate command.
This way, any hot-plugged devices will be synced and unmounted before the hibernate process takes place.
The same can be done for other mounted devices (a Windows partition for example) by adding the appropriate unmount commands in the user-hibernate script.

10 - Extra reading (troubleshooting, and more information):

Suspend2 FAQ pages:

Relevant information from the Gentoo Wiki (from ACPI configuration onward):

11 - Final notes:

This HowTo is not intended as a RTFM "gag".
If you are having problems, then don't hesitate to ask!

Improvements to this HowTo are welcome.

12 - Enjoy hibernation support!

Yep, it does feel good, and is addictive too  Grin

« Last Edit: March 16, 2007, 04:11:51 pm by easuter » Logged

Posts: 2499

« Reply #1 on: March 13, 2007, 04:11:26 pm »

Just one note, IMHO, the kernel config in the package is better than the one in the iso.

O'Neill (RE the Asgard): "Usually they ask nicely before they ignore us and do what they damn well please."
Running: VL 7 Std 64 + self-cooked XFCE-4.10
Posts: 3261

-- Just being myself --

« Reply #2 on: March 14, 2007, 06:02:48 pm »

currently I am using VL58 GOLD default kernal
does this howto work for this version of kernal?
Global Moderator
Posts: 2160

« Reply #3 on: March 14, 2007, 11:06:32 pm »

currently I am using VL58 GOLD default kernal
does this howto work for this version of kernal?

Yes, in theory, but you would have to get a 2.6.18 Suspend2 patch for that kernel, instead of the 2.6.19 one used here.

Posts: 3261

-- Just being myself --

« Reply #4 on: March 15, 2007, 01:57:11 am »

from below link there a download for kernel


does that work for my kernel?
Global Moderator
Posts: 2160

« Reply #5 on: March 15, 2007, 02:03:06 am »

That might work, its just a matter of trying.
But installing a newer kernel like 2.6.19.x can't do any harm....

Posts: 3261

-- Just being myself --

« Reply #6 on: March 15, 2007, 02:33:12 am »

where can I download it?

Got it....
downloading it from
« Last Edit: March 15, 2007, 02:54:17 am by hata_ph » Logged
Global Moderator
Posts: 2160

« Reply #7 on: March 15, 2007, 04:11:25 am »

I think we are misunderstanding each other: the Suspend2 patch is a source code patch, so in other words you can only apply it to the kernel source code and not to a pre-built kernel.
So there really isn't any point in getting pre-built kernels from the repository because you are going to have to compile the source in any case.

If you follow the steps mentioned in the howto, they already included getting the source code for the new kernel from the Linux Kernel Archives and building the kernel itself after the sources have been patched.
« Last Edit: March 15, 2007, 04:26:55 am by easuter » Logged

Posts: 3261

-- Just being myself --

« Reply #8 on: March 15, 2007, 07:29:34 am »

oh....I think I have miss read this howto........
another question, if I follow the howto and install kernel version it erase my current kernel?
I did once install a "pre-build" kernel (version 2.6.20) that I download from VL repository. It show 2 kernel at LILO which I can choose and remove at later( Can I do the same if I install new kernel from source?
Global Moderator
Posts: 2160

« Reply #9 on: March 15, 2007, 07:32:03 am »

If you follow the howto, then you will end up with 2 kernels on your computer to chose from: the one with suspend suport in it, and the default one as a backup in case the new one doesn't function correctly.

Posts: 3261

-- Just being myself --

« Reply #10 on: March 15, 2007, 07:46:55 am »

is this the only way to enable the Suspend2 function? Add the patches to a kernel source and install the modify kernel from source? Is there any pre-build patches or packages that can be install to the current installed kernel?

Sorry for asking a lot of question. Because I am new to Linux and kernel configuration, scare I will screw up my system if I make some mistake...Tongue
« Last Edit: March 15, 2007, 07:48:27 am by hata_ph » Logged
Global Moderator
Posts: 2160

« Reply #11 on: March 15, 2007, 07:58:13 am »

Quote from: hata_ph
Sorry for asking a lot of question. Because I am new to Linux and kernel configuration, scare I will screw up my system if I make some mistake...

No problem, better to ask than to be sorry later  Wink

Yeah this is one of the ways to do it.
The other way would be to build one with all the patches in it already and upload it to the repo, so that you could just download and install the packages.

If I'm not mistaken, the 2.20.x kernels in the repo should have Suspend2 patched in, but Joe1962 or uelsk8s would probably be able to  tell you with better detail about that...

Posts: 2504

« Reply #12 on: March 15, 2007, 09:28:20 am »

this kernel has the suspend2 patch
Posts: 92

« Reply #13 on: March 15, 2007, 11:22:47 am »

That kernel had the same wireless bug which I already mentioned at Beryl live beta4 bug report, you can see it here

Fish go m00!
Posts: 3261

-- Just being myself --

« Reply #14 on: March 16, 2007, 09:21:26 am »

just try it and it work for root...but when I run the command "user-hibernate" it prompt out error as below

>>> sudoers file: syntax error, line 109 <<<
sudo: parse error in /etc/sudoers near 109

I know the hibernation program work but is not working while using sudo for normal users.....

I did add the below line to /etc/sudoers

#Allow users to access the Suspend2 hibernate script:

%hibernate    ALL=(root)     NOPASSWD: /usr/sbin/hibernate

I did create a hibernate group and add my username to it...
create a /usr/bin/user-hibernate with global read and execute right
change /usr/bin/user-hibernate to hibernate group
what else that I am missing??


Found out that I cannot shutdown or restart my laptop using XFCE (halt or shutdown from CLI is still working though). When I click the "QUIT" button from XFCE the restart and shutdown option was disabled. It happen both in kernel and Dunno it is due to the Suspend2 patch that I just installed........ Huh
« Last Edit: March 16, 2007, 10:06:21 am by hata_ph » Logged
Pages: [1] 2
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!