Clone Windows 11 to another Hard Drive using Command Prompt

NC

Do you want to replace the old hard drive with a new one with a larger capacity? Or do you want to replace the traditional hard drive with a solid-state drive to improve performance?

This article explains How to Clone your Hard drive to another hard drive using command prompt.

Keywords: how to clone your hard drive to another hard drive, how to clone your windows to another hard drive, how to copy your hard drive to another hard drive, clone hard drive using command prompt, clone hard drive using cmd, cmd copy hard drive, how to clone windows 11 to another hard drive, how to clone windows 11 to ssd, copy hard drive, how to clone os to another hard drive, clone windows os, how to clone windows 11, clone your drive don't lose your data.

Currently my computer uses a traditional hard drive, I want to clone to a solid state drive to improve performance. But I don't want to reinstall the operating system and the software so what should I do?

Do you need any software to do this or does it cost money to buy it? Fortunately, on Windows operating systems, the necessary tools are available to do this.

Please join me in cloning the hard drive using the command prompt in this article. I added both hard drives to my computer and make sure the computer detects both hard drives.

How to Clone Windows 11 to another Hard Drive using Command Prompt

First you need to create an OS image for your source hard drive. So you need a place to store that image, you can use external memory to store it. Because on a traditional hard drive there is still a lot of free space, so I created a new partition to store images of the Windows operating system.

How to Clone Windows 11 to another Hard Drive using Command Prompt

You should check your current operating system size to create a partition large enough for storage. Your operating system will be significantly compressed when creating the image file.

How to Clone Windows 11 to another Hard Drive using Command Prompt

How to Clone Windows 11 to another Hard Drive using Command Prompt

To create an image file of the Windows operating system, restart your computer and access the recovery environment.

So how to boot into OS recovery environment. You press and hold the "shift" key on your keyboard and restart your computer. Press the key and wait. And here is the Windows OS recovery environment. You open the command prompt to create the operating system image.

How to Clone Windows 11 to another Hard Drive using Command Prompt

Choose options: "Troubleshoot" > "Advanced options" > "Command prompt".

You need to define the operating system partition and the partition where the image file will be stored before doing so. You use the "diskpart" command to check.

diskpart
list disk
list vol
exit

So partition C contains the operating system and partition E is where the operating system image file will be stored.

How to Clone Windows 11 to another Hard Drive using Command Prompt

You then use the below command to create an operating system image file. This file is called Windows Operating System. If your partition is assigned with other characters, replace accordingly. 

dism /capture-image /imagefile:D:\WindowsOS.wim /capturedir:C:\ /name:WindowsOS
dir D:\

And here is the file you will get, it's quite small in size.

How to Clone Windows 11 to another Hard Drive using Command Prompt

After obtaining the image file, you exit the recovery environment and return to the Windows operating system to perform the next steps. You go to partition D and you will see your Windows operating system image file.

How to Clone Windows 11 to another Hard Drive using Command Prompt

So how to restore it to the new hard drive. On the new hard drive you create the necessary partitions for the Windows operating system. If you use cloning software you are probably only interested in the source hard drive and the destination hard drive. But this way you will know how many partitions the Windows operating system needs to work.

To create partitions quickly and easily you use the text file as below:

CreatePartitions-UEFI.txt

With this text file you need to make sure to select the correct hard drive you want to format and partition. As in this example the target hard drive is 1. Make sure you don't select the source hard drive here.

Next, open a command prompt with administrative privileges. You use the diskpart command and browse to the prepared text file to partition the selected hard drive.

diskpart /s D:\CreatePartitions-UEFI.txt

As you can see the target hard drive will have 3 partitions. The "W" partition stores the files of the operating system. The "S" partition helps to boot the operating system. And the last partition is R to restore the operating system when needed.

How to Clone Windows 11 to another Hard Drive using Command Prompt

Next you will restore the image file created in the previous step to the "W" partition of the target hard drive. You need to make sure to enter the correct image file name and select the correct target partition.

dism /apply-image /imagefile:D:\WindowsOS.wim /applydir:W:\ /index:1

You will then see operating system files appear in the target partition. However, your Windows operating system will not be able to boot because the "S" partition is not configured.

The below command will create the necessary startup files for the operating system. You select the corresponding operating system partition of the target hard drive for the command.

bcdboot W:\Windows /s S: /f UEFI

You have completed 2 out of 3 partitions of the target hard drive. The last partition is the recovery partition. By default this partition is hidden and not assigned free characters so I will assign any character to it.

As long as the character does not match the characters already used. Here I assign the recovery partition of the source hard drive the character E.

diskpart
list vol
select vol 3
assign letter=E
list vol
exit

How to Clone Windows 11 to another Hard Drive using Command Prompt

In the recovery partition of the destination hard drive, create a new folder called WindowsRE. After getting the new folder you copy the files from partition E to partition R including hidden files.

md R:\Recovery\WindowsRE
xcopy /h E:\Recovery\WindowsRE\Winre.wim R:\Recovery\WindowsRE
exit

At this point you have done most of the work.

Next, turn off the computer and remove the source hard drive to check the results. You go to your computer's BIOS and make sure the computer boots from the new hard drive.

How to Clone Windows 11 to another Hard Drive using Command Prompt

After booting you will add a few commands to get the job done. As you can see the Windows operating system boots successfully without you needing to reinstall the operating system.

How to Clone Windows 11 to another Hard Drive using Command Prompt

With this method, it will help you clone your hard drive without using any software. In addition, you will better understand what partitions the Windows operating system has and what it is used for.

These commands are available on the Windows operating system, you just need to use it correctly. However, your system recovery partition is not working properly if you have not used the following commands. You open the command window and execute the last commands to get the job done.

reagentc /setreimage /path E:\Recovey\WindowsRE /target C:\Windows
reagentc /enable
reagentc /Info

How to Clone Windows 11 to another Hard Drive using Command Prompt


Facebook: https://www.facebook.com/routerbest

Twitter: https://twitter.com/routerbestcom

Tags: Windows 11