How to Move Windows 10 Installation to Another Drive

bootclonesatassdwindows

There are a lot of questions like this, but given the specific circumstances I am adding this one as a new question as there are some specific issues that need to be tackled.

The steps that got me to this point:

  1. I had a PC with a SATA SSD, this SSD started having issues
  2. I put in an m.2 SSD and installed Windows 10 on it, but the boot loader/record was not moved, the old SSD was kept inside the system
  3. My SATA SSD kicked the bucket completely, which made my system inaccessible.
  4. I swapped in a different SSD and did an error check on the m.2,
    which was fine. Windows' recovery terminal would not let me create a
    fresh boot record on the m.2, and while it still recognized that
    install it would not let me boot into it, just the fresh/blank
    install on the new SATA SSD.

As a result, I ordered a new m.2 SSD and an m.2 to SATA enclosure (so I can pull the data off the old m.2, as my motherboard only has one m.2 slot).

I would like to move my Windows install from the old m.2 to the new m.2. The new SSD is larger (1TB) than the old one (128GB), but I cannot boot up the old system, only access its files. I also specifically want to cut out any other drives, but there is no boot record on the m.2, so that needs to be created on the new SSD during this process.

I am okay with 1:1 cloning the drive, as long as I can still create the boot record and resize the partition to the full SSD size. Just fixing the old m.2 SSD is not an option, as it is also degraded (cache on it is broken).

Somehow I need to clone the files from the old to the new SSD and create a boot record on the new SSD, without having the old system accessible.

Is there a process or piece of software that can help me do this, from a live environment running on a USB drive?

Best Answer

When it comes to Windows, 3rd party cloning tools are not an efficient way to image a partition.

  • Windows has always natively supported imaging of partitions or individual directories.
    • The system partition can only be imaged from WinPE/WinRE, while all other partitions are able to be imaged while booted to Windows.
    • WIMs (Windows IMage) can be captured of an entire partition or individual folders/files.
      Create a WimScript.ini config file to specify exclusions or exceptions.

  • All WinPE/WinRE WIMs have DISM included within them.
    • WinPE: Windows Preinstallation Environment
      • Such as a Windows Setup boot media (SHIFT+F10 to access terminal)
    • WinRE: Windows Recovery Environment

