• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

Sign in to follow this  

[howto] Suspend 2 Ram Guide

Recommended Posts

msg43    0

Suspend 2 Ram Guide

Requirements:

  • 1.Kernel 2.6.* with Sleep States
Power Management Opitions -> Acpi -> Sleep States


2.Vbetool

I think any 2.6.* kernel will work I am not sure

Setup:

  • 1. Make sure you have a kernel with Sleep States Compiled in. Any arch stock kernel should do.
    2. Get or Compile vbetool

Making the Script:

You now need to make a script that will unload your modules, save the video card state, restore modules on resume, etc....

Here is my script hopefully it pretty straight foward:

#!/bin/sh
# Initiates a suspend-to-ram!

# Suspend
echo "Going to sleep at `date`"

##Let's go to Terminal 1 (Ctrl+Alt+1)
echo "* chvt 1"
/usr/bin/chvt 1

##Close Programs

##I have session saver for firefox
if [ `pidof firefox-bin` ]; 
	then killall firefox-bin; 
	else echo "Firefox-bin is not running";
fi


##The Sound Module won't unload when applications are using the sound
killall xmms

if test -e /var/run/daemons/mpd.pid; 
	then /etc/rc.d/mpd stop; 
	else echo "Mpd is not Running"; 
fi



## Stopping the Network
if test -e /var/run/daemons/network;
	then /etc/rc.d/network stop;
	else echo "Network is not Running";
fi

##Save Alsa Mixer Settings and give all the programs 2 secs to finish shutting down.
alsactl store
sleep 2

## Unload Modules [snd_emu10k1 = sound 8139too = network]
rmmod snd_emu10k1
rmmod 8139too

#Save Video State
echo "* save vbestate"
/usr/sbin/vbetool vbestate save > /etc/acpi/vbestate
echo "* writing to /sys"
echo -n "mem" > /sys/power/state
echo ""

# Resume
echo "Back from sleep at `date`"

##Restore the state of the Video
echo "* restore vbestate"
/bin/cat /etc/acpi/vbestate | /usr/sbin/vbetool vbestate restore

##Lets restore the clock
echo "* restore clock"
/sbin/hwclock --hctosys

##Lets get back to Xorg (Ctrl+Alt+1)
echo "* chvt 7"
/usr/bin/chvt 7

##Load Modules
modprobe snd_emu10k1
modprobe 8139too

##Give the modules some time to learn
sleep 5

##Load Programs
/etc/rc.d/network start
alsactl restore
/etc/rc.d/mpd start


echo "* done"
echo ""

# Done
exit 0

You must edit this script if you want to use it!!!

The chance that you have the same modules and setup as me are extremely slim.

Note: Firefox uses the sound module and prevents unloading of it.

Note 2: Orginally written for Arch Linux should work on any distro.

Share this post


Link to post
Share on other sites
mr_demilord    0

I think this should be in the HOWTO section . :drool:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.