How to Get Hibernate to Work with Nvidia Restricted Drivers

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
garda

How to Get Hibernate to Work with Nvidia Restricted Drivers

Post by garda »

Last edited February 3rd, 2009 (08:20 AM UTC): Added note about blacklisting AGPGART

To those of you who are still struggling to get hibernate working on your machine, you may want to try the method that I've applied on some computers. Please note that this method is only necessary if you need to have nVidia restricted driver (particularly version 96.xx) installed and Compiz enabled .

1. Edit /etc/X11/xorg.conf to add “NvAGP” “1” and “nologo” “1” driver options

Let's make a backup of the file before altering it:

Code: Select all

sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.old
And then open the (original) file for editing:

Code: Select all

gksu gedit /etc/X11/xorg.conf
Scroll down to the “Device” section then add both options right below the line that reads Driver "nividia". Here is a sample from my xorg.conf:

Section "Device"
Identifier "Configured Video Device"
Boardname "nvidia"
Busid "PCI:1:0:0"
Driver "nvidia"
Option "NvAGP" "1" <=
Option "nologo" "1" <=
Screen 0
EndSection

*Please Note*
If your computer becomes unstable or if graphics gets corrupted after adding the NvAGP option, you may want to blacklist the AGPGART module. You simply have to add it into the blacklist file:

Code: Select all

sudo cp /etc/modprobe.d/blacklist /blacklist.old; sudo echo 'blacklist agpgart' >> /etc/modprobe.d/blacklist
Then reboot your computer.

If you get worse performance and/or stability after rebooting with AGPGART turned off, you can restore the original blacklist file using this command:

Code: Select all

sudo cp /blacklist.old /etc/modprobe.d/blacklist
2. Open /etc/default/acpi-support to add post_video=false and vbe_save_state=false:

Code: Select all

gksu gedit /etc/default/acpi-support
Use mine as reference:

# Should we save and restore state using the VESA BIOS Extensions?
#SAVE_VBE_STATE=true
SAVE_VBE_STATE=false <=

# The file that we use to save the vbestate
VBESTATE=/var/lib/acpi-support/vbestate

# Should we attempt to warm-boot the video hardware on resume?
#POST_VIDEO=true
POST_VIDEO=false <=

*Remember to comment out the default settings before making any modifications.*

3. Disable Vsync in Compiz:

System > Advanced Desktop Effects Settings > General Options, go to the Display Settings tab and clear the checkbox next to Sync to Vblank.

4. Better reboot your computer now.

5. Check your swap partition (you need to have a properly set up swap partition in order to get hibernate working):

Code: Select all

swapon -s
You should get something like this:

Filename Type Size Used Priority
/dev/sdb8 partition 2048184 0 1

If you get any number lower than 1 (i.e. a 0 or any negative values) under Priority, then you have to do some additional steps to change it to 1. Otherwise, skip the steps below and jump right to step 7: Install uswsusp.

6. If you get a 0 or negative value for your swap partition priority, then edit your /etc/fstab to make a little adjustment in it:

Code: Select all

gksu gedit /etc/fstab
And make it look like this (just add the text in bold into yours):

# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
# /dev/sdb9
UUID=1e603731-5088-4e2f-b239-399b51e437c1 / ext3 relatime,errors=remount-ro,data=writeback 0 1
# /dev/sdb8
UUID=19fcf2e9-ed0d-4d6f-ba27-ad3821d8d533 none swap pri=1 0 0

Now save the modification, and disable swap partition:

Code: Select all

sudo swapoff -a
Now re-enable it:

Code: Select all

sudo swapon -a
It should have the correct priority value now, check to make sure:

Code: Select all

swapon -s
7. Install uswsusp:

Code: Select all

sudo apt-get install uswsusp
You should now be given several questions to configure uswsusp. Basically you simply have to define the swap partition you would like uswsusp to use for storing the memory dump, console loglevels, etc. Use the partition that appeared when you entered the command swapon -s.

