Skip to content
 

Moving a NTFS Windows XP installation to a new harddrive

This weekend I’ve been trying to move Esther her Windows XP installation from a NTFS partition to a new, larger harddrive.

Initially I tried doing this using a Clonezilla live CD, by letting Clonezilla create an image of each partition (the Windows XP installation, the rescue partition, etc.) to an USB drive. Restoring the images to the new harddrive failed because there appeared to be some bad sectors on the old harddrive.

After this I used SystemRescueCd to manually clone the Windows XP installation:

  • Create an image of the Windows XP partition (in my case the 2nd partition, /dev/sda2) using --rescue to ignore bad sectors: ntfsclone --rescue --save-image --output sda2.img /dev/sda2
  • Replace the old harddrive with the new harddrive
  • Recreate the partition table on the new harddrive. Apparently Windows will not (easily) boot if the partition number or starting sector is different. As the 1st partition was only 100 MB large, and Clonezilla already recreated the partition table, I’ll restore the image to the 2nd partition.
  • Restore the image: ntfsclone --restore-image /dev/sda2 sda2.img
  • The bad sectors are also copied to the new harddrive, but do not exist there. Reset the bad sector list using:
    • ntfsinfo -i 8 /dev/sda2 and write down the "Allocated size" close to ‘$Bad’
    • ntfstruncate /dev/sda2 8 0x80 '$Bad' 0
    • ntfstruncate /dev/sda2 8 0x80 '$Bad' "Allocated size"
  • Reboot into Windows and check the harddrive for bad sectors (by right-clicking on the harddrive, Settings, TODO
  • Reboot into SystemRescueCd
  • Resize the partition to cover the rest of the harddrive
    • Start fdisk: fdisk /dev/sda
    • Set the display units from cylinders to sectors: u [enter]
    • Delete the partition (in my case the 2nd partition): d [enter] 2 [enter]
    • Recreate the partition: n [enter] p [enter] 2 [enter]. By default the 1st sector is the 1st sector of the deleted partition, and the last sector the last sector on the disk, so [enter] [enter]
    • Set the partition type to HPFS/NTFS: t [enter] 2 [enter] 7 [enter]
    • Set the 2nd partition active, so that it will be booted: a [enter] 2 [enter]
    • Write the partition to disk: w [enter] and quit: q [enter]
  • Resize the filesystem to fill the enlarged partition (by default the filesystem gets resized to the entire partition): ntfsresize /dev/sda2
  • Boot into Windows

Leave a Reply