Actually, I consider
partimage to be the best "ghosting tool" to use for Linux or Windows systems.
The part about setting up the partitions used to give me the fits until I found out you can use
sfdisk to save and restore all or part of the MBR. That means you don't have to manually enter the partition table.
The reason I run sfdisk and dd... to save and restore the mbr is incase there are any issues with extended partitions. ( that's what I read anyway )
Here's how I do it.....
If you are going to clone an NTFS partition, you may want to run defrag and scandisk first.
Get a cd bootable version of linux like system rescue at
http://www.sysresccd.org and bootup with that cd.
Mount the partition where the images are going to be saved to.
mount /dev/hdb1 /mnt/images/backup -t ext3
Run partimage to make the images and save it to the backup directory which was created in the previous step.
In this example, I have a dual boot system so I backed up both operating systems with partimage.
Save the ENTIRE PARTITION TABLE to a file using sfdisk.
sfdisk –d /dev/hda > /mnt/images/backup/partfile
Save the MBR to a file...
dd if=/dev/hda of=/mnt/images/backup/mbrfile bs=512 count=1
The clone script will restore that partition table and MBR from files to the new hard drive using the commands:
sfdisk /dev/hda < /mnt/images/backup/partfile
dd if=/mnt/images/backup/mbrfile of=/dev/hda bs=512 count=1
After you have saved the images and the partition table, install the new hard drive, make sure that bios sees it as the /dev/hda ( Primary Master ) so you don’t accidently zap your backup images which are saved on the /dev/hdb ( Primary Slave ) .
Bootup with the rescue cd and run the clone script to restore the images to your new hard drive.
Code:
#!/bin/bash
#
clear
echo
echo "********************************************************************"
echo " Caution!!! This program will erase your hard drive"
echo
echo -n " Do you want to proceed (Y/N)?"
read answer
if test "$answer" != "Y" -a "$answer" != "y";
then exit 0;
fi
#
clear
#
#Erase the old boot sector
dd if=/dev/zero if=/dev/hda bs=512 count=1
#
#Restore the partition table from file
sfdisk /dev/hda < /mnt/images/backup/partfile
#
#Restore the MBR from file
dd if=/mnt/images/backup/mbrfile of=/dev/hda bs=512 count=1
clear
#
#Restore the images with Partimage
partimage restore -b -z2 -f3 /dev/hda1 /mnt/images/backup/windows.000
#
partimage restore -b -z2 -f3 /dev/hda2 /mnt/images/backup/linux.000
#
clear
echo "Image restore is complete"
echo
#
#End