Question
Using nothing but the usual relevant Linux utilities like parted, fdisk, ntfsclone, et cetera, in addition to whatever tools come with Windows, like bcdboot and dism, how can one copy or clone an existing Windows 10 installation from one disk to an arbitrary location on another disk? For example, from /dev/sdc42 to /dev/sdp23. Obviously, it must be bootable by the end of the process.
Possible Solutions
My guess of the solution was to
- ensure that an EFI system partition (ESP) exists on the target device,
- create a partition on the target device that is the same size as the old (existing) Windows partition,
ntfsclonethe old partition to the destination,- use
bcdbootfrom the old installation to copy the BCD stuff of the new installation to the ESP of the target disk, and - attempt to boot into the new installation whilst crossing fingers.
but after a couple of attempts, that did not seem to work the way I did it. Continuing from step 2 above, my current guess is now to, as described by this post
- use
dism(from a separate Windows environment, such as Windows PE) to capture an image of the old (existing) Windows installation, - apply the image to the newly created partition, and
- use
bcdbootto copy the BCD files from the new partition to the ESP of the new disk.
Note
I know I could just use a convenient tool like Clonezilla or something, but I want to learn the process of doing it manually this way.
bootrec /FixMBR && bootrec /RebuildBCDis required prior to booting. What does the/FixMBRswitch actually do on a GPT disk? – Mona the Monad Feb 07 '20 at 21:47bootrec /rebuildbcdis always required prior to booting when applying a system WIM to another partition, else the BCD store will lack the volume path to that partition and it's more efficient than usingbcdedit./fxmbrshouldn't have to be issued on a GPT disk, however I've had users comment on other forums that without issuing it in some instances, the system won't boot. I personally have never encountered that, and since it doesn't cause any harm to a GPT disk, I've always included it. – JW0914 Feb 08 '20 at 12:48BootRec, which should allow you to recreate the EFI partition's contents without initiating an install (bootrec /fixbootdoes not work on it's own with UEFI). If that method works, please reply back and I'll update the information in that answer. – JW0914 Feb 08 '20 at 12:55BootRec /FixBootwill not work on it's own (you'll get an access denied error).BootRec /RebuildBCDsearches for partitions with a%WinDir%and, if found, provides the user the option to update the BCD store with the relevant info for booting to the OS on that partition. All the EFI partition contains are the EFI boot files (backup of which is stored at%WinDir%\Boot) and BCD store. – JW0914 Feb 08 '20 at 13:47BootRec /RebuildBCD] may modify is the BCD store, so if that's not what you want to occur, you'll either want to disconnect that HDD from the PC or useBCDedit. If your intent is to dual-boot both OSes and to be asked at boot which to boot from, you'll want to only use the EFI partition already in use and simply allowBootRec /RebuildBCDto add both OSes to the BCD store. – JW0914 Feb 08 '20 at 16:59bootreccommands prior to booting. After attempting to boot into the new installation, the machine restarts itself. I try to boot into it again, and I am met with a black screen. I can hear some ongoing disk I/O, but it's on the HDD. I otherwise cannot see what it's doing. Did I do something wrong? – Mona the Monad Feb 15 '20 at 03:08bcdedit(if unable to solve the issue, please add the output of the following to your question:bcdedit /enum). I've never attempted what you're trying to do [having a mirrored Windows partition and trying to boot from both], but I would start with the BCD store as my assumption is it would be configured the same way as any other dual-boot Windows setup. Beyond that, Microsoft Docs is where I would recommend taking a look at (you should only have one ESP and MSR partition AFAIK), as the capturing and applying of the WIM isn't the issue. – JW0914 Feb 15 '20 at 12:42C:is often not assigned to the Windows partition? Also, for WinRE, if you have WinRE on it's own partition (the default for UEFI installs), once you're booted to the second Windows partition, you can configure it to use that WinRE partition (provided you only have one EFI partition - only one is needed and having more than that overcomplicates things) – JW0914 Feb 15 '20 at 12:51D:, so the command issued after applying the WIM was something likeBCDBoot D:\Windows /s H: /f UEFI /v /addlast /d. The cloned Windows does indeed boot, complete with those revolving dots, but then I am met with a black screen and a flashy disk I/O indicator. Also,BootRec /RebuildBCDreports 0 discovered Windows installations. What could be wrong here? – Mona the Monad Nov 26 '20 at 02:11D:in WinPE, as I said, but I don't know how the clone sees itself. Maybe it mistakenly sees itself also as a different letter, somehow. Is this what you meant to ask me? The other possibility might be wonky drivers (display?), as I didn'tsysprepit, but it's the same physical machine, just with a different disk, so I don't know why this would be a problem. Just a few guesses from me. – Mona the Monad Nov 26 '20 at 15:02