It happened, it finally happened. You ran smartctl -a
and your disk is dying, with SMART errors all over the place. You don't want to reinstall your OS and start from scratch. Fortunately, you have a new disk ready to take over while it's not too late. You format it and copy the data over and... it doesn't boot. Even if you manage to fix the bootloader, the boot never finishes - the screen is black, perhaps a cursor is available but nothing works, the boot spinner spins forever. You tried everything: ctrl+alt+del
, Windows+R
, nothing happens... Here you will learn how to move Windows partitions as a Linux user so it just works.
1. Prepare a Windows Recovery Image
We will need to fix the bootloader and system registry later on. The best way to do this is to download the official Windows installer and flash it on some kind of removable media using dd
. If you want to stay pure, you can try using Linux-specific tools for Windows like chntpw, but right now I would advise against it.
2. Boot to Windows and disable Fast boot
Shutting down Windows doesn't actually shut it down completely. This optimizes startup time but leaves the disk in a dirty and unsafe state. To ensure you don't corrupt your data and then spend time recovering your install, disable fast boot and make a full shutdown.
- Open the
Control Panel
, and click on thePower Options
icon. - Click
Choose what the power buttons do
on the left side. - Click
Change settings that are currently unavailable
on the top. - Ensure fast boot is disabled in the options list.
- Shut down the OS.
3. Clone the Windows partition
- Allocate your new partition
/dev/NEW
using your favorite tool, ensuring it has the same size as the old one. - Check that the NTFS partition you want to move is in a clean state with
ntfsfix /dev/OLD
and optionally take a checksum of it usingxxh128sum /dev/OLD
. xxHash is arguably the fastest way to do it, but you can use any hash algorithm you have available. - Clone it using dd:
dd if=/dev/OLD of=/dev/NEW status=progress bs=16M
. Ensure you don't make a typo, as you WILL lose data if you enter this command incorrectly. - Run
sync
to flush pending write buffers to disk and then optionally ensure the data got copied over correctly by checksumming it:xxh128sum /dev/NEW
.
4. Generate the bootloader
Ensure you have an EFI partition available (ESP). If not,create it. To boot your new clone, you need to place the Windows Bootloader onto your ESP and configure it to recognize the clone. The simplest way to do this is using the Windows Recovery Image.
- Boot the recovery image and select your language.
- Press
Troubleshooting
, thenAdvanced options
andCommand Prompt
. - List the available disks using
wmic logicaldisk get name
. - Use
dir <DRIVE_LETTER>:\
(for example,dir C:\
) to see what's on that disk. Find where your Windows install is available. - Mount the ESP:
mountvol S: /s
. This will mount your ESP under the drive letterS:\
. - Place the Windows bootloader on the ESP:
bcdboot <CLONE_DRIVE_LETTER>:\Windows /l en-us /s S: /f ALL
, and DON'T REBOOT until you read to the end. - (Optional) To inspect the current configuration of the installed Windows Bootloader, run
bcdedit /store S:\EFI\Microsoft\Boot\BCD
. You can also enable safeboot:
5. Update Drive Letter Mappings
Windows maintains a database in the system registry under HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices
which tracks historical drive assignments using device serial numbers and partition UUIDs, similar to /etc/fstab
on Linux. When we move to new hardware, these identifiers change. For reserved drive letters like C:\
, their mapping needs to be set correctly, or Windows will silently fail to boot. No error message, just a black screen and frustration... By removing the old mapping from the registry, we tell Windows to regenerate it on the next boot.
- While still in the shell, mount the clone's registry hive:
reg load HKLM\OFFLINE_SYSTEM <CLONE_DRIVE_LETTER>:\Windows\System32\config\SYSTEM
. - Launch the registry editor by entering
regedit
. - Navigate to
HKEY_LOCAL_MACHINE\OFFLINE_SYSTEM\MountedDevices
. - Locate and remove the
\DosDevices\C:
entry and any related symbolic links. If you want to be safe, you can even delete everything except the default entry. - Unload the modified registry hive:
reg unload HKLM\OFFLINE_SYSTEM
.
6. Enjoy your Windows!
The system should now boot successfully from the cloned drive. The first boot may take longer than usual as Windows detects and configures the new system location. If you encounter any issues with this tutorial, feel free to reach out to me, and I will be happy to provide more guidance.