22
Oct
2015

Use Linux to move a Windows Installation to another drive!

So, you have a cranky old 2.5″ 160GB drive with Windows on it that just won’t do (yes, this is what I had for a long while). Its time for a drive upgrade! But you don’t want to reinstall Windows to the new drive! That’s just more work than it needs to be. Fortunately, there’s a better way.

You can use a Ubuntu Live USB stick for this, follow this guide on how to make one!

What this guide will show you how to do is directly transfer a Windows installation from one drive to another. You will need BOTH drives connected to the same PC for this to work (you could do it with some networking, but that’s beyond the scope of this tutorial).

The first thing you want to do is make sure that your Windows installation is smaller than the target disk. If you’re moving to a bigger drive you can skip this step. You’ll need to move some stuff off the Windows drive then shrink the partition using GParted:

Screenshot_2015-10-22_16-37-24

Once your Windows partition is small enough (I advise making it 2-5 GB smaller than the target drive), you can start to transfer the partitions over. It’s not entirely straightforward, however.

Above you can see that Windows creates multiple partitions for stuff like boot partitions. We need to mirror those partitions over to the new drive.

The first thing that you’ll need to check is that there is nothing on the new drive. Doing this will overwrite it. If you have a new drive, work away. If you have a used drive, it doesn’t hurt to scrub the drive first.

The next thing is to set the new drive up with identical partitioning. Use the following command to do this:

sfdisk -d /dev/sd<source> | sfdisk --force /dev/sd<target>
sfdisk --re-read /dev/sd<target>

The above commands use sfdisk to send over the partition structure to the new drive. Make sure you don’t get the labelling mixed up. If you do you will end up losing the partition structure to your current Windows drive. Your source drive could be /dev/sda and your target drive could be /dev/sdb – or it could be the other way around. Double check. Install gnome-disk-utility to help you.

Once it’s sent the partition structure over, you can use the following command to snapshot the partitions over:

dd if=/dev/sd<source>x of=/dev/sd<target>x

…where x is the partition number of each partition you are sending over. Again, make sure you get the labelling right or you’ll end up wiping your old drive. Start from /dev/sda1 and move upwards to /dev/sda2 etc. This will take a while depending on the size and speed of your drives.

Okay, you’ve made it this far. The good thing about this process is that you still have a working Windows drive, and a new drive with the same copy of Windows on it. The next thing we need to do is boot the new drive!

When I did this, I had a boot error (something to do with an inaccessible drive). You’ll need to fix this by booting the Windows install DVD/USB drive and doing a startup repair (it should find the problem straight away and fix it). This error might or might not happen to you, but if it does you can fix it easily enough.

The next thing you should notice is that the new Windows drive is the same size as your old drive/shrunk partition. You can expand the drive using the Disk Management console in Windows, or Gparted in Linux (I used Gparted and that worked fine).

The last thing:

lel

If  your old drive was full, do a defrag! If you’ve moved to an SSD, don’t bother doing this. You can see from above that my 160GB drive was horribly fragmented and all this had been moved to the new drive. You can see how the 160GB partition only sat at the top of the new 500GB drive. After Defragglering the new drive (which took 9 hours), your system should reap the benefits of getting a new drive! You could also defrag the drive before doing this process (best if you’re moving to an SSD), but it’s better to do it after to make use of the extra room.

Remember, if all goes south, you haven’t modified your old Windows drive in any way! You can still boot from it and use it the exact way as before (I’ve put mine away in a cupboard as a backup). This won’t mess up your Windows Activation since not enough components have been changed – only the boot drive, so as far as it’s concerned it’s in the same computer.

I hope this helps, post comments if you want help or if you have questions!

Great Scott!
Updating to 15.10

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.