Migrate Windows 8.1 from an HDD to a smaller SSD

Over the last couple days I’ve fought to migrate my desktop computer operating systems to a new SSD, without reinstalling anything. I have a multiboot system containing partitions for Windows 8.1, Linux, and OS X, across two hard drives. Linux and OS X gave me no trouble, but Windows proved particularly hard to move and get working again, so I’ve made some notes here in case they can help someone else (or future me) down the road — not a total step-by-step, but an outline an experienced administrator could follow.

First, some notes on my particular situation:

  • The new SSD (240GB) is smaller than the old HDDs (500GB + 80GB), so all partitions need to be shrunk to fit.
  • My original Windows installation included a separate boot partition which preceded the main partition. In a perhaps-misguided effort to simplify things, I opted to omit the boot partition from the new disk.
  • This system has a BIOS, not UEFI, so I will be using an MBR partition table on the SSD rather than the more modern GPT.
  • Windows is on the first partition, and this should be known as C:.
  • GRUB is installed to the MBR and used to boot all three OSes.

Now, to the actual process:

I started off in Linux (Ubuntu, FWIW) to resize and copy the Windows partition.

  1. Use GParted or another tool to partition the SSD. Mark the Windows partition as boot/active.
  2. Resize (shrink) the old partition so it’s small enough to be copied to the target
    ntfsresize --size <size> <source_device>
  3. Copy data to the new partition
    ntfsclone --overwrite <target_device> <source_device>
    ntfsresize <target_device>
  4. Use testdisk to rebuild the NTFS boot sector with the new partition offset. I don’t know why the partition has to know about its own position, but that’s NTFS for ya.

Next, boot to a Windows 8.1 install/recovery USB drive and enter recovery mode. Under advanced troubleshooting, start a command prompt.

  1. Check the disk for consistency. The resize operation has already marked the volume for a check anyway.
    chkdsk /f c:
  2. Rebuild the bootloader to take the place of the old boot partition
    bcdboot c:\windows /s c:
    bootrec /rebuildbcd

If you stop here, where I was stuck for a long time, Windows will boot but will not show your lock-screen wallpaper and won’t load anything after you log in. There’s one more step which I didn’t discover until I poked around the registry and stumbled across the magic key:

  1. Clear stored drive addresses
    reg load HKLM\TempSystem C:\Windows\system32\config\SYSTEM
    reg delete HKLM\TempSystem\MountedDevices /va
    reg unload HKLM\TempSystem

And that’s it! If I remembered everything during this brain-dump writeup, your resized-and-moved Windows installation should now be able to boot from the SSD (with GRUB’s help). Two evenings’ worth of struggle condensed into a short list.

I read far too many articles and forum posts along the way to have kept track of all the sources that helped me. Although I’m grateful to all of the authors, unfortunately I can’t give proper credit where it’s due; I can only hope that by posting this, I can partially return the favor.

Good luck!