Really disabling hibernate before installing Linux

I did a lot of research before installing Linux on my new laptop. Some people advised to disable hibernate before installing Linux in a dual boot setup. The reasoning, I think, is to prevent the machine hibernating in one OS and waking in another, leaving the first in an unusual state.

I found some instructions on how to disable hibernate https://www.tenforums.com/tutorials/2859-enable-disable-hibernate-windows-10-a.html and set about doing that armed with the Microsoft docs on the relevant command line utility https://docs.microsoft.com/en-us/windows-hardware/design/device-experiences/powercfg-command-line-options

An added complexity that I discovered while following the instructions to disable hibernate is that it can be triggered for a number of reasons, all of which need to be addressed when disabling it. The following outlines the steps I took to hunt down every way that hibernate could be triggered in my system and disable them all one by one.

The first step is to open a command line shell in administrator mode (from memory, since I am on the Linux side at the moment: hit Windows key + X, right click on command line and select administrator mode). In the resulting shell:

C:\WINDOWS\system32>powercfg /list

Existing Power Schemes (* Active)

Power Scheme GUID: 191ba8c6-5e2f-4d89-8197-303852978162  (Airplane)
Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e (Balanced) *
Power Scheme GUID: 707872dd-11b4-4409-b54f-121b8ea7ba40 (Timers off (Presentation))

Turn off hibernate

powercfg /hibernate off

Query settings for Airplane mode

From the output above, we see that the GUID for airplane mode is 191ba8c6-5e2f-4d89-8197-303852978162

C:\WINDOWS\system32>powercfg /query 191ba8c6-5e2f-4d89-8197-303852978162
 Power Scheme GUID: 191ba8c6-5e2f-4d89-8197-303852978162  (Airplane)
Subgroup GUID: 0012ee47-9041-4b5d-9b77-535fba8b1442 (Hard disk)
GUID Alias: SUB_DISK
Power Setting GUID: 6738e2c4-e8a5-4a42-b16a-e040e769756e (Turn off hard disk after)
GUID Alias: DISKIDLE
Minimum Possible Setting: 0x00000000
Maximum Possible Setting: 0xffffffff
Possible Settings increment: 0x00000001
Possible Settings units: Seconds
Current AC Power Setting Index: 0x00000384
Current DC Power Setting Index: 0x000000b4

From the full output of that command we see that we also need to change HIBERNATEIDLE in all power plans. Setting it to zero disables.

C:\WINDOWS\system32>powercfg  /setacvalueindex 191ba8c6-5e2f-4d89-8197-303852978162 SUB_SLEEP HIBERNATEIDLE 0
C:\WINDOWS\system32>powercfg /setdcvalueindex 191ba8c6-5e2f-4d89-8197-303852978162 SUB_SLEEP HIBERNATEIDLE 0

Verify it is off

C:\WINDOWS\system32>powercfg /query 191ba8c6-5e2f-4d89-8197-303852978162
...
Power Setting GUID: 9d7815a6-7ee4-497e-8888-515a05f02364 (Hibernate after)
GUID Alias: HIBERNATEIDLE
Minimum Possible Setting: 0x00000000
Maximum Possible Setting: 0xffffffff
Possible Settings increment: 0x00000001
Possible Settings units: Seconds
Current AC Power Setting Index: 0x00000000
Current DC Power Setting Index: 0x00000000

Also turn it off in the balanced power profile

powercfg  /setdcvalueindex  381b4222-f694-41f0-9685-ff5bb260df2e SUB_SLEEP HIBERNATEIDLE 0

Verify

C:\WINDOWS\system32>powercfg /query 381b4222-f694-41f0-9685-ff5bb260df2e

...
Power Setting GUID: 9d7815a6-7ee4-497e-8888-515a05f02364  (Hibernate after)
  GUID Alias: HIBERNATEIDLE
  Minimum Possible Setting: 0x00000000
  Maximum Possible Setting: 0xffffffff
  Possible Settings increment: 0x00000001
  Possible Settings units: Seconds
Current AC Power Setting Index: 0x00000000
Current DC Power Setting Index: 0x00000000

Check the last power configuration

powercfg /query 707872dd-11b4-4409-b54f-121b8ea7ba40

See that hibernate is still enabled for Critical battery action on DC power (battery). Change it to sleep in all power profiles:

powercfg  /setdcvalueindex 707872dd-11b4-4409-b54f-121b8ea7ba40 SUB_BATTERY BATACTIONCRIT 1
powercfg  /setdcvalueindex 191ba8c6-5e2f-4d89-8197-303852978162  SUB_BATTERY BATACTIONCRIT 1 
powercfg  /setdcvalueindex 381b4222-f694-41f0-9685-ff5bb260df2e  SUB_BATTERY BATACTIONCRIT 1 

And for AC power in 381b4222-f694-41f0-9685-ff5bb260df2e (Balanced)!

powercfg  /setacvalueindex 381b4222-f694-41f0-9685-ff5bb260df2e  SUB_BATTERY BATACTIONCRIT 1 

Verify again by querying each power scheme in turn.

Now, this should also disable Fast Boot and we can verify that using the Windows control panel:

Control Panel\All Control Panel Items\Power Options\Choose what the power buttons do – check there is no Fast Boot option