DISCLAIMER: Why would you take a drive out of a never-been-booted, brand new computer and mess with it? You could totally mess up your drive and your Windows installation for your brand new computer! Proceed at your own risk! You should be fairly familiar and comfortable working with and setting up disk partitions.
Clonezilla: I could not find a boot image that would work from a USB flash drive. (Tried it on two different computers.) However, System Rescue CD (on CD or USB) has never failed me.
System Rescue CD contains GParted, which I found to be totally adequate for what I needed to do. The version of GParted I used had the ability to create GPT bootable volumes, as well as the older, traditional MBR type boot records. (I wanted to stick with GPT/UEFI booting.)
What didn't work: using dd to try to copy a partial disk or a partial partition, or the boot sector code. Wasted a lot of time here.
I rigged up a system that I booted from my USB SystemRescueCD flash drive (if you don't know how to do that, you shouldn't be trying this). I also connected the factory 1 TB HDD (still sysprepped, never-been-booted), and the new 256GB SSD I planned to migrate the installation to - both of these drives via SATA cables to the motherboard.
WARNING: if you accidentally boot from your sysprepped disk, it will proceed to install. I was careful not to do this!
Inside the SystemRescueCD window environment (which you can get to by typing
startx) I ran GParted, which scanned all disks connected to the system. I set up the SSD to be a GPT volume, and then I recreated each partition from the HDD to the SSD, down to the exact size and sector.
There was one partition that GParted could not read; it said it was a 'Microsoft system partition' of type 'unknown.' I created an NTFS partition of the exact same size instead, and then later used dd to copy the 'unknown' partition from the HDD to the SDD.
The tough part comes when we try to copy the large main partition of the HDD, shrinking it down to be able to fit on the smaller SSD. My factory HDD had two recovery-type partitions at the end of the disk; I copied those partitions to the end of my SSD, and then checked what space I had left in the middle of the SSD that was available for the main data partition (just a little over 200GB).
Read the disclaimer at the top again. We're talking about shrinking the partition on the factory HDD which has never been booted. If we mess things up, then we messed up our factory HDD image, and there's no recovery from that (unless you have a way to make a backup). If I had had enough disk space on another disk, I would have backed up or made an image of the big data partition on the HDD. Even though it was over 800GB in size, there was less than 50GB of data on it. I tried using PartImage which supposedly only backs up the occupied sectors and not the blank ones, but it still wanted to back up to a roughly 425GB image file, which I didn't have. In any case, it would be best to back it up before proceeding, just in case.
I have successfully resized NTFS partitions in GParted before, so I knew I could shrink the 800GB+ down to 200GB without any data loss. So that is what I did. First I tried making it exactly the same size, but GParted would not copy the partition over unless the target space was slightly (7MB) larger than the source partition. Then I copied the shrunk partition from the HDD over to the SDD.
Next, still in GParted, I set all the flags and volume names and labels of partitions on the SSD to match exactly what was on the HDD - the only difference was the size of the main large partitions.
Then, I installed the SSD in our new computer, and fired it up. I was greeted by a blue screen stating:
Your PC needs to be repaired
An unexpected error has occurred
Error code: 0x0000225
So I followed these instructions and booted from a Windows 10 USB install media, and went into the advanced options to a command prompt, and executed
Look at the output, and make a note of two things: 1) the drive letter assigned to your main Windows partition, and 2) a volume that is FAT32 but not assigned any drive letter (it may or may not have a label; mine was called SYSTEM). One of the volumes shown is your USB recovery media - be sure not to use that one for any of the following steps.
Still in DISKPART, select the volume that does not have a drive letter by typing
select volume 3 (yours may not be 3, but mine was). Then type
assign letter=z. Now we've assigned the drive letter of Z to that partition.
EXIT diskpart and type:
BCDBoot c:\Windows /s z: /f UEFI
One caveat here: the above statement references c:\Windows as the location of the boot files, but if DISKPART showed that your main Windows partition was assigned to a different drive letter, then use that drive letter instead of c: in
Hopefully it returns something like
operation completed successfully. If it returns an error like
Failure when attempting to copy boot files, make sure you're reference the correct location of
\Windows on a drive letter mapped to your main Windows partition.
Then I rebooted, and was greeted with a Windows boot loader screen that asked my which volume I wanted to boot from - both volumes said 'Windows 10' but the default one said 'Windows 10 - volume 3.' When I booted from that volume, the system proceeded to do its first-time "Out of box experience" setup of Windows 10 - only from the SSD I purchased, not the factory HDD that came with the new computer.
Since there should be only one bootable operating system on this new drive, I plan on using msconfig or BCDedit to delete the other Windows 10 boot option so I don't have to select it every time on boot.