Hibernation (computing)#Microsoft Windows
{{Short description|Powering down a computer while retaining its state}}
Hibernation (also known as suspend to disk, or Safe Sleep on Macintosh computers{{Cite web|title=What is safe sleep on Mac?|url=https://support.apple.com/guide/mac-help/what-is-safe-sleep-mh10328/mac|access-date=2021-01-24|website=Apple Support|language=en}}) in computing is powering down a computer while retaining its state. When hibernation begins, the computer saves the contents of its random access memory (RAM) to a hard disk or other non-volatile storage. When the computer is turned on the RAM is restored and the computer is exactly as it was before entering hibernation. Hibernation was first implemented in 1992 and patented{{Cite web|last=|first=|date=1998|title=Hibernation Patent|url=https://patentimages.storage.googleapis.com/4d/66/ea/18621f850b2f81/US6243831.pdf|url-status=live|archive-url=https://web.archive.org/web/20210125051148/https://patentimages.storage.googleapis.com/4d/66/ea/18621f850b2f81/US6243831.pdf|archive-date=25 January 2021|access-date=24 January 2021|website=Patents.google.com}} by Compaq Computer Corporation in Houston, Texas.
Microsoft's Windows 8, Windows 8.1, Windows 10 and Windows 11 employ a type of hibernation (Fast Startup) by default when shutting down.{{Cite web|last=windows-driver-content|title=Delivering a great startup and shutdown experience|url=https://docs.microsoft.com/en-us/windows-hardware/test/weg/delivering-a-great-startup-and-shutdown-experience|access-date=2021-01-24|website=docs.microsoft.com|language=en-us}}
Uses
After hibernating, the hardware is powered down like a regular shutdown.{{cite web|title=Sleep and hibernation: frequently asked questions|url=http://windows.microsoft.com/en-us/windows7/Sleep-and-hibernation-frequently-asked-questions|access-date=15 October 2011|work=Windows 7 Online Help|publisher=Microsoft Corporation}} The system can have a total loss of power for an indefinite length of time and then resume to the original state. Hibernation is mostly used in laptops, which have limited battery power available. It can be set to happen automatically on a low battery alarm. Most desktops also support hibernation, mainly as a general energy saving measure and allows for replacement of a removable battery quickly. Google and Apple mobile hardware (Android, Chromebooks, iOS) do not support hibernation. Apple hardware using macOS calls hibernation Safe Sleep.
A real-time clock alarm can be scheduled to wake the machine after hibernation.{{cite web|title=systemd.timer|url=http://www.freedesktop.org/software/systemd/man/systemd.timer.html|website=freedesktop.org|accessdate=12 June 2024}}
Comparison to sleep mode
Many systems support a low-power sleep mode in which the processing functions of the machine are lowered, using a trickle of power to preserve the contents of RAM and support waking up. Instantaneous resumption is one of the advantages of sleep mode over hibernation. A hibernated system must start up and read data from permanent storage and then transfer that back to RAM, which takes longer and depends on the speed of the permanent storage device, often much slower than RAM. A system in sleep mode only needs to power up the CPU and display, which is almost instantaneous. On the other hand, a system in sleep mode still consumes power to keep the data in the RAM, and thus cannot last indefinitely, as hibernation can. Detaching power from a system in sleep mode results in data loss, while cutting the power of a system in hibernation has no risk; the hibernated system can resume when and if the power is restored. Both shut down and hibernated systems may consume standby power unless they are unplugged.{{Cite web|title=Shut down, sleep, or hibernate your PC|url=https://support.microsoft.com/en-us/windows/shut-down-sleep-or-hibernate-your-pc-2941d165-7d0a-a5e8-c5ad-8c972e8e6eff|access-date=2021-01-15|website=support.microsoft.com}}
Hibernation is a means of avoiding the burden of saving unsaved data before shutting down and restoring all running programs and re-opening documents and browser tabs. Both hibernation and sleep preserve memory fragmentation and atrophy that lead to mobile devices working poorer the longer they run without a full reboot. This is why many experts{{Who|date=December 2024}} recommend a frequent shut down or reboot of electronic devices.
First implementation
The first working retail hibernation was in 1992 on the Compaq LTE Lite 386 as noted in its sales material.{{Cite web|last=|first=|date=1992|title=Sales Material from Compaq Computer Corp|url=http://www.1000bit.it/ad/bro/compaq/Compaq-LTE-Family.pdf|url-status=live|archive-url=https://web.archive.org/web/20170102094953/http://www.1000bit.it/ad/bro/compaq/Compaq-LTE-Family.pdf/|archive-date=2017-01-02|access-date=2021-01-24|website=10000 Bit}} It is made possible in part due to the sleep and protected mode opcodes in the Intel 386 CPU. It was implemented in ROM and worked independently of the operating system with no drivers needed. The LTE would sense low battery and prevented data loss by making use of a hidden partition. It preserved and restored the system in the midst of disk writes and operations with a math co-processor. It could also be controlled using an optional software GUI or a customized keyboard shortcut. It was tested on DOS, Windows 3.1, Banyan Vines, and Novell Netware. Compaq's hibernation is also noted in an IBM patent{{Cite patent|title=Hibernation file creation device and method|gdate=1993-07-26|url=https://patents.google.com/patent/JPH0744438A/ja}} from 1993.
Operating system support
Early implementations of hibernation used the BIOS as noted above, but modern operating systems usually handle hibernation themselves. Hibernation is defined as sleeping mode S4 in the ACPI specification.{{Cite web |url=http://www.acpi.info/DOWNLOADS/ACPIspec30b.pdf |title=ACPI Specification Rev 3.0b |access-date=2008-11-09 |archive-date=2008-12-30 |archive-url=https://web.archive.org/web/20081230093024/http://www.acpi.info/DOWNLOADS/ACPIspec30b.pdf |url-status=dead }}
=Microsoft Windows=
On Windows computers, hibernation is available only if all hardware and device drivers are ACPI and plug-and-play–compliant. This allows some desktop computers to hibernate quickly to SSD in the event of a power failure and power supplied to even a lightweight or aging UPS. Hibernation can be invoked from the Start menu or the command line.{{Cite web |url=http://support.microsoft.com/kb/555569/ |title=Microsoft Help and Support – How To Put the System into hibernation or Standby from Run menu |access-date=2009-02-11 |archive-date=2009-02-11 |archive-url=https://web.archive.org/web/20090211115107/http://support.microsoft.com/kb/555569 |url-status=dead }}
Windows 95 supports hibernation through hardware manufacturer-supplied drivers and only if compatible hardware and BIOS are present. Since Windows 95 supports only Advanced Power Management (APM), hibernation is called Suspend-to-Disk. Windows 98 and later support ACPI. However, hibernation often caused problems since most hardware was not fully ACPI 1.0 compliant or did not have WDM drivers. There were also issues with the FAT32 file system,[http://www.microsoft.com/whdc/archive/hiberfat32.mspx BIOS and Hibernate Issues for FAT32 File System] making hibernation problematic and unreliable.
Windows 2000 is the first Windows to support hibernation at the operating system level (OS-controlled ACPI S4 sleep state) without special drivers from the hardware manufacturer. A hidden system file named "{{mono|hiberfil.sys}}" in the root of the boot partition is used to store the contents of RAM when the computer hibernates. In Windows 2000, this file is as big as the total RAM installed.
Windows Me, the last release in the Windows 9x family, also supports OS-controlled hibernation like Windows 2000 and requires disk space equal to that of the computer's RAM.{{cite web|url=http://www.activewin.com/interviews/microsoft/7.shtml |title=Interview with Nicolas Coudière, Chief Product Manager: Microsoft Windows Millennium Edition (Me) |publisher=Activewin.com |access-date=2010-08-26}}{{cite web|url=http://www.microsoft.com/whdc/archive/winpowmgmt.mspx#EUE |title=Windows Power Management |publisher=Microsoft.com |date=2001-12-04 |access-date=2010-08-26|archive-url=https://web.archive.org/web/20040713182635/http://www.microsoft.com/whdc/archive/winpowmgmt.mspx|archive-date=2004-07-13}}
Windows XP further improved support for hibernation.[http://www.microsoft.com/whdc/archive/winpowmgmt.mspx#EQAAC Windows Power Management: Instant PC availability and energy savings] Hibernation and resumption are much faster as memory pages are compressed using an improved algorithm; compression is overlapped with disk writes, unused memory pages are freed and DMA transfers are used during I/O.[http://www.microsoft.com/whdc/archive/XP_kernel.mspx#EUNAC Kernel Enhancements for Windows XP] {{mono|hiberfil.sys}} contains further information including processor state. This file was documented by security researcher Matthieu Suiche{{Cite web |url=http://msuiche.net/con/bhusa2008/Windows_hibernation_file_for_fun_%27n%27_profit-0.6.pdf |title=BlackHat USA 2008 – Windows hibernation file for fun and profit |access-date=2008-08-18 |archive-date=2008-11-19 |archive-url=https://web.archive.org/web/20081119152007/http://msuiche.net/con/bhusa2008/Windows_hibernation_file_for_fun_%27n%27_profit-0.6.pdf |url-status=dead }} during Black Hat Briefings 2008 who also provided a computer forensics framework to manage and convert this file into a readable memory dump.{{Cite web |url=http://sandman.msuiche.net/ |title=SandMan Computer Forensics Framework |access-date=2022-03-08 |archive-date=2018-12-29 |archive-url=https://web.archive.org/web/20181229222229/http://sandman.msuiche.net/ |url-status=dead }} The compression feature was later documented by Microsoft as well.{{cite web|url=http://download.microsoft.com/download/7/E/7/7E7662CF-CBEA-470B-A97E-CE7CE0D98DC2/HiberFootprint.docx |title=Reducing the Disk Footprint for Windows 7 Hibernation |access-date=2012-10-25}}
Although Windows XP added support for more than 4 gigabytes of memory (through Windows XP 64-bit Edition and Windows XP Professional x64 Edition), this operating system, as well as Windows Server 2003, Windows Vista and Windows Server 2008 do not support hibernation when this amount of memory is installed because of performance issues associated with saving such a large pool of data from RAM to disk.{{cite web|url = http://support.microsoft.com/kb/888575|title = You cannot put a computer that has more than 4 GB of memory into hibernation in Windows XP, in Windows Server 2003, in Windows Vista, or in Windows Server 2008|date = 23 September 2011|website = Support|publisher = Microsoft|access-date = 23 March 2014|edition = 9.0|archive-date = 23 March 2014|archive-url = https://web.archive.org/web/20140323134616/http://support.microsoft.com/kb/888575|url-status = dead}} This would later be resolved by Windows 7 and Windows Server 2008 R2.
Windows Vista introduced a hybrid sleep feature, which saves the contents of memory to hard disk but instead of powering down, enters sleep mode. If the power is lost, the computer can resume as if hibernated.
Windows 7 introduced compression to the hibernation file and set the default size to 75% of the total physical memory. Microsoft also recommends that the size be increased using the powercfg.exe
tool in some rare workloads where the memory footprint exceeds that amount. It can be set from anywhere between 50% and 100%, although decreasing it is not recommended.
Windows 8 also introduces a Fast startup feature. When users select the Shut Down option, it hibernates the computer, but closes all programs and logs out the user session before hibernating.{{Cite web |url=http://blogs.msdn.com/b/b8/archive/2011/09/08/delivering-fast-boot-times-in-windows-8.aspx |title=Delivering fast boot times in Windows 8 |access-date=2011-11-09 |archive-date=2011-11-08 |archive-url=https://web.archive.org/web/20111108025109/http://blogs.msdn.com/b/b8/archive/2011/09/08/delivering-fast-boot-times-in-windows-8.aspx |url-status=dead }} According to Microsoft, a regular hibernation includes more data in memory pages which takes longer to be written to disk. In comparison, when the user session is closed, the hibernation data is much smaller and therefore takes less time to write to disk and resume. Users have the option of performing a traditional shutdown by holding down the Shift key while clicking Shut Down{{Cite web |url=https://blogs.technet.microsoft.com/askperf/2012/10/25/windows-8-windows-server-2012-faster-boot-process/ |title=Windows 8 / Windows Server 2012: Faster Boot Process | Ask the Performance Team Blog |access-date=2018-05-24 |archive-date=2018-05-24 |archive-url=https://web.archive.org/web/20180524152103/https://blogs.technet.microsoft.com/askperf/2012/10/25/windows-8-windows-server-2012-faster-boot-process/ |url-status=dead }} and it is also possible to shut down a computer in the traditional way by disabling Fast Startup in the system settings.
Windows 10 mirrors Windows 8 as noted by Microsoft. Windows 10's hibernation algorithm is solid-state drive optimized. This behavior is carried over to Windows 11.
Hibernation is often underused in business environments as it is difficult to enable it on a large network of computers without resorting to third-party PC power management software.[http://www.datasynergy.co.uk/PowerManagerHome.aspx Enable hibernate using group policy] This omission by Microsoft has been criticized as having led to a huge waste in energy.{{Cite web |url=http://www.treehugger.com/files/2006/11/how_windows_xp.php |title=EcoGeek – How Windows XP Wasted $25 Billion of Energy |access-date=2009-01-14 |archive-date=2006-11-27 |archive-url=https://web.archive.org/web/20061127051214/http://www.treehugger.com/files/2006/11/how_windows_xp.php |url-status=dead }}
It is possible to disable hibernation and delete hiberfil.sys
.[http://support.microsoft.com/kb/920730 How to disable and re-enable hibernation on a computer that is running Windows; Microsoft; August 12, 2010.]
Third-party PC power management software offers features beyond those present in Windows.{{cite web|url=http://www.windowsitpro.com/article/buyers-guide/Power-Management-Software-for-Windows-Workstations-Buyers-Guide|title=Power Management Software for Windows Workstations|access-date=2011-04-19|archive-url=https://web.archive.org/web/20120426175620/http://www.windowsitpro.com/article/buyers-guide/Power-Management-Software-for-Windows-Workstations-Buyers-Guide|archive-date=2012-04-26|url-status=dead}}{{cite web|url=http://www.energystar.gov/index.cfm?c=power_mgt.pr_power_mgt_comm_packages|title=Energy Star Commercial Packages List|access-date=2011-04-19|archive-date=2008-11-02|archive-url=https://web.archive.org/web/20081102002142/http://www.energystar.gov/index.cfm?c=power_mgt.pr_power_mgt_comm_packages|url-status=dead}}{{cite web|url=http://www.hmcsustainability.org.uk/energy.html|author=The Headmasters' and Headmistresses' Conference|title=HMC: A Practical Guide to Sustainable Building for Schools|access-date=2011-04-19|archive-url=https://web.archive.org/web/20120315230900/http://www.hmcsustainability.org.uk/energy.html|archive-date=2012-03-15|url-status=dead}} Most products offer Active Directory integration and per-user or per-machine settings with more advanced power plans, scheduled power plans, anti-insomnia features and enterprise power usage reporting.
=macOS=
{{Main|Sleep (macOS)}}
On Macs, a feature known as Safe Sleep saves the contents of volatile memory to the system hard disk each time the Mac enters Sleep mode. The Mac can instantaneously wake from sleep mode if power to the RAM has not been lost. However, if the power supply was interrupted, such as when removing batteries without an AC power connection, the Mac would wake from Safe Sleep instead, restoring memory contents from the hard drive.{{cite web|url=http://docs.info.apple.com/article.html?artnum=302477|title=Apple Support: Progress bar appears after waking from sleep|date=February 20, 2006|archive-url=https://web.archive.org/web/20080312183128/http://docs.info.apple.com/article.html?artnum=302477|archive-date=March 12, 2008}} Because Safe Sleep's hibernation process occurs during regular Sleep, the Apple menu does not have a "hibernate" option.
Safe Sleep capability was added in Mac models starting with the October 2005 PowerBook G4 (Double-Layer SD). Safe Sleep requires Mac OS X v10.4 or higher.
Shortly after Apple started supporting Safe Sleep, Mac enthusiasts released a hack to enable this feature for much older Mac computers running Mac OS X v10.4.{{cite web|work=AndrewEscobar.com|url=http://andrewescobar.com/archive/2005/11/11/how-to-safe-sleep-your-mac/|title=How to Safe Sleep (Hibernate) Your Mac|archive-url=https://web.archive.org/web/20080105000720/http://andrewescobar.com/archive/2005/11/11/how-to-safe-sleep-your-mac/|archive-date=2008-01-05}} The classic Mac OS once also supported hibernation, but this feature was dropped by Apple.{{cite web|url=http://docs.info.apple.com/article.html?artnum=59016|title=Sleep Memory Extension 1.0 Document and Software|archive-url=https://web.archive.org/web/20070819171424/http://docs.info.apple.com/article.html?artnum=59016|archive-date=August 19, 2007}}
=Linux=
In the Linux kernel, hibernation is implemented by swsusp which is built into the 2.6 series. An alternative implementation is TuxOnIce which is available as patches for the kernel version 3.4. TuxOnIce provides advantages such as support for symmetric multiprocessing and preemption. Another alternative implementation is uswsusp. All three refer to it as "suspend-to-disk". systemd, if deployed, manages hibernation itself.
Hybrid sleep
{{See also|Sleep mode#Hybrid sleep}}
Sleep mode and hibernation can be combined: the contents of RAM are copied to the non-volatile storage and the computer enters sleep mode. This approach combines the benefits of sleep mode and hibernation: The machine can resume instantaneously, and its state, including open and unsaved files, survives a power outage. Hybrid sleep consumes as much power as sleep mode, whereas hibernation powers down the computer.{{cite web|title=Turn off a computer: frequently asked questions|url=http://windows.microsoft.com/en-US/windows-vista/Turn-off-a-computer-frequently-asked-questions|access-date=15 October 2011|work=Windows Vista Online Help|publisher=Microsoft Corporation|archive-date=10 October 2011|archive-url=https://web.archive.org/web/20111010023912/http://windows.microsoft.com/en-US/windows-vista/Turn-off-a-computer-frequently-asked-questions|url-status=dead}}