Use my uswsusp configuration as reference:

Code: Select all

cat /etc/uswsusp.conf
resume device = /dev/sdb8
image size = 587737425
suspend loglevel = 2
max loglevel = 2
RSA key file = /etc/uswsusp.key
shutdown method = platform

If uswsusp configuration screen doesn't appear after installation, then call it manually:

Code: Select all

sudo dpkg-reconfigure uswsusp
8. You may want to check your kernel configuration file to make sure it has the correct settings.

Code: Select all

gksu gedit /boot/config-2.6.24-generic
Check if it has the following lines:

CONFIG_SOFTWARE_SUSPEND=y
(Note: I don't see this one in my kernel configuration file but I can still put the computer into hibernation)

CONFIG_BLK_DEV_INITRD=y

CONFIG_BLK_DEV_RAM=y

CONFIG_BLK_DEV_RAM_SIZE=65536
(Note: minimum value needed by uswsusp is 2048. If you see higher value there, just leave it as it is)

CONFIG_BLK_DEV_LOOP=y
(Note: mine is set to CONFIG_BLK_DEV_LOOP=m but s2disk seems to work properly)

For more information about kernel configuration file parameters required by uswsusp, you can consult the uswsusp Howto which is stored in /usr/share/doc/uswsusp/HOWTO.gz.

Note: Should you need to perform any adjustment to your kernel configuration file, please make a backup before doing so.

9. Edit your /boot/grub/menu.lst file to add boot option required by uswsusp:

Code: Select all

gksu gedit /boot/grub/menu.lst
Add resume=/dev/sdxn boot option, where sdxn is your swap partition. For example, since my swap partition is /dev/sdb8, my final menu.lst file now looks like this:

## ## End Default Options ##

title Linux Mint, kernel 2.6.24-16-generic
root (hd1,8)
kernel /boot/vmlinuz-2.6.24-16-generic root=/dev/sdb9 rootflags=data=writeback ro quiet splash resume=/dev/sdb8
initrd /boot/initrd.img-2.6.24-16-generic

title Linux Mint, kernel 2.6.24-16-generic
root (hd1,8)
kernel /boot/vmlinuz-2.6.24-16-generic root=/dev/sdb9 ro quiet splash
initrd /boot/initrd.img-2.6.24-16-generic

title Linux Mint, kernel 2.6.24-16-generic (recovery mode)
root (hd1,8)
kernel /boot/vmlinuz-2.6.24-16-generic root=/dev/sdb9 ro single
initrd /boot/initrd.img-2.6.24-16-generic

title Linux Mint, kernel memtest86+
root (hd1,8)
kernel /boot/memtest86+.bin

### END DEBIAN AUTOMAGIC KERNELS LIST

10. Reboot your computer.
11. Once you're back in the Gnome desktop, check if the kernel gets the boot option:

Code: Select all

dmesg | grep command
If you see resume=/dev/sdxn boot option in the output line, proceed to the next step. This is what I get by entering the above command, for your reference:

[ 0.000000] Kernel command line: root=/dev/sdb9 rootflags=data=writeback ro resume=/dev/sdb8

12. Test if hibernate works:

Code: Select all

s2disk
Your computer should now be on its way to hibernation. It's hibernated once the power supply turns off. <=not that I underestimate your intelligence :lol:

Note: if you see an error message “s2disk: Could not lock myself. Reason: Cannot allocate memory” by entering the above command, then try:

Code: Select all

sudo s2disk
13. Turn your computer back on and to see if your desktop session is restored the way it was right before the hibernation. If it is, then congratulations! You now have hibernate.

14. You now have to make the s2disk command get invoked when you initiate hibernation from System > Quit > Hibernate (or by pressing an appropriate button on your laptop/desktop case). To do that, we have to edit one more file.

First, make a backup copy of the file you're going to edit:

Code: Select all

sudo cp /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux.bak

Edit the file /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux:

Code: Select all

gksu gedit /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux
Add the following line into it, right below #!/bin/sh and delete everything else except exit $RET:

Code: Select all

/sbin/s2disk
See mine for reference:

Code: Select all

#!/bin/sh 
/sbin/s2disk
 
exit $RET
Finally, Go to System > Quit . . . > Hibernate. And click on Hibernate.

That was how I got hibernate working on some machines. Good luck! :D

Additional informations:
1. If your computer goes into hibernation without completely powering off, you may want to try the solution offered by cbaltar2. Simply read the succeeding posts in this page and you should spot it easily.
2. Some of you may see minor glitches when your computer comes out of hibernation, such as window title bars and decorations turning white/gray or nautilus opening up windows for attached removable drives. Please check page 2 of this thread to see some safe ways to workaround them.
Last edited by garda on Fri Nov 04, 2011 11:10 am, edited 6 times in total.
Reason: Amended title to make it clear its a How-to Guide
garda

Spam Alert!

Post by garda »

Man, this forum's increasingly getting more spams from time to time.
Husse

Re: Spam Alert!

Post by Husse »

garda wrote:Man, this forum's increasingly getting more spams from time to time.
If you report the spam I'll remove it as soon as I can
cbaltar2

Re: Getting Hibernate to Work with Nvidia Restricted Drivers

Post by cbaltar2 »

This is neat and thanks for all your work to come up with this! Basically everything works, except that when I run sudo s2disk at the end, the computer "hibernates" without powering off - it writes something to disk, then stops and never turns off. Pressing the restart button then restores the system to its original condition, as if it had hibernated correctly :? . So basically, I'm hibernating without power off, which is not true hibernation. Any suggestions?

Thanks,
Cristian
cbaltar2

Re: Getting Hibernate to Work with Nvidia Restricted Drivers

Post by cbaltar2 »

Okay, I think I fixed it - I unloaded the Nvidia driver, which allowed me to read the following error message after issuing s2conf:

Code: Select all

suspend_device(): usb_suspend +0x0/0x30 [usbcore]() returns -32
So before hibernating I unloaded the ehci_hcd driver:

Code: Select all

sudo modprobe -r ehci_hcd
then hibernated with

Code: Select all

 sudo pm-hibernate
Seeing hibernation works now with me getting full power off, I reloaded the Nvidia driver, and the fix still works, so I'm good. I'm going to make a script to make this automatic, or I might even modify the action of the Hibernate button in the gui.

Thanks,
Cristian
garda

Re: Getting Hibernate to Work with Nvidia Restricted Drivers

Post by garda »

I'm sorry all, for this very late reply.
Husse wrote:If you report the spam I'll remove it as soon as I can
I'll report if I found one and thank you for deleting that one.

cbaltar2,

It's good to know you managed to fix the problem yourself and thank you for adding more information to this How-to. I appreciate it.
I suppose you're using a different version of nVidia restricted driver (nvidia-glx), am I right?
I tested your solution on two different computers running nvidia-glx driver version 96.43.05, both managed to hibernate but failed to resume.
But thanks again for adding those informations, I'm sure someone will find them useful.
Husse

Re: Getting Hibernate to Work with Nvidia Restricted Drivers

Post by Husse »

Linus Torvalds claims he has solved the resume problem
http://torvalds-family.blogspot.com/200 ... again.html
Old Marcus

Re: Getting Hibernate to Work with Nvidia Restricted Drivers

Post by Old Marcus »

I've managed to Hibernate fine on nvidia drivers... :?
cespinal

Re: Getting Hibernate to Work with Nvidia Restricted Drivers

Post by cespinal »

okay... Im sorry to say this... but after upgrading to mint 6, having my laptop broken, going back to mint 5 and setting everything ok in 2 hours, I went to fix suspend and hibernate again, but using this tutorial this time around and I ended up breaking my x.org file :( . Now mint will say it canrt detect my display and drivers, forcing me to use de computer in low graphics mode...

its so irritating!!.. would you please help me?
garda

Re: Getting Hibernate to Work with Nvidia Restricted Drivers

Post by garda »

Can you post your xorg.conf?

And, to make sure of something, please post the output of this command:

Code: Select all

dpkg -l nvidia* | grep ^i
Husse

Re: Getting Hibernate to Work with Nvidia Restricted Drivers

Post by Husse »

@ garda
What's the purpose of dpkg -l nvidia* | grep ^i ?
The results for nvidia that does not contain i ?
garda

Re: Getting Hibernate to Work with Nvidia Restricted Drivers

Post by garda »

So I can see what nVidia-related packages installed on his computer, along with their version(s). On one of my machines, entering the above command gives this kind of output:
ii nvidia-glx 1:96.43.05+2.6.24.14-21.51 NVIDIA binary XFree86 4.x/X.Org driver
ii nvidia-kernel-common 20051028+1ubuntu8 NVIDIA binary kernel module common files

So in other words, the "^i" part is to display only the results starting with "i" (pay attention to "ii" that precedes both output strings above).
Husse

Re: Getting Hibernate to Work with Nvidia Restricted Drivers

Post by Husse »

Damn it - I have to read up on ^ which I don't find on my keyboard (except as in hôtel)
I thought it was a negation meaning "does not contain the character after it" (in this case i)
No use for ATI though, lots of things like Configuration and all lines begin with ii when I tested " dpkg -l | grep ati
" :) (without the "^i" part)
cespinal

Re: Getting Hibernate to Work with Nvidia Restricted Drivers

Post by cespinal »

garda wrote:Can you post your xorg.conf?

And, to make sure of something, please post the output of this command:

Code: Select all

dpkg -l nvidia* | grep ^i
all rite here I go

Code: Select all

# xorg.conf (X.Org X Window System server configuration file)
#
# This file was generated by failsafeDexconf, using
# values from the debconf database and some overrides to use vesa mode.
#
# You should use dexconf or another such tool for creating a "real" xorg.conf
# For example:
#   sudo dpkg-reconfigure -phigh xserver-xorg

Section "Screen"
	Identifier	"Default Screen"
	Device		"Configured Video Device"
	Monitor		"Configured Monitor"
	SubSection "Display"
		Depth	24
		Virtual	640	480
		Modes		"640x480@60"
	EndSubSection
	Option		"AddARGBGLXVisuals"	"True"
	Defaultdepth	24
EndSection

Section "Screen"
	Identifier	"screen1"
	Device		"device1"
	Monitor		"monitor1"
	Option		"AddARGBGLXVisuals"	"True"
	Defaultdepth	24
EndSection

Section "Device"
	Identifier	"Configured Video Device"
	Boardname	"nvidia"
	Busid		"PCI:1:0:0"
	Driver		"nv"
	Option		"NvAGP"	"1"
	Option		"nologo"	"1"
	Screen	0
EndSection

Section "Device"
	Identifier	"device1"
	Boardname	"NVIDIA GeForce 7 Series"
	Busid		"PCI:0:18:0"
	Driver		"nvidia"
	Screen	1
	Vendorname	"NVIDIA"
EndSection

Section "InputDevice"
	Identifier	"Generic Keyboard"
	Driver		"kbd"
	Option		"XkbRules"	"xorg"
	Option		"XkbModel"	"pc105"
	Option		"XkbLayout"	"us"
	Option		"XkbOptions"	"lv3:ralt_switch"
EndSection

Section "InputDevice"
	Identifier	"Configured Mouse"
	Driver		"mouse"
	Option		"Emulate3Buttons"	"true"
EndSection

Section "InputDevice"
	Identifier	"Synaptics Touchpad"
	Driver		"synaptics"
	Option		"SendCoreEvents"	"true"
	Option		"Device"	"/dev/psaux"
	Option		"Protocol"	"auto-dev"
	Option		"HorizEdgeScroll"	"0"
EndSection

Section "ServerLayout"
	Identifier	"Default Layout"
  screen 0 "Default Screen" 0 0
	Inputdevice	"Synaptics Touchpad"
EndSection

Section "Module"
	Load		"GLcore"
	Load		"v4l"
	Load		"dri"
EndSection

Section "Monitor"
	Identifier	"Configured Monitor"
	Vendorname	"Plug 'n' Play"
	Modelname	"Plug 'n' Play"
  modeline  "640x480@60" 25.2 640 656 752 800 480 490 492 525 -vsync -hsync
	Gamma	1.0
EndSection

Section "Monitor"
	Identifier	"monitor1"
	Gamma	1.0
EndSection

Section "Extensions"
	Option		"Composite"	"Enable"
EndSection
and... the output of the command you said

Code: Select all

ii  nvidia-glx-new                             169.12+2.6.24.14-22.53                   NVIDIA binary XFree86 4.x/X.Org 'new' driver
ii  nvidia-glx-new-dev                         169.12+2.6.24.14-22.53                   NVIDIA binary XFree86 4.x/X.Org 'new' driver
ii  nvidia-kernel-common                       20051028+1ubuntu8                        NVIDIA binary kernel module common files
ii  nvidia-new-kernel-source                   169.12+2.6.24.14-22.53                   NVIDIA binary 'new' kernel module source
ii  nvidia-settings                            1.0+20080304-0ubuntu1.1                  Tool of configuring the NVIDIA graphics driv
I'll just wait here :P thanks in advance
garda

Re: Getting Hibernate to Work with Nvidia Restricted Drivers

Post by garda »

I've been trying to recreate the problem you're experiencing without success. Meaning, everything I've done to my xorg.conf doesn't give me the error message you mentioned. That said, I'm under the impression that you blindly copy-pasted the modified xorg.conf sample that I put in the tutorial, which was generated for a GeForce4 Ti card (AGP) that's attached to a single monitor. So below are some possible workarounds I have in mind for now:

- Try to remove:

Code: Select all

Option      "NvAGP"   "1"
if you know for sure that your GPU operates on PCI-E bus.

- If that doesn't change the situation, execute this command from the Terminal:

Code: Select all

sudo nvidia-xconfig
to revert to nVidia's default xorg.conf.

- Alternatively, you can execute the following command from the Terminal:

Code: Select all

sudo nvidia-xconfig -o /etc/X11/xorg.conf.xconfig
to tell nvidia-xconfig to save the default xorg.conf to a different file (xorg.conf.xconfig) instead of overwriting the one currently in use. From here, you can then compare your current xorg.conf with the one generated by nvidia-xconfig and see which options don't belong to your xorg.conf.

- Then try to change your monitor model and resolution in "Screens and Graphics" applet (Applications > Other > Screens and Graphics) or, if it's not there, call it from the terminal:

Code: Select all

gksu displayconfig-gtk
Hope that helps and let me know how it turns out.
Husse wrote:No use for ATI though, lots of things like Configuration and all lines begin with ii when I tested " dpkg -l | grep ati
" :) (without the "^i" part)
Yes, ATI restricted driver installs more packages and troubleshooting ATI driver issues generally brings along greater headache. Or perhaps it's just because of my lack of experience in dealing with ATI cards. :)
cespinal

Re: Getting Hibernate to Work with Nvidia Restricted Drivers

Post by cespinal »

All rite! after struggling a lot with the xorg file, I just decided to start over:

Reinstalled mint and got it up and running full in an hour (it gets easier everytime :D). Then I read this tutorial more carefully and got hibernate and suspend working correctly after several trials.

There are a couple of nicks tho:

On both suspend and hibernate, the system wakes up opening nautilus on any removable media I may have attached. Not a big deal... I just have to close the opened windows

Upon waking up from suspend, the windows previously opened before putting the pc to sleep show no borders or decorations, just plain white. Since the window buttons are still functional (although invisible) I just have to click on the upper right corner of each window to close them and then reopen them to get the decorations back.

Are these treatable? :wink:
garda

Re: Getting Hibernate to Work with Nvidia Restricted Drivers

Post by garda »

Hi Cespinal,

Glad to know you could sort it out! :D

I need some time to figure out a way to remedy the glitches you mentioned (maybe a few days) as there's only one machine I have unlimited access to that runs nvidia-glx version 169.xx. To make matters worse, hibernation and STR have been working right out-the-gate since day one without tinkering there.

I'll update this thread once I get the cure.

Oh, one more thing. I think it'll make it easier for me if you could post the link to the tutorial/how-to you followed earlier. You know, the one you used before this.
Fred

Re: Getting Hibernate to Work with Nvidia Restricted Drivers

Post by Fred »

garda,

Good thread.

Thank you. :-)

Fred
cespinal

Re: Getting Hibernate to Work with Nvidia Restricted Drivers

Post by cespinal »

Hey!, thank you very much for putting your efforts on this... so far I feel very satisfied with my Mint system thanks to the community

here is the link: https://help.ubuntu.com/community/Nvidi ... verSuspend
garda

Re: Getting Hibernate to Work with Nvidia Restricted Drivers

Post by garda »

Alright, after a few hours worth of trials and errors, here are several workarounds I can offer. They are not actually fixes in the truest sense, but will hopefully reduce some of the inconveniences you are experiencing nonetheless.

1. White/gray title bar and window borders upon resuming.
This glitch is caused by compiz-decorator being unable to correctly render metacity graphics upon waking up from suspend/hibernate due to a bug in nvidia-glx. There is no known universal fix as far as I know but there are some workarounds you can safely try:

1.A. Manually reload compiz-decorator upon waking-up from suspend/hibernate.
- Open Advanced Desktop Effects Settings (Control Center > Advanced Desktop Effects Settings).
- Go to 'General Options' > Commands tab.
- Find any unused command slots (empty box) under 'Commands' and type into the box:

Code: Select all

/usr/bin/compiz-decorator --replace
- Scroll down to 'Key bindings' section and assign a shortcut key to execute the above command (example: SUPER+F1).

Now you simply have to press SUPER+F1 (SUPER=WinKey/Start Menu key) after resuming from suspend/hibernate to get the window decorations back. No need to close and reopen the windows.

1.B. Replace Metacity with any other window manager/decorator.
There are tons of Gnome-compatible window managers/decorators you can choose from, but I think most users are happy with Emerald. To do that:
- Run in the Terminal:

Code: Select all

sudo apt-get install emerald emerald-themes
to install Emerald and some Emerald themes.
- After the installation is completed, open the Run Application dialog (default: ALT+F2) and enter the following command:

Code: Select all

emerald --replace
- You can change the Emerald theme by going to Control Center > Emerald Theme Manager.
- Test to see if Emerald exhibits the same glitch by hibernating/suspending your machine and wake it back up.

If you wish to use Emerald permanently, you can tell Compiz to execute it instead of Metacity:
- Go to Control Center > Advanced Desktop Effects Settings > Window Decoration.
- Enter the following into the 'Command' box:

Code: Select all

emerald --replace
2. Nautilus opening up windows for attached removable drives upon resuming from hibernate/suspend.
This is caused by HAL issue of some sort and is an upstream from either Ubuntu or Debian. There is no known safe fix known to me. You can, however, change Nautilus' setting in order to keep it from autonomously opening up windows upon waking up from hibernate/suspend:

- Open Nautilus.
- Go to Edit > Preferences > Media.
- Remove the check mark next to 'Browse media when inserted'.
- Click Close.
Post Reply

Return to “Tutorials”