I am trying to partially restore a previous system image with a slightly different partition table and Windows 10 keeps trying (and failing) automatic repair.
I need help fixing the partition table.
Setup Background
I will denote the "current" (i.e. layout before restoring backup images) as layout A. Layout A partition table is as follow (sector size: 512):
DEVICE START END SECTORS SIZE TYPE
A-P1 2048 1023999 1021952 499M Windows Recovery Environment
A-P2 1024000 1228799 204800 100M EFI System
A-P3 1228800 1261567 32768 16M Microsoft Reserved
A-P4 1261568 625827839 624566271 298G Microsoft Basic Data
A-P5 625827840 2000406527 1374578688 655.5G Microsoft Basic Data
Note that A-P4
and A-P5
are encrypted with Bitlocker in layout A.
I will denote the backup images I am attempting to restore as layout B. The original system from which backup B was created had a smaller, B-P4
and consequently, larger B-P5
relative to layout A. However, B-P5
is a full of user data (no OS data) and therefore B-P5
was not backup and and the current A-P5
will be preserved. Below are the images I have available to restore:
FILE SIZE
B-bs=512_count=2048.dd 1,048,576
B-P1.dd 523,239,424 (same size as A-P1)
B-P2.dd 104,857,600 (same size as A-P2)
B-P3.dd 16,777,216 (same size as A-P3)
B-P4.dd 267,349,131,264 (SMALLER than A-P4)
Since I do not want to change the boundary of A-P5
since I want to preserve its (bitlocker encrypted) data, I did not restore the first 2048 sectors of the disk. Instead I used GParted to change the B-P4
end boundary to reflect the B-P4.dd
file size. Accordingly, the partition table looks as follows:
DEVICE START END SECTORS SIZE TYPE
B-P1 2048 1023999 1021952 499M Windows Recovery Environment
B-P2 1024000 1228799 204800 100M EFI System
B-P3 1228800 1261567 32768 16M Microsoft Reserved
B-P4 1261568 523427839 522166272 249G Microsoft Basic Data
A/B-P5 625827840 2000406527 1374578688 655.5G Microsoft Basic Data
I then restored B-P1
, B-P2
, B-P3
, and B-P4
, with files, B-P1.dd
, B-P2.dd
, B-P3.dd
, and B-P4.dd
, respectively. Also, note that the restored B-P4
/B-P4.dd
is not encrypted.
Once restored, I was able to mount, mount B-P4 /mnt
, the unencrypted Windows OS partition with success.
What I Tried
I tried to fix the partition table in Windows Advanced Repair Command Prompt as follows:
- bootrec /fixmbr (success)
- bootrec /fixboot (fail / "access denied")
- DISKPART: assign letter to EFI partition (letter N:)
- Format N: to FAT32
- bcdboot d:\windows /s n: /f uefi (failed / not in windows store)
I stopped here before doing real damage. I reimaged the EFI partition B-P2
.
Other "useful" Information
The B backup layout I am restoring is Windows 10 1804. The A layout was for Windows 10 20H1. I am in the process of creating a USB recovery drive from another Windows 10 20H1 computer that I will have at my disposal.
If not already apparent, I have access to Ubuntu Live and the images were created/restored using Ubuntu.
Parting Thoughts
How can I fix the partition table so that B-P4
(unencrypted) boots to Windows while preserving the boundaries of the (bitlocker encrypted) A-P5
partition?