Configuring Standby on your HTPC

My main HTPC uses around 130 watts at idle, 7 watts in standby (S3), and 4 in hibernate (S4) so the case for having it take a nap whenever it can is quite clear.  There was a time when getting S3 standby working properly was a black art involving careful motherboard and device selection, regsitry hacks, and some pixie dust.  When Vista came out and even low-end motherboards included full standby support all of that changed; setting up your PC to properly take a nap, and wake up when you need it, is something anyone with a few minutes can do.

Before going any further lets take a moment to define the PC’s power states:

  • S0: On
  • S1: CPU and most components receive power, CPU doesn’t execute any instructions and the hard drives should power down
  • S2: CPU stops receiving power
  • S3: Standby, only RAM is powered (USB devices and NIC should be in a lower power state)
  • S4: Hibernate, RAM is no longer powered so the contents of RAM are written to the hard drive 
  • S5: Soft off, only devices that can turn the PC back on are powered (i.e. the NIC if WOL from S5 is enabled)

Depending on your use case either S3 or S4 are good choices for saving power.  S4 will save a few watts vs. S3, but requires a full POST and about 15-20 seconds more beyond that do be fully functional, where resuming from S3 only take a few seconds.  Given that, I opt to use S3 for my HTPC and a combination of S3 and S4 for the other PCs at my house.

Configuration:  

The first step is to make sure that that BIOS is configured properly.  Every OEM’s BIOS is slightly different, but the idea is always the same.  There should be a option group for power managment; in this case (Gigabyte) it’s a option on the main page, on my dev box (Asus) it’s a tab on the top of the screen.

Usually there’s just two options S1 and S3 but some boards also have an “Auto” option.  In my experience Auto is the same as S3, but since that’s what we want anyway there’s why not to be explicit.  Below are some configuration screens from three different vendors.

Asus:

asus s3 bios

Intel:

intel s3 bios

Gigabyte:

s3 bios image

We are going to enable wake on lan (WOL) later so as long as we’re here, let’s make sure that the BIOS is setup correctly for that.  Again this isn’t a one size fits all setting; in most cases we need to enable PME (like Gigabyte).  The other cases I’ve seen have an explict WOL setting, or like this Asus board the setting is split across PCI/PCIe devices.

ASUS PME

Now that the BIOS is set to enable S3 stanby and let us wake the PC when we need it, save the settings and boot into Vista (or 7 which is almost exactly the same).  Power settings are found in the control panel under “Power Options”.  I like to work off of the “Balanced” plan, but there are some other plans available if you’d like to choose a different baseline.  There are several ways to change the settings we’re after, but instead of hiting them one at a time, we’ll just go to the master list and make them all in one place.

S3 Bios Setting

Select “Change plan settings” to get to the most basic set;the display and system idle timers.  I usually use very agressive idle timers (10/30) on my regular PCs (dev box, laptop, Sage client) and slightly less so on the main [server] HTPC (20/60).  There are some drawbacks to going too far in either direction, so you really need to find the right setting for your environment.  Too short and the PC goes to sleep while you take a break, to long and it never goes down since there’s a recording coming up.  When you’re ready select the “Change advanced power settings”.

S3 Bios

To get the full list select “Change settings that are currently unavailable” (not shown) before moving to the next step.  While I have a password defined for the user account on my HTPC, I don’t want to ever have to enter it manually.  While it’s bad policy to do it, I think authentication shouldn’t be part of the media consumption experience so I disable the need for a password on wakeup on my HTPCs; leave this one alone on the other PCs.  

S3 Bios

I’ve never been able to get hybrid sleep (a feature where the PC doesn’t have to transition through S1 to get to S4 from S3) to work properly so this get’s disabled on everything.  If you don’t want S4, change the “Hibernate after” setting to “Never” otherwise choose a setting that works for you.  Note that if your motherboard doesn’t support WOL from S5 you will not be able to WOL from S4.

S3 Bios

I don’t have seperate power and sleep buttons on any of my PCs.  So every one of them has the power button tied to the sleep action.  Most modern systems will turn off if the power button is pressed and held for 5 seconds so you don’t lose anything by going this route.  The upside, besides a more CE device experience, is that if one of your kids hits the power button, the PC goes to sleep instead of killing any unsaved work left open.

S3 Bios

The last step is to make sure that sharing content resets the idle timers.  AFAIK, this is really only effective for Microsoft’s applications (other apps could use it by making an API call, but don’t) so other solutions may be required to keep the server PC awake while you’re using the content hosted on it.  Click “OK” when you’re done.

S3 Bios

The next step is to setup WOL.  Open the Device Manager by right clicking on “[My] Computer” and selecting “Manage”, browse to the “Network adapters” section and double click the apdapter to open the properties dialog.

S3 Bios

Most modern NICs support both magic packets and directed packets (also called pattern match).  A magic packet is specally crafted packet broadcast to a specific MAC address, where a directed packet is just traffic that specifically targets the IP address of your PC.  If all the devices you want to be able to wake up the PC can send a magic packet only select that option, otherwise select both.  Generally this setting is configured on the “Advanced” tab, but if you have an Intel NIC it could be there

S3 Bios

S3 Bios

or on the “Power Management” tab

Intel NIC

In either case we need to make a stop on the “Power Management” tab and make sure that “Allow this device to wake the computer” and “Only allow management stations to wake this computer” are selected.  If for some reason directed and magic packets don’t wake the machine you can opt to disable the last setting, but be warned that any broadcast traffic (like enumerating network shares) will cause the box to wake up.

S3 Bios

Click OK (the NIC may reinitialize so make the change later if you’re doing anything that needs the network up) and we’re done with configuration.

 

Troubleshooting:

There are several background tasks (like the defragmenter) that can wake the PC and keep it from idling to sleep while they work.  It is possible to force the PC to standby during those times (Vista actually removed the ability to keep the PC awake using idle timers and standby notifications), but usually that’s not a great idea because these processes are doing vital work.  The best advice initially is to create the right environment and not get frustrated if your PC goes through a period where it won’t go down.  That said, if after 24hrs it still won’t sleep during idle periods or stay down for any length of time there are a few things to check.

The first place to check is to see if any remote file sessions are open.  Open up the system manager (right click on Computer and select “Manage”) and select the “Shared Folders” section (great place to see what folders are shared on the box too).  From here you can see all the open share sessions and files, generally an open file handle will keep the machine awake.

S3 Bios

Vista and 7 include a great command utility for troubleshooting standby issues called powercfg.  Open up an elevated command prompt and type powercfg /?  to list all the options.  The most useful ones for this task are:

  • LASTWAKE – tells you what device/event cause the last resume from standby (if the bios supports it)
  • DEVICEQUERY – queries devices that can wake the box; most interesting sub args are wake_armed (devices that are configured to wake the PC) and wake_from_any (list all devices that can wake the PC)

Given the information from “powercfg -DEVICEQUERY wake_from_any” you can go through all the devices in the Device Manager and uncheck the “Allow this device to wake the computer” option.  But be careful to not disable things like the power button or the keyboard/mouse or remote control.

The last place to look is the task scheduler.  Most of the task are necessary, but you can mess with when they run and if they can “Wake the computer to run this task”.

S3 Bios


Don’t forget to check out the follow up guide, Keeping your HTPC Awake