defragging
Makes more sense to do this as part of a backup operation that
involves a second hard drive:
backup partition by copying it to folder on second hard drive.
verify backup using file by file compare (I use windiff)
format paritions
restore partition by copying it from folder on second hard drive.
verify restore using file by file compare (I use windiff)
I wrote my own copy program that retains date, time stamps, and
short file names for the files and directories copied, but I
assume that any of the "backup" utilities available on the
internet would do the same thing.
For the OS parition, you need to be running a second instance
of the OS (or a different OS) from another paritition in order
to be able to do operations on the primary OS parition.
In the case of Windows XP, and perhaps NT -> Vista, the folder
\windows\installer will self delete after a few minutes and/or
restarts. After this happens, restore \windows\installer from
the backup on the second hard drive and it won't get purged
again.
compaction (versus compression)
In databases and in some file systems, deleted files are simply
marked as deleted, and this leaves "gaps" in the data stream.
Compaction eliminates the gaps by "compacting" the data so
that all the empty gaps are filled with valid data.
using a second hard drive for defrag (or compaction)
Hard drives random access times are very slow compared to the
streaming transfer rates. If the number and size of gaps is
large enough, it's faster to copy all the data to a second
hard drie and then copy it back. Plus you now have a backup
of your data in addition to a defragged (compacted) paritition.