1

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

  1. ensure that an EFI system partition (ESP) exists on the target device,
  2. create a partition on the target device that is the same size as the old (existing) Windows partition,
  3. ntfsclone the old partition to the destination,
  4. use bcdboot from the old installation to copy the BCD stuff of the new installation to the ESP of the target disk, and
  5. 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

  1. use dism (from a separate Windows environment, such as Windows PE) to capture an image of the old (existing) Windows installation,
  2. apply the image to the newly created partition, and
  3. use bcdboot to 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.

Mona the Monad
  • 387
  • 5
  • 13
  • Please see [this](https://superuser.com/a/1503102/529800) answer – JW0914 Feb 07 '20 at 21:36
  • I see that you say that `bootrec /FixMBR && bootrec /RebuildBCD` is required prior to booting. What does the `/FixMBR` switch actually do on a GPT disk? – Mona the Monad Feb 07 '20 at 21:47
  • `bootrec /rebuildbcd` is 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 using `bcdedit`. `/fxmbr` shouldn'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:48
  • I also came across [this](https://www.dell.com/support/article/us/en/19/sln300987/how-to-repair-the-efi-bootloader-on-a-gpt-hdd-for-windows-7-8-8-1-and-10-on-your-dell-pc?lang=en) while trying to find the Microsoft Docs man page for `BootRec`, which should allow you to recreate the EFI partition's contents without initiating an install _(`bootrec /fixboot` does 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:55
  • Alright, I'll try to try that today. However, just to make sure, this process will not mess up what is already in the EFI system partition, will it? Of course, I can always back it up, but I only want to make sure that it will modify only what needs to be modified or added (namely Windows-specific boot files). – Mona the Monad Feb 08 '20 at 13:33
  • The EFI partition, and it's contents (excluding the BCD store), cannot be maunally modified without extra steps in Windows 10, which is why simply issuing `BootRec /FixBoot` will not work on it's own _(you'll get an access denied error)_. `BootRec /RebuildBCD` searches 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:47
  • Alright, as long as it does not touch the boot files for the existing non-Windows boot stuff (like rEFInd). I will try this out later today. Thank you. – Mona the Monad Feb 08 '20 at 14:21
  • The only boot file on the current EFI partition it [`BootRec /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 use `BCDedit`. 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 allow `BootRec /RebuildBCD` to add both OSes to the BCD store. – JW0914 Feb 08 '20 at 16:59
  • I have attempted to use DISM as described to capture an image of my existing Windows installation (made sure that it was clean), applied it to the target partition, and ran the `bootrec` commands 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:08
  • You'll want to take a look at the BCD store via `bcdedit` _(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:42
  • Just wanted to verify since it's a common mistake many make... When you captured a WIM of the Windows system partition, did you verify the drive letter first, as in WinPE/WinRE, `C:` 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](https://superuser.com/a/1514869/529800) 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:51
  • Ah, didn't realize that I never answered you, my apologies. Anyway, after many months, I've tried to go about this again, and I've had the same results. The target drive letter when in the installer environment was `D:`, so the command issued after applying the WIM was something like `BCDBoot 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 /RebuildBCD` reports 0 discovered Windows installations. What could be wrong here? – Mona the Monad Nov 26 '20 at 02:11
  • And yes, I made sure that the drive letters were correct, for both the source and target volumes. I tried to make it as simple as possible for the WinPE environment. One ESP, one source Windows partition, one destination Windows partition (empty), and one extra NTFS partition for storing the WIM and acting as the scratch directory. It at least boots, so I hope this last obstacle is a small one. – Mona the Monad Nov 26 '20 at 02:19
  • After doing some more research, I've come up with some possibilities. The boot drive letter might actually be incorrect. It was `D:` 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't `sysprep` it, 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

0 Answers0