2

I have a recurring issue that prevents windows from being shut down, when the partition is cloned or migrated to another disk.

In this situation, clicking on shut down from start menu causes Windows to log out, and reboot back to the login screen. The only remedy for this is to issue a shutdown /s /f /t 0 command which will successfully shutdown Windows.

I suspect the issue is related to fast startup, a feature introduced in Windows which will hibernate the OS Kernel with a signed out user profile, rather than actually quitting the kernel.

Additional context

This will happen after cloning or migrating the partition where Windows is installed on. I use GParted to achieve this, which will break UEFI booting and thus I'll need to issue a bcdboot.exe c:\windows /s h: /f UEFI command from the recovery environment in order to restore the entry with the correct GUID for the boot drive.

How can I fix this issue without changing the fast startup or hibernate settings on Windows? The only other fix I know that works is a clean re-install, which negates the whole point of disk migration/cloning, and personally, I take as a sign of admitting defeat.

EDIT

I finally found the answer to my problem, described here.

David Refoua
  • 249
  • 1
  • 4
  • 19
  • What is the size of the new partition and how much free space is on the new partition and how much ram do have installed? – Rohit Gupta Jan 26 '23 at 13:02
  • Successful cloning shouldn't require running `bcdedit` etc. How are you doing the cloning? Why are you using GParted which is chiefly a Linux utility to clone a Windows setup? – harrymc Jan 26 '23 at 15:15
  • I use GParted to resize (shrink or extend) and copy partitions, which might include Windows setups. The new partition might be smaller or larger (e.g. 128GB or 256GB) and the free space is at least 30% of total storage. Other utilities (e.g. WinToHDD or Acronis) _migrate_ Windows installations and make necessary modifications (rather than a raw _clone_, and doing the required changes manually). In any case, that shouldn't matter, or I need to know what other changes need to be applied besides using `bcdedit` to rewrite boot configurations, this is what I'm asking. – David Refoua Jan 27 '23 at 11:29
  • I wonder if it helps if you `bcdboot` to an empty / (re-)formatted EFI partition. – Tom Yan Jan 27 '23 at 12:45
  • I don't entirely believe `bcd` is the culprit, if I use Clover to boot into Windows instead of `bcd` boot loader, the same issue happens. – David Refoua Jan 28 '23 at 13:19
  • @DavidRefoua You are ALWAYS using the Windows Boot Manager (hence the BCD). Clover does not boot Windows directly for you but just chainloads WBM. – Tom Yan Jan 28 '23 at 16:02
  • @TomYan Thanks, good to know; although still not sure why this particular issue would occur. – David Refoua Jan 29 '23 at 18:41
  • @DavidRefoua An additional thing to check is the windows system event log. There should be an event for when it shuts down (or sleeps/hibernates), and another event for when it resumes (Event ID 1, Source: Power-Troubleshooter). More importantly, the startup event should have a reason like getting woken from a scheduled task or (in my case) an ethernet connection. – Cpt.Whale Feb 01 '23 at 22:11
  • Also for sanity, check that the `Choose what the power buttons do` has "When I press the power button" set to `Shut down`, since the start menu Shut Down button follows that setting too – Cpt.Whale Feb 01 '23 at 22:12
  • @Cpt.Whale Yes, I definitely checked the obvious settings beforehand, although I'm not sure if what you're saying is the case since on an another computer I set it to `hibernate` or `turn screen off` instead, and it doesn't affect Start Menu's power off option. – David Refoua Feb 02 '23 at 06:25

2 Answers2

0

This is likely caused by the Windows kernel still being hibernated after the partition is cloned or migrated.

One solution to this problem would be to disable fast startup before cloning or migrating the partition. This can be done by going to Control Panel > Power Options > Choose what the power buttons do, and then uncheck the box labeled "Turn on fast startup".

  • You could also toggle powercfg hibernate off before the clone, and then after the clone completes, you can run powercfg hibernate on to turn that back on the original system.
  • The assumption is you are not using sysprep | generalize, shutting down on sysprep, and then doing the clone or making and image because this too may resolve this issue.

