Thursday, March 22nd, 2007

Migrating Windows XP to a larger laptop hard disk

715 words, 1 image

I ran out of space on my laptop, so I put a new disk drive in. Too tight to buy Ghost or anything like that, I elected to migrate my old stuff using Open Source tools. All the tools I needed were on SystemRescueCd.

That's more like it

I did hit a few issues, and I didn’t find an end to end recipe on the Web (although everything’s there, scattered around), so here’s what eventually worked for me: maybe it will work for you. Be very careful though, and make sure you understand what you’re doing. You are using tools that are capable of trampling over your data very roughly.

Preparation

  • I got the new drive on eBay. It was something like £1 extra to buy a laptop drive in a USB caddy, so that’s what I got.
  • Plug the USB caddy into the laptop
  • Boot from SystemRescueCD - choose the standard Linux boot option
  • Internal disk is /dev/hda ; USB disk is /dev/sda
  • Windows is on a partition within /dev/hda — /dev/hda1

Gathering info on the source partition

  • Run “parted /dev/hda”. Type “help” for usage guidance.
  • With parted, enter “print”, and make a note of your Windows partition’s properties.
  • Quit parted without making any changes.

Preparing the destination drive

  • Run “parted /dev/sda”.
  • Within parted, delete any partitions put there by the manufacturer, and create a new partition for your new copy of the Windows partition. Make it the same as the old one: same size, same position, same everything.
  • Quit parted

Copying the data

  • Copy your Windows partition using the command: ntfsclone -O /dev/sda1 /dev/hda1
  • If this succeeds, great. I got errors indicating that hda had hardware issues. Good timing! Repeating with extra options allowed the copy to complete: ntfsclone –rescue -O /dev/sda1 /dev/hda1
  • We now have a copy of the old Windows partition on the new disk. In theory this could have been achieved in one step using the graphical “gparted”, but that precludes the “–rescue” option to ntfsclone.
  • Do not let old Windows see your new partition. By which I mean, don’t boot Windows from the old drive, while the new drive is plugged in too. It will assign a drive letter to the new partition. It won’t be C. This will cause you pain.
  • Run “ntfsfix /dev/sda1″ — this tells Windows to run chkdsk, which is probably for the best.

Installing the new drive

  • Shut down the computer. Get a screwdriver, and swap your new disk and your old disk around. That is, old disk goes in the caddy, new disk goes in the computer. This is easy if your laptop was designed properly…
  • Ensure the caddy is not plugged into the computer, and try booting up. If Windows boots (and works properly), you are a winner! Skip ahead to the bit where the rest of the class can also boot Windows.

Mending the boot record (not always required)

  • Shut down, plug in the caddy and boot SystemRescueCD
  • This time, the new disk is /dev/hda and the old disk is /dev/sda
  • Copy the Master Boot Record from the old disk to the new one, as follows: dd if=/dev/sda of=/dev/hda bs=512 count=1
  • Shut down, unplug the caddy, power up. Windows should boot. If it doesn’t you didn’t make the new partition sufficiently similar to the old one. Either start again and be more careful this time, or delve into the murky world of bootloaders (you ought to be able to coax Grub or Lilo to boot this partition).

Growing the new partition

  • This is where the lucky people who booted Windows first time can rejoin.
  • We are now able to boot Windows on our new hard disk. But the new partition has no more space than the old one. What’s the point of that?
  • Shut down and boot from the SystemRescueCd again.
  • This time, hda is the new disk. The old disk is not plugged in.
  • Run “startx”. You should go into the X Windowing System. Type “gparted” in the terminal window.
  • GParted will launch and take an unexpectedly long time to scan for devices.
  • Select hda, click on the hda1 partition, click “move/resize”.
  • Drag the right hand side of the partition as far as you want — I went all the way, but you could leave room for other partitions if you like
  • Do not move the left hand side of the partition anywhere!
  • Click “apply”
  • Some stuff will happen. About 5 minutes later, your partition should be resized.
  • Let GParted scan again, close it, shutdown
  • Power on. Windows should now have lots of extra disk space.

Leave a Reply



Spam Karma 2 has sent 82918 comments to hell and 204 comments to purgatory. The total spam karma of this blog is -25684. What's your karma?