The Big Picture: Saving a Game and Switching Off the Console
When you save a video game and switch the console completely off, nothing uses power. Next day you load the save and carry on exactly where you were. Hibernate does this for the whole PC. It is the S4 state from Section 2.
Sleep (Section 3) keeps your work in RAM, which needs power. Hibernate writes your work to the drive, which needs none.
4.1 RAM Contents Written to hiberfil.sys
What it is: hiberfil.sys is a large hidden system file in the root of the system drive (usually C:\hiberfil.sys). When you hibernate, Windows writes the contents of RAM into it, in a compressed form.
BEFORE DURING HIBERNATE AFTER
RAM [ apps, kernel, data ] RAM [ apps, kernel, data ] RAM [ empty ]
Disk [ hiberfil.sys: old ] -> Disk [ hiberfil.sys: filling ] Disk [ hiberfil.sys: full ]
then power goes completely off
How big is it? Windows reserves the file in advance so there is always room to save. By default it is a fraction of your RAM size, roughly 40% to 75% (hedge: this depends on the Windows version and settings, because the data is compressed). A PC with 16 GB of RAM may therefore have a hiberfil.sys of several gigabytes to about 12 GB.
Why it is hidden: it is a protected operating-system file. To see it in File Explorer you must show hidden items and protected operating system files (a View option). It cannot be opened or edited.
Who writes and reads it: the kernel's power code does the writing and the Windows boot loader (Chapter 6) does the reading on resume. The loader reads the file before the full OS is running, so the system comes back as one block.
4.2 Full Power-Off, Restore on Wake
Going to hibernate (S4):
1. Trigger Start -> Power -> Hibernate (if shown), or a timer or low battery
2. Notify Apps and services are told; drivers get power IRPs (Chapter 13)
3. Freeze Devices go to D3; only one CPU core keeps working
4. Write RAM contents are compressed and written to hiberfil.sys
5. Power off acpi.sys puts the machine into S4; all power is removed
(only standby power for the power button, as with S5)
Coming back:
1. Power button Same as a normal start
2. Firmware Does its normal startup checks (Chapter 5)
3. Boot manager Notices a valid hiberfil.sys (the "resume" case)
4. Resume loader Reads hiberfil.sys back into RAM
5. Windows Continues where it stopped; drivers restore devices
6. You See your apps exactly as you left them
| Sleep (S3) | Hibernate (S4) | |
|---|---|---|
| Power used while off | Small, from RAM refresh | None |
| Survives battery running flat or power cut | No | Yes |
| Resume speed | 1-3 s | Slower; depends on RAM size and drive speed |
Needs hiberfil.sys | No | Yes |
An SSD (Chapter 18) makes hibernate and resume much faster than a hard drive.
4.3 Hibernate Is Not Always in the Menu
On many PCs, Hibernate is not shown in the Start menu Power list. That does not mean it is missing; the menu entry can be hidden by a setting. In Control Panel → Power Options → "Choose what the power buttons do", the Hibernate option can be shown or hidden (it can need "Change settings that are currently unavailable" first).
Use the read-only command from Section 2 to see the truth:
powercfg /a
If Hibernate is listed as available, hiberfil.sys exists and S4 works.
4.4 Turning Hibernation On or Off (Do Not Try in the Lab)
The command powercfg /h (or /hibernate) changes the feature. It needs an administrator window.
| Command | What it does |
|---|---|
powercfg /h off | Turns hibernation off and deletes hiberfil.sys; frees the disk space; also turns off Fast Startup |
powercfg /h on | Turns it back on and creates the file |
Do not run these in the practical lab. They change the system. They are safe and reversible, but this chapter's lab only reads information.
Why someone might turn it off: to free several gigabytes on a small drive. The cost: no hibernate, and no Fast Startup (Section 6). On PCs with Modern Standby, Windows may still use hibernation as a backup, so check powercfg /a before deciding (hedge: this depends on the PC).
4.5 Hybrid Sleep (Mostly on Desktops)
What it is: Hybrid sleep is sleep plus a hibernate save. Windows writes RAM to hiberfil.sys and then goes into S3. If the power stays on, you wake in a second or two from RAM. If power is lost, the PC starts from the saved file instead of losing your work.
| Setting | Meaning |
|---|---|
| Hybrid sleep on | Safe sleep: both RAM and the saved file hold your work |
| Hybrid sleep off | Plain sleep, a bit faster to enter |
It is usually switched on by default on desktop PCs and off on laptops, where the battery gives protection (hedge: it varies by PC and version). The setting lives in the advanced part of the power plan (Section 7).
4.6 Hibernate After Sleep
Windows can also hibernate after a long sleep. The power plan has a setting called Hibernate after (a number of minutes). The PC sleeps first; if it is still asleep when the time ends, Windows wakes it briefly, saves RAM to hiberfil.sys and powers off. This protects a laptop whose battery would otherwise slowly drain in S3.
Summary
| Term | Plain meaning |
|---|---|
| Hibernate (S4) | RAM saved to disk, power fully off |
hiberfil.sys | The hidden file in the system drive root that holds the saved RAM |
| Size | About 40% to 75% of RAM by default (hedge) |
powercfg /h off / on | Removes or creates the file (administrator; not for the lab) |
| Hybrid sleep | Sleep plus a hibernate save, for safety |
| Resume | The loader reads the file back into RAM |