Using Knoppix and the dd utility to restore a WinXP partition Image to a Hard Disk

Written by James McDonald

June 16, 2007

These are my notes on how I successfully restored a Windows XP image I took of a partition.

I can’t remember how exactly I took the partition image of the Windows XP installation. I can remember the following points

  • I was dual booting at the time and I needed the XP partition to increase disk space for linux
  • Image was taken from within Linux
  • It was taken with either dd if=/dev/hdb1 of=imagename.img or cp /dev/hdb1 imagename.img
  • I confirmed a successful partition copy using md5sum /dev/hdb1 and then md5sum imagename.img. The resulting MD5 sums need to be exact
  • The resulting image was stored on hard disk uncompressed

The restore was to a machine which was dedicated to Linux. It has two harddisks hda and hdb. I used a bootable Linux CD with all the utilities I needed to make the changes. I used PING but ran in to trouble with it’s gui and ended using the shell it provides. You could just as easily use Knoppix which has all the same utilities.

  1. Boot using CD
  2. Map drive to computer that is hosting the disk image. Use mount -t smbfs //hostname/share /mnt/mountpoint -U remoteuser%password
  3. Using fdisk or cfdisk. Delete the Linux partitions on one disk. I chose hda which is a 20GB HDD
  4. Find out how many kilobytes the image file is. Using ls -lk imagename.img. I came up with a figure of 8193119 kb (approx 7gb)
  5. Create a new primary partition using fdisk. Start the partition at the default cylinder 1 and then specify a size using the format +8193119K. Set the partition type to hex 07 which equates to NTFS/HPFS. Set the partition bootable flag to be on. Write the new partition to disk and exit fdisk
  6. using dd restore the data to the new partition. dd if=imagename.img of=/dev/hda1 bs=64k
  7. The dd will take about 45 minutes to an hour for an image that (7.8GB) size
  8. When dd returns. reboot the computer using a Windows XP installation CD. Type r to get into the recover console… Note: you will have to know the administrator password for the XP installation. If you don’t you will need to use a Linux utility to reset the XP admin password. I think it’s called ntpasswd.
  9. In the windows XP recovery console I ran fixmbr and fixboot. This replaces the master boot record that until now was a linux one. I don’t know which command had the desired effect. I ignored the warnings that came up about making my installation unbootable
  10. The above gave me a bootable Windows XP installation. I was prompted to re-activate Windows. Which I did.

After getting a bootable Windows XP installation I noted that 8GB is too small for a windows XP installation with all the bells and whistles so I decided to enlarge the partition to the full size of the disk as follows. I have also put the following in it’s own post because they can be performed as too separate operations

  1. Boot from my trusty Linux boot CD again
  2. Run fdisk and delete the Windows XP partition and recreate a partition the full size of the disk
  3. Remember to reset the partition to a type of 07 and set the bootable flag
  4. run ntfsresize --info /dev/hda1 to get info on the disk
  5. run ntfsresize -v -s <SIZEINBYTES> /dev/hda1
  6. I first tried to specify the partition size in the MB and ntfsresize complained that I was trying to resize to a size bigger than the partition. Looking at the output carefully showed that I was specifying a partition with more bytes in it than the physical partition had even though they displayed the exact same MB size I assume this was due to rounding so I switched to bytes and made it exactly same as the partion bytes and ntfsresize ran with out complaint.
  7. Once this was complete I rebooted back into Windows and it ran a disk check.

Restoration and Disk Space Upgrade Complete!

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

You May Also Like…

PDF Poster

PDF Poster

Start with a wide long image. This is just a screen shot of my desktop. widescreen.png Convert it to postscript using...

Scribus to PDF Print

Just using Scribus to design and print some lapel cards Regarding Scribus - It seems that the stable version will not...