Another solution would be to use a third-party tool that is designed to handle the cloning or migration of Windows partitions, such as Macrium Reflect which can properly handle the hibernation state of the Windows kernel.

  • Or you could check if there are other options with your current cloning tool to use to better handle the the hibernation state of the Windows Kernel.

As a workaround, you can try the command shutdown /p instead of shutdown /s as it is used to power off the computer instead of shutting down and per the Windows kernel hibernation state, it could matter.

Lastly, a clean re-install may not even fix the issue because it doesn't always address the "hibernation state" of the Windows kernel before the clone is made.


Bonus item

  • According to Disable Fast Startup "Just turn off the machine to be cloned by pressing SHIFT when you shutdown. This disables fast boot only for this moment." so consider testing this at clone/image creation time.

Supporting Resources

Vomit IT - Chunky Mess Style
  • 40,038
  • 27
  • 84
  • 117
  • @David I know you say "*without changing the fast startup or hibernate settings on Windows*" but I wanted to mention those things because they are going over to the cloned system this way so adjusting those would likely resolve. However, I listed other items as well with other workaround solutions that may work out for you too plus some additional reading resources to read up on some of the correlated functionality. Good luck!! – Vomit IT - Chunky Mess Style Jan 30 '23 at 03:52
  • 1
    I appreciate it, even the resources that you posted. Will try and post the results, also thanks for _actually_ looking into this problem, I appreciate your effort! – David Refoua Jan 30 '23 at 11:14
  • @DavidRefoua I found a **Bonus** item I edited the post and appended to it. Apparently this disable that fast boot in that power cycle—this might work out well for you but not around any image systems for another week to test myself. You can disable "**Fast Startup**" [other ways too with reg keys and `control panel` | `power options`, etc.](https://www.isumsoft.com/windows-10/turn-on-off-fast-startup-in-windows-10.html). – Vomit IT - Chunky Mess Style Feb 01 '23 at 02:14
  • Thank you, I will try the solution next time I'm creating a clone of Windows, although I wish there was a fix for the current cloned situation, as well. – David Refoua Feb 02 '23 at 06:31
0

EFI system flag not set correctly

Okay, I solved my issue while browsing for solutions to another problem, Windows Update failing to complete setup on my system. I came upon this answer by martijnvan der ploeg, which like me had cloned his disk to another drive.

It seems that the EFI system partition type field was missing from my boot partition (which is usually around 100 MBs), thus Windows was failing to sleep/hibernate/shutdown.

The author provides the following instructions to restore the flag:

diskpart
select disk <id>
select partition <id>

SET ID=c12a7328-f81f-11d2-ba4b-00a0c93ec93b

This is the important GUID that sets the partition as EFI, which results in:

DISKPART> list partition

  Partition ###  Type              Size     Offset 
  -------------  ----------------  -------  ------- 
  Partition 1    Recovery           529 MB  1024 KB 
  Partition 2    System             100 MB   530 MB 

Personally, I don't care about the Recovery partition, so I didn't bother to copy it as well to the new disk, also no other drives where connected at the time. So when doing list disk and list part, I see only disk 0 with part 0 being the System partition, so I went ahead and sel disk 0 and sel part 0 them.

I'm so happy that he actually decided to go through the CBS.log log file to actually understand and debug the issue, instead of the usual steps that other people suggest in order to nuke the downloaded files and then restart windows update services, which aren't even related to the boot upgrade procedures.

BTW, I found this other guide (in german) which explains how to create this EFI partition, from scratch. It's pretty similar, you only need bcdboot.exe to populate the newly created partition.

Since my EFI partition contains some other EFI files that I didn't want to touch (mainly some utilities, also another bootloader) I didn't create it from scratch, just restored the missing flag. A reboot, and BAM! Now everything works fine on the system, like it should have been from the beginning.


P.S. Absolutely no need to clean install, unnecessary reboots, cleans, etc people. Learn to fix the problem, unlike many "advisors" on the Microsoft forum "advising" you to nuke everything and start from scratch. Be like martijnvan der ploeg, read logs, debug and fix the actual issue rather than a clean install.

David Refoua
  • 249
  • 1
  • 4
  • 19