Suspend2 brings to the Linux world the ability to suspend the current working state of the computer to hard disk, and power off the machine, then restart it to the exact same state where you left off. This is similar to the ability of Windows machines to hibernate, and is invaluable to laptop users; when your battery is about to run out, you can save your work in progress. After a while, I have found it helps my productivity enormously, because I can save my "mental state" in the layout of windows and browser tabs I have open, and restore a better summary of what I was working on at the time I had to leave the computer, without taking notes and bookmarking all the bits that I was in the process of researching.
Suspend2 differs from the suspend functionality built into the kernel in that it supports up to 4 GB of memory, compresses the save image while writing to the disk, and supports suspend to file and splashscreen integration (but this tutorial does not cover these last two.) It also is rumored to support SMP, but we have not yet gotten that functionality working. In addition, it just flat works on a whole bunch of machines and configurations that seem to cause the original suspend to fail.
This patch as modified might not function on clustered computers, but you could argue that it doesn't make much sense there. Also, there was a bit about Toshiba laptops I just had to guess at. I don't have either of these systems to test it on, so feel free to give feedback.
Problems with the modified patch should be directed to me, and not Nigel at suspend2.com. He knows I have been hacking on his patches, but I'm still responsible for any mess I've made of his code.
HOW TO:- Get the networking working properly, so that you can perform apt-get update.
- Start a terminal window from the menu, Applications->Accessories->Terminal
- Login as root
Code:
sudo -s
# enter password
- Install the kernel source and the tools to build it
Code:
apt-get -y install build-essential bin86 libncurses-dev alien
apt-get -y install linux-tree-2.6.12
cd /usr/src
- Download patched Suspend2
Code:
wget http://ubuntu.griffin3.com/software-suspend-2.1.9.9-for-2.6.12-ubuntu5.10.tar.bz2
wget http://www.suspend2.net/downloads/all/hibernate-1.12-1.i386.rpm
wget http://www.suspend2.net/downloads/all/suspend2-userui-0.5.1.tar.gz
- Unpack the lot
Code:
tar -xjf software-suspend-2.1.9.9-for-2.6.12-ubuntu5.10.tar.bz2
tar -zxf suspend2-userui-0.5.1.tar.gz
tar -xjf linux-source-2.6.12.tar.bz2
ln -s linux-source-2.6.12 linux
cd /usr/src/linux
- Install gcc-3.4 required by kernel
Code:
apt-get -y install gcc-3.4.5
CC=gcc-3.4
export CC
- Patch the kernel
Code:
cp /boot/config-2.6.12-9-386 .config
make oldconfig
../software-suspend-2.1.9.9-for-2.6.12-ubuntu5.10/apply
- Find your IDE chipset and swap partition--remember these
Code:
lspci | grep 'IDE'
fdisk -l | grep 'swap'
- Configure the kernel
Code:
make menuconfig
# General setup --->
# (-hibernate) Local version - append to kernel release
# Power management options (ACPI, APM) --->
# [ ] Software Suspend (EXPERIMENTAL)
# <*> Software Suspend 2 --->
# <*> Swap Writer
# (swap:/dev/hda3) Default resume device name
# Device Drivers --->
# ATA/ATAPI/MFM/RLL support --->
# <*> ATA/ATAPI/MFM/RLL support
# <*> Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support
# <*> Include IDE/ATA-2 DISK support
# <*> generic/default IDE chipset support
#===This will work, but speed is 5-7x faster with specific chipset support
# <*> ALI M15x3 chipset support #===your IDE chipset
# File systems --->
# <*> Ext3 journalling file system support
# Cryptographic options --->
# <*> LZF compression algorithm
#===This is a good time to set the processor type, if desired [optional]
# Processor type and features --->
# Processor family (Athlon/Duron/K7) #===your processor
- Install text-mode userui
Code:
cd /usr/src/suspend2-userui-0.5.1
make suspend2ui_text
cp -p suspend2ui_text /usr/local/sbin
- Install hibernate script and configure
Code:
cd /usr/src
alien -i hibernate-1.12-1.i386.rpm
gedit /etc/hibernate/hibernate.conf
# -> ImageSizeLimit nocache
# -> ProcSetting expected_compression 50
# add-> ProcSetting userui_program /usr/local/sbin/suspend2ui_text
# -> SwitchToTextMode no
- Set power button to hibernate
Code:
gedit /etc/acpi/events/powerbtn
# -> action=/usr/sbin/hibernate
# -> #action=/etc/acpi/powerbtn.sh
/etc/init.d/acpid restart
- Compile the kernel (get lunch now, takes about an hour on my AMD1700)
Code:
cd /usr/src/linux
make bzImage install modules modules_install
#cd /boot
#rm config vmlinuz System.map #optional: remove extra links, less clutter for grub
update-grub
- Read note below about restricted kernel modules, if you are using them: these include madwifi for wireless cards, fglrx for ATI video, and nVidia video cards
- Reboot to load the new kernel
Pressing the power button should now cause hibernation! If the power button does not work on your laptop, in a terminal type:
After hibernating successfully, you can see some statistics by typing
Code:
sudo cat /proc/software_suspend/debug_info |grep 'compression\|speed'
In particular, if the disk read/write speed is about 5 MB/s or less, you probably do not have the correct IDE chipset driver installed, and are using the generic drivers. My speeds on this elderly eMachines laptop are ~35MB/s write, ~45MB/s read with the ALi drivers compiled into the kernel.
Most common failing is not getting all of the IDE drivers (and ext3 filesystem) compiled into the kernel during make menuconfig. If these are left out, the system will give a "Big Fat Error" on boot, or a "Kernel Panic". If you have to adjust any of these, the re-compile goes much faster, because it only has to compile the changes (step 14).
Any errors in the "patching the kernel" (step 8) are mine, and Nigel won't want to hear about them. I've tested this on the base Ubuntu kernel, without much added into it, and with the 386 and k7 switches applied. Errors on boot might be the result of missed steps (say, putting swap=/dev/hda3 instead of swap:/dev/hda3 in the Default resume device name, my personal nemesis). Looking through the mailing lists on suspend2 might be able to help, but we should be able to troubleshoot the Most Frequent Misteaks in this thread, check there first.
Finally, you might be tempted to install the fbsplash userui for suspend2. You are completely on your own there. It has been reported to completely gum up suspend-to-ram, and slow down the hibernation process greatly. The textmode is more trustworthy, and this eMachines 5309 with 512MB RAM hibernates in 6 seconds, and wakes in 8. It's not worth the instability for something that will just flash on the screen for 2/3 of that time; and anyway, that's why you prefer Ubuntu to Windows anyway, it doesn't hide the delicate inner workings of the system from you. Right? Right?
NOTE re: linux restricted modules
When you recompile the kernel, you can no longer use any of the Ubuntu linux-restricted-modules packages, so you will have to compile these on your own. These are best done before you reboot the computer, or something will be missing when it comes back up again. And if you do it this way, the modules will have the same internal version (-hibernate) as the kernel. I should be posting a HOWTO: for the madwifi here soon, because I had to do it myself.
Bookmarks