A modern PC takes AGES to boot! And Linux is not the fastest OS around in this regard. As this is rather anoying and seriously influences the WAF, something must be done.

If keeping the PC on is not an option (it costs a fortune in electricity), the power must be suspended somehow. Several methods exists to do this:
  • Off by switching the wall plug. Most energy effective, but hard to integrate with a remote control. 0 Watt. Requires full boot
  • S0 or ATX stand-by. The way you normally shut down and power off a PC. This requires a full reboot to come back from. PSU on standby, 1-10 W.
  • S1 or soft stand-by. The way a desktop PC normally goes to standby: Turns off the monitor and the harddrive, but the CPU and the fans remain on. Only saves around 15% and not an option for us. Instantly-on.
  • S3 or Suspend-to-RAM. The system turns off the power to everything but the RAM. The entire system state is thus saved. When activated, the system is running as before in typical a few seconds. PSU on standby + some more, 5-15 W. The system will not survive a complete power off (power outage).
  • S4 or Suspend-to-disk or Hibernate. In princible, the system RAM is saved on disk and the PC is powered off. When powered on again, the system has to go through a BIOS bootup before the OS can load and read in the RAM image, so the boot time is about 30 seconds. Further more, the shut down time is also significant. The system need a swap-partition for the image at least twice the size of the memory, and thus a disk, but it can be done on an USB stick. The PSU is on standby and can be switched off without loosing the state.

  • With a modern energy-efficient motherboard and PSU, the speed of the S3 mode is perfect for an HTPC. My system is on faster than any DVD-player I have seen.

    Suspend-to-Ram (S3)

    The problem with S3 is that it needs hardware-support.

    I originally had an AsRock motherboard K7VT6, which was unable to get to S3, suspend to RAM, only to S1, suspend. The difference is that in S1, only the screen and harddrives are powered down, saving about 10% only. Due to this and to HD decoding performance, I switched to another AsRock board and a Core 2 Duo (E6550) processor. But this was also not able to reach S3. I realised that AsRock is not the way to go for S3.

    Now I have an Asus P5K-V with an Intel G31 chipset - and this works fine. It powers down the fans, the LCD and everything but the power-on LED, which blinks. I seriously consider detaching this, as it is a quite innoying blue colour..Edit: It has now been done ;-)

    The software is contained in the hibernate package and dependencies. It is actually a collection of scripts to try various method and is easily modified. I have not been able to get the hibernate main script itself to work - it complains about the nvidia driver not unloading. Luckily, taking the second option in the script s2ram -f in stead works perfectly - the -f being because it does not recognize the machine.

    But something more had to be fixed, as the remote control driver had to unload in order for the system to be turned on by the remote control. The ALSA sound system also needed a kick. Further more, open streaming programs would fail when the system came back on. In the end, I created a small script, mysuspend, which would take care of any systems that needed to be shut down before suspending, and then restarting them if necessary after resume:

    Note that the automatic shut-down of various streaming programs is done in /etc/init.d/lirc, see here.

    The good thing about it is all the things that just worked out of the box:
  • CIRF/SMB and NFS mounts had no problems - including the root file system, which is an NFS (I'm using PXE network boot)
  • The nVidia card has no problem suspendning ad resuming
  • Network and wireless keyboard and mouse was no problem

  • I had some occasional problems when using kernel 2.6.21:
  • The PC would occasionally not resume after a suspend, but seems to just hang, needing a hard reset. It was typically after suspending for a long time, and I was beginning to suspect the power to have failed, and was actually thinking to applying an UPS to solve the problem.
  • Quite often the Xorg would go to 100% CPU usage (on one core only) after resume. This did not keep me from starting and running various applications, but especially MythTV would use minutes to startup as the prescaling theme items suddenly was very slow. The solution was to shut down Xorg (Ctrl-Alt-Backspace) and then restart it (startx) - this was much faster than waiting for MythTV to start up!

  • But going for kernel 2.6.24 resolved this completely! So it is strongly recommended to upgrade the kernel..

    Power button

    In order to get the power button on the enclosure to also suspend the PC rather than to shut it down (as the default setup is doing), you need to have the ACPI package installed (which you probabaly already have) and to change the file /etc/acpi/powerbtn.sh into e.g. this. The important stuff here is the reference to the mysuspend script rather than the call to shutdown.
    You can still hold in the button for four seconds to do a hard power-down.