You can use the dd command to create an image of your windows partition. How large is it? How much space is taken up? You can also pipe the output of dd through gzip or bzip2 to compress it, however if the drive was filled previously, it won't compress very well because the bit patterns of the old files (before reformatting) are still present. One thing you could do is use something like a norton utility to zero the free space on the drive. However there is another (free) way of doing it.
I tried an experiment one time where I filled up a partition with files and then deleted the new files. The partition would not compress well. Next I filled the partition with a file of zero's (using the versatile dd program again) and then deleted these files. This had the effect of zero'ing most of the free space. The difference was dramatic.
You could produce such a file in linux and make several copies of it in windows, until you have very little free space left. Then delete these files.
Code:
Here is the command you can use to produce a file consisting of zeros:
dd if=/dev/zero of=zerofile bs=1024 count=$((40*1024))
40960+0 records in
40960+0 records out
41943040 bytes (42 MB) copied, 2.59414 seconds, 16.2 MB/s
[jschiwal@delllap ~]$ ls -lh zerofile
-rw-rw-r-- 1 jschiwal jschiwal 40M Nov 14 17:44 zerofile
I selected a block size of 1024 because that is the block size that utilities such as ls use. The "$((40*1024))" is how you perform arithmatic in bash. Since 1024*1024 is 1 MB, you can change the 40 to what you want and the file will be that many Megabytes in length.
Suppose that your Windows partition is /dev/sda1. Also suppose that you have an external usb drive mounted at /media/backups.
Note: If the length of the final backup would be greater than 4 GB, you wouldn't be able to use the FAT32 filesystem to hold the backup.
You could back up an image with:
Code:
dd if=/dev/sda1 bs=1024 | gzip - >/media/backups/WindowsXP.img.gz
If the partition is 30GB but you only use 8GB, the final file length will be less than 8GB
if you had zeroed out the partition. Otherwise it might be closer to 30GB than 8GB so you wouldn't be able to burn the file to a DVD.
I would prefer using an external drive for a backup than using DVDs.
The filesize needn't be constrained. Even if you formatted the drive using the FAT32 filesystem, you could pipe the backup through the "split" program to break it up into slices. Then you can restore the backup by cat'ing together the slices, using a wildcard in the argument name:
cat WindowsXP.img.gz.* | ...
Suppose that the image backup was small enough to burn to a dvd, and you have the dvd disc mounted at /media/dvd. Then you can restore the backup by reversing order of the commands you used to produce the backup:
Code:
cat /media/dvd/WindowsXP.img.gz | gunzip | dd of=/dev/sda1 bs=1024
You could also use the zcat program to expand the image:
Code:
zcat /media/dvd/WindowsXP.img.gz | dd of=/dev/sda1 bs=1024
Suppose you saved the image uncompressed to a file on an external drive:
Code:
dd if=/dev/sda1 bs=1024 of=/media/backups/WindowsXP.img
You could mount the image file and retrieve individual files:
Code:
mkdir /mnt/xpbu
mount -t ntfs /media/backups/WindowsXP.img /mnt/xpbu -o ro,loop
If the Windows partition (/dev/hdd1) is mounted somewhere using the "ntfs-3g" filesystem (read-write), you can simply copy from /mnt/xpbu to your windows system. So if a single dll became corrupted or infected, you could copy just that file from your image backup to your windows system. This is another reason to use an external drive for backups. You can pick up a NetDisk enclosure from Radio Shack for example for around $35 and put in a spare drive yourself. I'm sure on the net, they would be even cheaper.