You are not logged in.

#1 2005-10-01 17:57:50

mezoko
Member
Registered: 2005-03-26
Posts: 310
Website

Suspend 2 Ram Guide (Like MS Sleep Feature in Windows)

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. pacman -S 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.


"The only thing we have to fear is fear itself." - Franklin D. Roosevelt

Offline

Board footer

Powered by FluxBB