A free utility backup image of the hard drive
PartImage http://www.partimage.org/Main_Page is a free utility that can create a full image backup of a hard drive.
PartImage is included on the bootable SystemRescue CD http://www.sysresccd.org (You need to download and burn system rescue tool onto a blank CD.
You may have to change your BIOS setting to allow your computer to boot from CD
NOTE: you cannot restore to a hard drive that is smaller than the original imaged drive. Restoring to a larger hard drive may require GParted to resize to fill the drive.
NOTE: This is not a "universal restore" to different hardware, this restores to the the OS configured for the previous hardware.
YOU MAY HAVE TO RESTORE THE MBR FROM THE IMAGE FILE AS WELL?!?!?!?!?! EXCEPT if the disks are not of the same size (e.g. we have created a new partition and moved disks etc.)
- Boot from the systemrescue CD then type "rescuecd docache" (boot the CD into RAM and use 40 (uk) as the language).
- "wizard" at the command prompt autoconfigures and starts the friendly GUI.
- The fdisk -l command from the command line quickly displays detected drives.
OR use GPARTED GUI, on the lower left menu bar, to examine the attached Hard Drive Devices (the upper right must be "selected" like a drop down to choose the current device and see it's partitions.)
/dev/hda is used to tell the pc which drive you are examining.
Different types of hard drives are recognised depending on the type of interface used to connect it to the motherboard.
So IDE is usually /dev/hda (a second IDE device would be /dev/hdb, a third, /dev/hdc) while sata or USB Stick hard drives are /dev/sda (and sdb, sdc, etc.)
The number at the end, e.g. hda1 identifies the partition.
Use the terminal console to mount the external usb drive (the target location to store or restore the backed up image file).
mount -t auto /dev/sdb1 /mnt/sdb1 (i.e. commands for a FAT32 usb stick)
To mount an NTFS drive, use the ntfs-3g /dev/sdb1 /mnt/windows (depending on what the external ntfs hard drive is labelled in Gparted).
After mounting ensure that everything is visible by the commnands cd /mnt/windows ls
You can also use midnight commander to create another folder that you will dump the Image into or check if you can see the target mounted location (e.g. external drive).
.. The 2 dots means go up a directory until you see sdb1 which is your external hard drive you want to back up to. The folder "/mnt/windows" is now on the mounted external drive. When you mount the drive it gets recognised as /mnt/windows
umount is the command used to unmount drives from the OS
/mnt/windows is an empty folder where the OS interfaces with the new hardware
unmount the drive that will be saved/copied to an image
(if it holds the swap then make sure the swap is off,
Partimage, from the left corner CD icon System Menu, is the disk image backup program. Press TAB to move between built in menu options.
sda1 is the drive and partition to save/restore.
/mnt/windows/linux-currentdate-backup.partimg.gz as the image file to create/use as the location to backup.
Then press F5 (to continue/start the process).
You could leave the defaults and press F5 to continue.
It takes 12 minutes to back up 3.6GB of data.
After backup is finished go back to the console and unmount the drive by typing umount /mnt/windows.
F6 exits PartImage.
Then enter halt or shutdown to reboot.
Prepare the target restoration hard drive. If you have new hard drives (or a new RAID mirror Array) you may have to "format" it.
partimage details: choose the device/partition to backup
write in the output file (e.g.) /mnt/sda1/winbackup.partimg.gz
e.g. choose sda1 as the partition to save/restore to.
(fdisk -l) should have told you where you want to put your data.
NOTE: You may have to create a partition if the space is unallocated (and without a part table), e.g. use GParted or fdisk!
It took 5 minutes to make a /dev/sdb1 60GB partition with Quad core 3GB RAM...
Under Image file to create/use fill in the location & filename of your backup file:
Then under, "action to be done" select restore partition from an image file option. Once you're SURE everything's correct Press F5 (to continue/start the process).
Deselect the two options at the top and the click F5 to continue
It took about 12 minutes to restore 3.6GB of data.
You could encounter a problem accessing the external drive or after using linux stating that the external drive has not been removed properly.
To resolve: connect the usb HD to a windows machine and safely remove the drive.
backup the MBR (the first 512 bytes which are crucial to loading)
dd if=/dev/hdb of=/dev/hda bs=446 count=1
Optional: We should try to enable DMA on both disks, to increase the transfer speed.
# hdparm -d 1 /dev/hda /dev/hda: setting using_dma to 1 (on) using_dma = 1 (on) # hdparm -d 1 /dev/hdb /dev/hdb: setting using_dma to 1 (on) using_dma = 1 (on)
try to use gzip (bzip2 has some errors with mbr? and is slow?)
(took a 4 GB partition with 819 MiB data to 300 Mib image in half an hour with 333 Mhz and 32 MB RAM)
Mount the Source Image file Drive (e.g. the external source USB HD).
mount /dev/sdc1 /mnt/windows partimage
F6 at any menu to exit without doing anything
Highlight the Target partition (Restore to Here) press Tab
Type in the path to the source backup file (e.g. /mnt/windows/12sep2008.partimg.gz.000) press Tab
Use the arrow keys and space bar to select the action: Restore partition from image file press Tab
DON'T ACCIDENTALLY BACKUP INSTEAD OF RESTORING - you will overwrite your backup!!!!
F5 (Next) shows the Partition Description (12sep2008backup)
Options (Simulate is useful if you're not sure what will happen with a backup/restore)
Usually Wait after finishing is recommended (you can see the results).
F5 (Next) shows information from the image file (e.g. Ext3fs 7% usage = 4.15GiB, 447 groups)
Note that this technique will actually "uncompress" and can result in a "defragmented" drive
Copy the image file to the newly restored HD and unmount/unplug the external usb HD (no mistakes!) umount /mnt/windows
Then, from the command line enter ./partimage restmbr /mnt/windows/linux-currentdate-backup.partimg.gz
To reboot enter the command: shutdown -r "now"
If you have not written down how large your swap partition is BE AWARE that you should recreate a swap partition for your linux... (It's easy with GnuParted, just choose to create a new partition of type linux-swap, size = about1.5x RAM)
You may also have to update your /etc/fstab file to indicate what partitions are where, e.g.
/dev/sda1 / ext3 /dev/sda2 none swap
And the floppy line was deleted... OR DO we have to create grub all over again? (GRUB is pretty good at detecting everything...)
mount /dev/sda1 /mnt/backup grub-install --root-directory=/mnt/backup /dev/sda
showed an incorrect setting of hd1,0 which I changed to hd0,0 because we now only have 1 mirrored hd!
I had to modify, nano /mnt/backup/boot/grub/device.map to remove the extra device I also modified, nano /mnt/backup/boot/grub/menu.lst to use (hd0,0) instead of (hd1,0)
when booting you will see the GRUB menu for about 10 second and can choose 'e' to manually boot in with a one time customized changes
MBR backup and restore tricks
To duplicate the MBR of /dev/sda (only if using IDENTICAL model disks.)
dd if=/dev/sda of=/mnt/tmp/mbr-sda.bak bs=512 count=1
- Then 'p' to see what's on the partition/hard drive
- Then 'n' for new partition
- Then '1' for primary
- Then use the defaults to fill up the hard drive (e.g. 1 large partition)
- Then 'a' to toggle that partition as bootable
- Then 'p' to check that everything looks right.
- Then 'w' to write your changes and exit.
Note you can cancel at any time without making any write/changes).
Note, you won't be mounting the target drive).