Home > Articles > Operating Systems, Server > Linux/UNIX/Open Source

  • Print
  • + Share This
Like this article? We recommend Sleep States

Sleep States

Netbook operating systems have three sleep states that are of interest to us in the context of this series:

  • Suspend (S3). This state simply preserves the contents of DRAM. It puts that DRAM into a low-power state and shuts down as much of the rest of the computer as possible. When you return from the suspend state, you can continue where you left off. This will probably work overnight, as long as you can get AC power back to your computer in the morning to run the computer and recharge the battery. If you don't, you may reboot to a major filesystem problem.
  • Hibernate (S4). This state saves the content of your DRAM to the hard drive and shuts down the computer completely. When shut down, the computer consumes no battery power. When you turn on the computer again, it will reboot to the desktop, and you can continue where you left off, with an intact filesystem.
  • Suspend-hybrid (S4, then S3). This state combines the suspend and hibernate states. This is the state that I use and recommend for netbook/laptop users. If you leave the computer in suspend state and it runs out of battery power, it will resume to the hibernate state, and you can continue where you left off. This option helps if you're away from your netbook for a lot longer than you expected—you don't have to worry about fouling up the filesystem when the battery runs out. The tradeoff is that you have to wait a couple of minutes for the hibernate DRAM save to complete before you can reopen the computer. However, since this state is most likely to be invoked by a user who puts a computer to sleep by closing the lid and putting the machine away overnight, I see no problem. This article tells you how to set up this state on your computer, as well as using the more conventional hibernate setup.

This technique doesn't work for Linux SSD netbook users who are running without swap, because the swap partition is where the hibernate state writes the contents of DRAM before the computer shuts down. If there is no swap partition, when the computer tries to hibernate, that data goes into the void. What results is essentially a computer that was shut down by flipping a power switch, rather than one that was shut down in an orderly manner—the result is frequently a mess in the filesystem.

The hibernate method that I demonstrate in this article writes the contents of DRAM to a "swap file" created by the user in "userspace"—that is, an ordinary userspace file dedicated as a swap file, not a drive partition. ("Swap file" is in quotes here because you don't use this option for ordinary virtual memory swapping.)

The swap file in this technique can live in any filesystem the computer can access during boot. In this article, given that the SDHC flash card in my Eee PC's internal card reader (in which my OS lives) is only 8GB, I show how to put the swap file into the internal SSD I use for mass storage. If you have the OS running in a separate flash drive from the main mass memory, as some vendors have configured their netbooks, this approach can be adapted to put the file into an internal flash drive.

This procedure was created on an Eee PC 900 running a conventional Kubuntu-Jaunty 9.04 KDE distribution.

  • + Share This
  • 🔖 Save To Your Account