Archive for June 9th, 2006

AT LAST: laptop sleep on Linux

At last! After years of fighting with Linux and laptop sleep (suspend-to-RAM), I finally got it working on this LinuxCertified LC2430 laptop. I have tried many times in the past to make it work, but it wouldn’t wake up properly. I decided to try make it work for a last time, as Linux.com posted a nice guide recently (written by a fellow Greek). I followed the instructions to the letter, but again, the laptop would go to sleep but wouldn’t wake up properly…

Thankfully, the solution was in the comments! A guy said that in order sleep to work with his Radeon, he had to pass a kernel parameter during boot time (on Lilo or Grub): acpi_sleep=s3_bios. My laptop also uses a Radeon (9200 — I use the r200 xorg driver) and after I added this parameter and rebooted, it worked!!!

I have since made some changes to the article’s suspend.sh file in order to work better with my Linux distribution, Arch Linux (I put network to sleep and I use vbestate to save the graphics card’s state instead of the Temp file the author of the article used). If you are using Arch, just use the instructions on the article linked above (for suspend-to-ram, not hibernate) and then use my suspend.sh instead of the article’s. All the tools needed for my modified script (hdparm & vbetool) are part of the main Arch repositories and are easily installable via ‘pacman’. You can choose to unload more kernel modules (and then load them again after wake-up in the script) so you save even more battery (Linux is not as good as Windows/OSX in saving enough battery while on sleep).

#!/bin/sh
/etc/rc.d/network stop
/usr/sbin/vbetool vbestate save > /etc/acpi/vbestate
chvt 1
sync
hdparm -y /dev/hda
echo -n mem > /sys/power/state
hdparm -a1024 -c3 -d1 -m16 /dev/hda
/sbin/hwclock --hctosys
/bin/cat /etc/acpi/vbestate | /usr/sbin/vbetool vbestate restore
chvt 7
/etc/rc.d/network start

I must note though that the system is kinda slower when it wakes up. Wake up from sleep on Linux is known to create weird problems. I might need to unload a few modules manually and then reload them, just to make sure…