Now that I have installed winXP I think it’s time to back it up.

Summary

[Backup]
~$ sudo time dd if=/dev/hda1 ibs=4096 | bzip2 -v --fast | split -a 2 -b 1024m - winxpsp2.img-part-

[Verify backup files]
~$ md5sum /dev/hda1

~$ cat winxpsp2.img-part-* | bunzip2 | md5sum

[Restore]
~$ sudo time cat winxpsp2.img-part-* | bunzip2 | dd of=/dev/hda1

Detail

The dd command seems to be the way to go, but it backs up empty space as well, so I am using the compression tool bzip2 to ensure I don’t waste too much space. I’ll be storing the backup files on my network file server share.

First I’ll have to mount my file server shared directory:
~$ sudo mkdir /media/fileserver
~$ sudo mount -t smbfs //server01/shared /media/fileserver -o username=WindowsUserName,password=WindowsPassword

This command failed with the following error (grrr):
smbfs: mount_data version 1919251317 is not supported

After a quick google session I found that it means the smbfs package is not installed. I installed smbfs via: sudo apt-get install smbfs then executed this again:
~$ sudo mount -t smbfs //server01/shared /media/fileserver -o username=WindowsUserName,password=WindowsPassword

Now we are ready to backup not just the windows installation, but the entire partition that it is installed on.

The command to back up the partition is:
~$ sudo time dd if=/dev/hda1 ibs=4096 | bzip2 -v --fast | split -a 2 -b 1024m - winxpsp2.img-part-

Where sudo time dd if=/dev/hda1 ibs=4096 means:

sudo Super user do. That is, do the following command as the root user.
time Report how long the commands took
dd Disk Dump (as far as I know)
if In file
/dev/hda1 A reference to the partition that has windows on it
ibs Input byte size. That is, read 4096 bytes at a time
   

The results of the above commands are then piped into the bzip2 compression tool where bzip2 -v --fast means:

bzip2 Name of compression program
-v Do verbose logging (a bit pointless when piping – it really shouldn’t be there)
–fast Do fast compression. basically means it’s compressing smaller block sizes, which leads to sub-optimal compression. 7.5GB is still going to take about 2 hours on my AMD 2500+ CPU

The output of the compression tool is then piped (yet again) to a tool called split that splits large files into smaller ones. It uses the following syntax split -a 2 -b 1024m - winxpsp2.img-part- where:

split Name of splitting program
-a 2 The number indicates how many suffixes to use in the output file name. Say I split a large file into 3 pieces. I can use -a 1 to give me three files called filea, fileb and fileb. Using -a 2 would result in three files called fileaa, fileab and fileac.
-b 1024m Indicates the maximum size of each split output file – in this case 1024MB (1 gigabyte)
- winxpsp2.img-part-: The first dash means read from standard input (or piped input – same thing really). Usually you could put the name of a file to split. The ‘winxpsp2.img-part-‘ bit means to name each file winxpsp2.img-part- followed by the specified amount of suffices. In this case winxpsp2.img-part-aa, winxpsp2.img-part-ab, … winxpsp2.img-part-ah.

Eventually I guess I’ll do something silly and trash Windows XP. If that is the case I should be able to restore it by:
~$ sudo time cat winxpsp2.img-part-* | bunzip2 | dd of=/dev/hda1

Tada! A brand new windows installation in mint condition.

Comments are closed.