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.imgor
cp /dev/hdb1 imagename.img
- I confirmed a successful partition copy using
md5sum /dev/hdb1and 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.
- Boot using CD
- Map drive to computer that is hosting the disk image. Use
mount -t smbfs //hostname/share /mnt/mountpoint -U remoteuser%password
- Using fdisk or cfdisk. Delete the Linux partitions on one disk. I chose hda which is a 20GB HDD
- 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)
- 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
- using dd restore the data to the new partition.
dd if=imagename.img of=/dev/hda1 bs=64k
- The dd will take about 45 minutes to an hour for an image that (7.8GB) size
- 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.
- 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
- 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
- Boot from my trusty Linux boot CD again
- Run fdisk and delete the Windows XP partition and recreate a partition the full size of the disk
- Remember to reset the partition to a type of 07 and set the bootable flag
ntfsresize --info /dev/hda1to get info on the disk
- run ntfsresize -v -s <SIZEINBYTES> /dev/hda1
- 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.
- Once this was complete I rebooted back into Windows and it ran a disk check.
Restoration and Disk Space Upgrade Complete!