Saturday, May 21, 2011

Image backup of Windows XP with diskdump - dd

Today I set up a Thinkpad T60 with a clean install of Windows XP SP3. Because there ar no real nice built-in features for backing up the whole disk as an image file in XP, I used the famous dd for that. I took an gparted live cd, but any live linux should do the trick.
First mount the media where the image should be copied to
me@linux:~>mount /dev/sdb1 /mnt
and create a folder where you want to store the image file
me@linux:~>mkdir /mnt/Backup
and now copy the whole disk with dd
me@linux:~>dd if=/dev/sda1 bs=1M | gzip -c > /mnt/Backup/sda1.gz
To save a lot of disk space I piped the dd output through gzip. This stored the image of an 60GB hard disk with 14GB of used space into a 10GB image file. Without zipping one would store the whole 60GB. To restore the backup to the disk you could use
me@linux:~>cat /mnt/Backup/sda1.gz | gzip -d | dd of=/dev/sda bs=1M
Finally just out of precaution I also saved the MBR of the hard disk to a file
me@linux:~>dd if=/dev/sda of=/mnt/Backup/mbr.img bs=512 count=1
In case of emergency I would copy it back with
me@linux:~>dd if=/mnt/Backup/mbr.img of=/dev/sda bs=512 count=1

As always, be very careful if you don't know what you're doing and RTFM. Messing with dd and hard disks can easily kill your weekend.

cheers

No comments: