Rebuilding the recovery partition in Windows 10 LTSC
I had an instance where I needed to expand a virtual Windows 10 install on my Proxmox server.
I've documented it before, in both Proxmox and in Windows, but it requires deleting the existing recovery partition in Windows 10, as it would otherwise sit between the old hard drive size and the newly added additional space.
After expanding the hard drive in Windows, I also wanted to rebuild the recovery partition, just in case something happened.
There are a lot of guides on the internet, but a lot of misleading information, and running the LTSC version of Windows makes the instructions a bit different.
Easier said than done, but I finally figured it out.
This guide assumes the following:
-
The hard drive to be expanded is C:\
-
It is being expanded from 50Gb to 100Gb
-
The dvdrom/cd is D:\
-
The Windows 10 LTSC ISO mounted in D:\
-
With the virtual Windows 10 device powered off, expand the hard drive in Proxmox.
Disable WinRE
- After powering on the virtual Windows 10 device, disable the Windows Recovery Environment (WinRE), using the
reagentc
command:
tom@WIN10-DESKTOP:\>reagentc /disable
- Display the versions of Windows 10 using the Windows image (.wim) file in the mounted ISO:
tom@WIN10-DESKTOP:\>Dism /Get-WimInfo /WimFile:d:\sources\install.wim
Dism /Get-WimInfo /WimFile:d:\sources\install.wim
Deployment Image Servicing and Management tool
Version: 10.0.19041.3636
Details for image : d:\sources\install.wim
Index : 1
Name : Windows 10 Enterprise LTSC
Description : Windows 10 Enterprise LTSC
Size : 13,557,566,813 bytes
Index : 2
Name : Windows 10 IoT Enterprise LTSC
Description : Windows 10 IoT Enterprise LTSC
Size : 13,560,468,900 bytes
The operation completed successfully.
Copy over the Windows image file
- Use the
dism
(Deployment Image Servicing and Management tool) to applies the Windows image file (.wim) to the c:\windows\system32\recovery\ partition:
Note: This will take a while...
tom@WIN10-DESKTOP:\>Dism /apply-image /imagefile:d:\sources\install.wim /index:2 /ApplyDir:c:\windows\system32\recovery\
Deployment Image Servicing and Management tool
Version: 10.0.19041.3636
Applying image
[==========================100.0%==========================]
The operation completed successfully.
Delete the existing recovery partition
- Delete the existing recovery partition, located on Disk 0, Partition 4 in this example, using
diskpart
:
tom@WIN10-DESKTOP:\>diskpart
Microsoft DiskPart version 10.0.19041.3636
Copyright (C) Microsoft Corporation.
On computer: DESKTOP-CVFKDKA
DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 100 GB 50 GB *
DISKPART> select disk 0
Disk 0 is now the selected disk.
DISKPART> list partition
Partition ### Type Size Offset
------------- ---------------- ------- -------
Partition 1 System 100 MB 1024 KB
Partition 2 Reserved 16 MB 101 MB
Partition 3 Primary 49 GB 117 MB
Partition 4 Recovery 509 MB 49 GB
DISKPART> select partition 4
Partition 4 is now the selected partition.
- Verify this is the recovery partition (Type should be de94bba4-06d1-4d40-a16a-bfd50179d6ac)
DISKPART> detail partition
Partition 4
Type : de94bba4-06d1-4d40-a16a-bfd50179d6ac
Hidden : Yes
Required: Yes
Attrib : 0X8000000000000001
Offset in Bytes: 53151268864
Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- --------
* Volume 3 NTFS Partition 509 MB Healthy Hidden
DISKPART> delete partition override
DiskPart successfully deleted the selected partition.
Extend the hard drive
- List the volumes
DISKPART> list volume
Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- --------
Volume 0 D CES_X64FREO UDF CD-ROM 4626 MB Healthy
Volume 1 C NTFS Partition 49 GB Healthy Boot
Volume 2 FAT32 Partition 100 MB Healthy System
- Select the c:\ drive:
DISKPART> select volume 1
Volume 1 is the selected volume.
- Extend the hard drive
DISKPART> extend size=51200
DiskPart successfully extended the volume.
Create the new recovery partition
- Create the partition for the new recovery partition
DISKPART> create partition primary
DiskPart succeeded in creating the specified partition.
- Perform a quick format for the new recovery partition
DISKPART> format quick fs=ntfs
100 percent completed
DiskPart successfully formatted the volume.
- Verify hard drive has been extended and new recovery partition created
DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
* Disk 0 Online 100 GB 0 B *
DISKPART> list partition
Partition ### Type Size Offset
------------- ---------------- ------- -------
Partition 1 System 100 MB 1024 KB
Partition 2 Reserved 16 MB 101 MB
Partition 3 Primary 98 GB 117 MB
* Partition 4 Recovery 1710 MB 98 GB
- Modify the new recovery partition so it can be used as a recovery partition
DISKPART> select partition 4
Partition 4 is now the selected partition.
DISKPART> set id=DE94BBA4-06D1-4D40-A16A-BFD50179D6AC
DiskPart successfully set the partition ID.
DISKPART> gpt attributes=0x8000000000000001
DiskPart successfully assigned the attributes to the selected GPT partition.
Note: If you don't set the id and gpt attributes, Windows will not recognize it as a recovery partition
Re-enable WinRE and verify
- Re-enable WinRE
tom@WIN10-DESKTOP:\>reagentc /enable
REAGENTC.EXE: Operation Successful.
- Verify that WinRE is active
tom@WIN10-DESKTOP:\>reagentc /info
Windows Recovery Environment (Windows RE) and system reset configuration
Information:
Windows RE status: Enabled
Windows RE location: \\?\GLOBALROOT\device\harddisk0\partition4\Recovery\WindowsRE
Boot Configuration Data (BCD) identifier: 06d4a223-b2af-11ef-b17f-a1e41d666534
Recovery image location:
Recovery image index: 0
Custom image location:
Custom image index: 0
REAGENTC.EXE: Operation Successful.