Windows 10 and KB5034441: Trying to understand error code 0x80070643 and then it suddenly works?
Photo by Sora Shimazaki: https://www.pexels.com/photo/crop-unrecognizable-developer-using-laptop-and-smartphone-5926389/
My Windows 10 gaming PC showed the lovely error code 0x80070643 when I try to apply the "2024-01 Security Update for Windows 10 Version 22H2 for x64-based Systems (KB5034441)". And this update gained a somewhat notorious reputation.
What I do understand is, that KB5034441 fails to install if there isn't at least 250MB of free space on the so-called "Windows-RE" or recovery partition. Microsoft offers a PowerShell script to enlarge the recovery partition. But this only works in certain cases like the recovery partition is located after the Windows partition. Which wasn't the case on my PC. Additionally Windows wasn't able to shrink my C-Partition in order to create new, and greater, Windows RE partition behind the C-Partition.
First time I executed the script in April 2024, it told me that I have only 171.5 MB of free space then I will be under the MinSize of the C-Partition.
So yeah.. Time to dive a little bit deeper?
Turns out the MinSize and MaxSize are retrievable via the Get-PartitionSupportedSize function.
PS C:\WINDOWS\system32> Get-PartitionSupportedSize -DriveLetter C
SizeMin SizeMax
------- -------
245659398144 248628903936
A little bit of PowerShell internals
With (Get-Command Get-PartitionSupportedSize).CommandType
I am able to get the CommandType, this tells me if I am working with a Function, an Cmdlet or an alias. Helpful if you explicitly need to know the details.
Via (Get-Command Get-PartitionSupportedSize).Definition
we can retrieve the actual code behind that function. There we can see that a new CIMInstance connection to the MSFT_Partition class of the Windows Storage Management Provider API is made.
Ok, but does this help me? Not much, now I would need to dig into WMI, C/C++ and this would require more time than I am willing to invest.
Back to the problem
However I noted (or more like: felt) that the SizeMin number is different from what I got last time. Which would surprise me as the Partition Size was the same and I always had more than 20GB of free space on the C-Partition.
Fancy a try? Sure thing!
PS C:\Users\users\Downloads> .\resize_script.ps1
Cmdlet resize_script.ps1 an der Befehlspipelineposition 1
Geben Sie Werte für die folgenden Parameter an:
(Geben Sie !? ein, um Hilfe zu erhalten.)
BackupFolder: C:\winre-backup
Start time: 08/10/2024 18:08:39
Examining the system...
WinRE-Status: Enabled
WinRE-Ort: \\?\GLOBALROOT\device\harddisk0\partition1\Recovery\WindowsRE
System directory: C:\WINDOWS\system32
ReAgent xml: C:\WINDOWS\system32\Recovery\ReAgent.xml
Collecting OS and WinRE partition info...
OS Disk: 0
OS Partition: 4
WinRE Partition: 1
Disk PartitionStyle: GPT
WinRE partition size info
Partition capacity: 523235328
Partition free space: 55316480
WinRE Partition Offset: 1048576
WinRE Partition Type: Recovery
OS partition size: 249414287360
OS partition Offset: 644874240
OS partition ends at: 250059161600
WinRE partition starts at: 1048576
Backup Directory: [C:\winre-backup]
Verifying if the WinRE partition needs to be extended or not...
WinRE partition is not after OS partition, cannot perform extension
Need to create a new WinRE partition after OS partition
Summary of proposed changes
Note: WinRE partition is before OS partition, need to create a new WinRE partition after OS partition
Will shrink OS partition by 785383424
Current OS partition size: 249414287360
Target OS partition size after shrinking: 248628903936
New WinRE partition will be created with size: 785379328
Existing WinRE partition will be deleted
WinRE partition: Disk [0] Partition [1]
Current WinRE partition size: 523235328
The contents of the old WinRE partition will be backed up to [C:\winre-backup]
Please reboot the device before running this script to ensure any pending partition actions are finalized
Would you like to proceed? Y for Yes and N for No: y
Proceeding with changes...
Note: To prevent unexpected results, please do not interrupt the execution or restart your system
Loading [C:\WINDOWS\system32\Recovery\ReAgent.xml] ...
Stage location info is empty
Disabling WinRE...
REAGENTC.EXE: Vorgang erfolgreich.
Verifying that WinRE wim exists in downlevel at default location
Performing repartition to extend the WinRE partition ...
Shrinking the OS partition to create a larger WinRE partition
Resizing the OS partition to: [248628903936]...
Target partition size: 248628903936
Size of OS partition after shrinking: 248628903936
Copying content on WinRE partition from [\\?\Volume{daac35b3-1726-41c1-b290-1f73fd3f840a}\] to [C:\winre-backup]...
Copying [\\?\Volume{daac35b3-1726-41c1-b290-1f73fd3f840a}\Recovery] to [C:\winre-backup\Recovery]...
Backup completed
Deleting WinRE partition: Disk [0] Partition [1]...
Creating new WinRE partition...
Target size: 785379328
Formating the partition...
New Partition index: 1
Re-enabling WinRE...
REAGENTC.EXE: Vorgang erfolgreich.
WinRE Information:
WinRE-Status: Enabled
WinRE-Ort: \\?\GLOBALROOT\device\harddisk0\partition1\Recovery\WindowsRE
WinRE Partition Index: 1
Partition capacity: 785379328
Partition free space: 317145088
OS Information:
OS partition size: 248628903936
OS partition Offset: 644874240
End time: 08/10/2024 18:09:29
The contents of the old WinRE partition has been backed up to [C:\winre-backup]
Successfully completed the operation
PS C:\Users\users\Downloads>
And after a reboot everything was fine. The update is now installed and my recovery partition is now located after my Windows C-Partition. My C-Partition is now 231GB, 1GB less.
Don't ask me what changed between April 2024 and August 2024. I have absolutely no idea. When I executed the script in April 2024 I had ~22GB of free space. Cleared all temp files from Windows you can clear. Defragmented the drive. Even moved some games to other partitions/hard-disks to free up even more space. Nothing worked.
The resize_script.ps1 is also still the same as the one I downloaded in April 2024.
Anyway, no annoying pending update anymore. And given that we are talking about my gaming PC I can live with that. ☺️