Configure Partitions

  1. Download the Windows Media Creation Tool
    • Save install media as an ISO and create a bootable USB with Rufus
  2. Boot the Windows Install USB and open a terminal via SHIFT+F10
  3. Configure new drive's partitions or use this script (diskpart /s CreatePartitions.txt):
    1. diskpart > lis dis > sel dis # > clean
      • UEFI: convert gpt
    2. Create WinRE partition:
      1. BIOS: cre par pri offset=1024 size=665 id=27
      2. UEFI: cre par pri offset=1024 size=665 id=de94bba4-06d1-4d40-a16a-bfd50179d6ac
      3. format quick fs=ntfs label=WinRE
        • WinRE partition must have 320MB free (WinRE.wim is ~300MB in size)
      4. UEFI: gpt attributes=0x8000000000000001
    3. Create boot partition:
      1. BIOS:
        1. cre par pri size=100
        2. format quick fs=ntfs label=Boot
        3. active
      2. UEFI:
        1. cre par efi size=100
        2. format quick fs=fat32 label=EFI
        3. cre par msr size=16
    4. If wanting:
      1. Rest of the disk as the system partition:
        1. BIOS: cre par pri
          UEFI: cre par pri id=ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
        2. format quick fs=ntfs label=System
      2. To create additional partitions after the System partition
        1. BIOS: cre par pri size=204800
          UEFI: cre par pri size=204800 id=ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
          • Creates 200GB System partition, w/ max size required being ~300GB if storing User Data directories on a partition other than C:\ (recommended)
            (i.e %UserProfile%\Documents, %UserProfile%\Downloads, etc.)
          • Multiply partition size wanted by 1024 (i.e. 200*1024=204800)
        2. format quick fs=ntfs label=System
      3. Exit DiskPart via: exit
  4. BIOS: Continue on to Imaging
    UEFI:
    1. Close the terminal and proceed through Windows setup
    2. Select the partition created to install Windows to (#3.4)
    3. Once setup reaches the "Installing Features" step, cancel the install
      • Setup can likely be canceled sooner, however, I'm not sure at which point it configures the EFI partition with the boot files, which is the only reason you're utilizing Windows Setup, since the EFI partition cannot be set up manually by the user on Windows 10.
    4. Before closing the setup GUI, else reboot back to install USB, open a terminal again for the imaging commands in the next section.
      • Before applying the image to the system partition on the new drive, format the partition again via DiskPart to ensure it's clean of any installer files.

Imaging

WinPE only has 32MB of scratch [temp] space by default, so /ScratchDir is required

  1. Capture image:
    DISM /Capture-Image /ImageFile:"Z:\Base.wim" /CaptureDir:"C:" /Name:"Windows Backup" /Description:"Base Image 2020.04.22 @ 10:05" /Compress:Max /CheckIntegrity /Verify /NoRpFix /ScratchDir:"Z:\"
    
    Append an image
    • Change /Compress:Max to /Compress:Fast if not saving captured image to an SSD
  2. Apply Image
    DISM /Apply-Image /ImageFile:"Z:\Base.wim" /Index:1 /ApplyDir:"C:" /CheckIntegrity /Verify /NoRpFix /ScratchDir:"Z:\"
    
    • Get Image Info prior to applying, ensuring correct index [image] is being applied.
      DISM /Get-WIMinfo /WIMfile:"Z:\Base.wim"
      


NOTE:

  • It's impossible for an ESD/WIM image to become corrupted
    • Provided imaging commands are always issued with /CheckIntegrity & /Verify

  • ESDs can only be taken of a system partition
    • /Compress:Recovery is the only compression algorithm available.
      • ESD compression ratio is ~33% more efficient than the WIM compression ratio.
      • In Windows 10, Microsoft only allows ESDs for Push-Button Reset exported images

  • ESDs/WIMs are smart compression image formats
    • Only changed files are added to an image when a new image is appended to it
      • Newly appended images utilize the same copy of unchanged files already contained within the image from the previous image(s).
        • This allows for an image to remain small in relation to the data contained within.


Example: /Get-WIMinfo

PS $  ls -file

  Directory: Z:\WIM

    Mode                LastWriteTime            Length  Name
    ----                -------------            ------  ----
    -a----        2018.12.24 03:34:13   95,019,530,773B  Base.wim
    -a----        2016.06.14 22:32:36              568B  DISM.cmd
    -a----        2016.05.17 05:36:10               97B  wimscript.ini

PS $  dism /get-wiminfo /wimfile:Base.wim

  Deployment Image Servicing and Management tool
  Version: 10.0.18362.1

    Details for image : Base.wim

    Index : 1
      Name : Alienware 18: Windows 10
      Description : v1803: Base (Drivers Only)
      Size : 22,710,283,446 bytes

    Index : 2
      Name : Alienware 18: Windows 10
      Description : v1803: Software Installed (No Customizations)
      Size : 45,591,850,754 bytes

    Index : 3
      Name : Alienware 18: Windows 10
      Description : v1803: Software Installed (Customized)
      Size : 94,958,267,312 bytes

    Index : 4
      Name : Alienware 18: Windows 10
      Description : v1803: Software Group 1 Installed (Customized)
      Size : 101,588,267,910 bytes

    Index : 5
      Name : Alienware 18: Windows 10
      Description : v1803: Software Group 2 Installed (Customized)
      Size : 101,905,314,237 bytes

    Index : 6
      Name : Alienware 18: Windows 10
      Description : v1809: Updated Applications
      Size : 114,959,954,040 bytes

  The operation completed successfully.
PS $  dism /get-wiminfo /wimfile:Base.wim /index:1

  Deployment Image Servicing and Management tool
  Version: 10.0.18362.1

    Details for image : Base.wim

      Index : 1
      Name : Alienware 18: Windows 10
      Description : v1803: Base (Drivers Only)
      Size : 22,710,283,446 bytes
      WIM Bootable : No
      Architecture : x64
      Hal : acpiapic
      Version : 10.0.17134
      ServicePack Build : 1
      ServicePack Level : 1
      Edition : Professional
      Installation : Client
      ProductType : WinNT
      ProductSuite : Terminal Server
      System Root : WINDOWS
      Directories : 24288
      Files : 112665
      Created : 2018.05.05 - 13:56:47
      Modified : 2018.05.05 - 13:56:47
      Languages :
              en-US (Default)

  The operation completed successfully.


PS $  dism /get-wiminfo /wimfile:Base.wim /index:2

  Deployment Image Servicing and Management tool
  Version: 10.0.18362.1

    Details for image : Base.wim

      Index : 2
      Name : Alienware 18: Windows 10
      Description : v1803: Software Installed (No Customizations)
      Size : 45,591,850,754 bytes
      WIM Bootable : No
      Architecture : x64
      Hal : acpiapic
      Version : 10.0.17134
      ServicePack Build : 1
      ServicePack Level : 1
      Edition : Professional
      Installation : Client
      ProductType : WinNT
      ProductSuite : Terminal Server
      System Root : WINDOWS
      Directories : 45803
      Files : 203058
      Created : 2018.05.06 - 01:55:47
      Modified : 2018.05.06 - 01:55:48
      Languages :
              en-US (Default)

  The operation completed successfully.


PS $  dism /get-wiminfo /wimfile:Base.wim /index:3

  Deployment Image Servicing and Management tool
  Version: 10.0.18362.1

    Details for image : Base.wim

      Index : 3
      Name : Alienware 18: Windows 10
      Description : v1803: Software Installed (Customized)
      Size : 94,958,267,312 bytes
      WIM Bootable : No
      Architecture : x64
      Hal : acpiapic
      Version : 10.0.17134
      ServicePack Build : 1
      ServicePack Level : 81
      Edition : Professional
      Installation : Client
      ProductType : WinNT
      ProductSuite : Terminal Server
      System Root : WINDOWS
      Directories : 62409
      Files : 350446
      Created : 2018.06.01 - 19:09:51
      Modified : 2018.06.19 - 21:26:18
      Languages :
              en-US (Default)

  The operation completed successfully.


PS $  dism /get-wiminfo /wimfile:Base.wim /index:4

  Deployment Image Servicing and Management tool
  Version: 10.0.18362.1

    Details for image : Base.wim

      Index : 4
      Name : Alienware 18: Windows 10
      Description : v1803: Software Group 1 Installed (Customized)
      Size : 101,588,267,910 bytes
      WIM Bootable : No
      Architecture : x64
      Hal : acpiapic
      Version : 10.0.17134
      ServicePack Build : 1
      ServicePack Level : 81
      Edition : Professional
      Installation : Client
      ProductType : WinNT
      ProductSuite : Terminal Server
      System Root : WINDOWS
      Directories : 61908
      Files : 346074
      Created : 2018.06.08 - 21:54:02
      Modified : 2018.06.19 - 21:26:18
      Languages :
              en-US (Default)

  The operation completed successfully.


PS $  dism /get-wiminfo /wimfile:Base.wim /index:5

  Deployment Image Servicing and Management tool
  Version: 10.0.18362.1

    Details for image : Base.wim

      Index : 5
      Name : Alienware 18: Windows 10
      Description : v1803: Software Group 2 Installed (Customized)
      Size : 101,905,314,237 bytes
      WIM Bootable : No
      Architecture : x64
      Hal : acpiapic
      Version : 10.0.17134
      ServicePack Build : 1
      ServicePack Level : 81
      Edition : Professional
      Installation : Client
      ProductType : WinNT
      ProductSuite : Terminal Server
      System Root : WINDOWS
      Directories : 76113
      Files : 423408
      Created : 2018.06.09 - 20:38:36
      Modified : 2018.06.19 - 21:26:18
      Languages :
              en-US (Default)

  The operation completed successfully.


PS $  dism /get-wiminfo /wimfile:Base.wim /index:6

  Deployment Image Servicing and Management tool
  Version: 10.0.18362.1

    Details for image : Base.wim

      Index : 6
      Name : Alienware 18: Windows 10
      Description : v1809: Updated Applications
      Size : 114,959,954,040 bytes
      WIM Bootable : No
      Architecture : x64
      Hal : acpiapic
      Version : 10.0.17763
      ServicePack Build : 195
      ServicePack Level : 0
      Edition : Professional
      Installation : Client
      ProductType : WinNT
      ProductSuite : Terminal Server
      System Root : WINDOWS
      Directories : 87659
      Files : 452028
      Created : 2018.12.24 - 04:27:13
      Modified : 2018.12.24 - 04:27:15
      Languages :
              en-US (Default)

  The operation completed successfully.
Related Question