HOWTO: Disk imaging using Partimage

From Sabayon Wiki
Jump to: navigation, search

How to backup disk partitions ("disk imaging") using Partimage

Partimage is a FOSS application for backing up disk partitions (a.k.a. disk imaging). Unlike the Unix/Linux dd command, Partimage only backs up the used blocks of a partition (there’s no point backing up empty blocks), and it also has an option to compress the backup if desired. It has other options, such as splitting the backup over multiple CDs, DVDs, Zip disks etc.

If you want to backup your core partitions they need to be unmounted, so use a LiveCD or LiveDVD with Partimage on it.

I think the best way to use Partimage is to download the ISO of the latest version of the Gentoo-based SystemRescueCd:

and burn it to a CD-R. I used K3b to burn it, but you can use Nero or any other method of burning ISOs (such as the method given on the SystemRescueCd Web site). I downloaded the file systemrescuecd-x86-0.4.2.iso from the above-mentioned site (this version works with both x86 and x86-64 CPUs).

Then read the online documentation for Partimage:

and specifically the Chapters 1 (Introduction), 3 (Usage: basics) and 5 (Backing up the partition table), plus Chapter 4 (Network support) if you're going to backup over a network. Note that Chapter 5 is very important otherwise the backups you make of your partitions will be useless:

I backup my laptop's HDD partitions (Windows XP and Sabayon Linux) to an external USB HDD as explained below. Note that, as some of your partitions will be bigger than 4 Gb, you cannot back them up to a HDD formatted as FAT32. So make sure you are backing up to a HDD that is formatted to support files bigger than 4 Gb (e.g. formatted as ext2, ext3, NTFS, etc.)

1. Set the BIOS of your PC so that the optical drive will boot first.

2. Insert the SystemRescueCd CD into the optical drive and restart the PC.

3. When the root prompt (%) appears, type the following:


4. Right-click on the Terminal icon (the PC monitor with Tux) and select 'Launch' to open a Terminal window.

5. At the root prompt (%) type:

cd /mnt
mkdir SEA_DISC

N.B. Choose any directory name you want. I use "SEA_DISC" because that's the volume name of my external USB HDD and I don't want to get confused.

6. Right-click on the desktop and select 'Partimage' from the pop-up menu.

7. Partimage will launch. Scroll down the list of HDDs to decide partitions you want to back up, and to see which HDD (partition) you want to back them up to. In my case I see that my 320 Gb external NTFS-formatted USB HDD is called “sdc1” (this can change, depending on what external USB HDDs I have plugged in to my laptop at the time). The full list displayed by Partimage for my current situation is:

hda1 <-- the FAT 32 WinXP factory restore partition on my laptop's HDD

hda2 <-- the FAT32 WinXP C: drive on my laptop's HDD

hda3 <-- the ext3 /boot primary partition on my laptop's HDD

hda4 <-- the extended partition on my laptop's HDD

hda5 <-- the ext3 /home logical partition on my laptop's HDD

hda6 <-- the ext3 / logical partition on my latptop's HDD

hda7 <-- the linux-swap logical partition on my laptop's HDD

sda1 <-- my FAT32 iRiver music player with 40 Gb HDD

sdb1 <-- my NTFS external Iomega 40 Gb USB HDD

sdc1 <-- my NTFS external Seagate 320 Gb USB HDD

8. Based on my current situation (see Points 5 and 7 above) I type the following in the Terminal window:

ntfs-3g /dev/sdc1 /mnt/SEA_DISC

N.B. If my external HDD were formatted as ext3 instead of NTFS then I would have instead typed:

mount /dev/sdc1 /mnt/SEA_DISC

9. In the Partimage window I select the partition I want to back up. Let's say for example that I want to back up hda1, so I use the scroll keys to select that partition.

10. Then I use the TAB key to select the box 'Image file to create/use' and I enter the full path of the file I want to save the partition into. In my case this would be:


N.B. You can call the file whatever you want. I could have called it "/mnt/SEA_DISC/mybackup.gz" or whatever, but you must add the suffix ".gz" to it if you want to create a Gzip file (there are three choices with Partimage: read the online Documentation -- see the link I gave earlier).

11. Press F5 to go to the next page of Partimage.

12. Use the TAB key and tab down to 'Image split mode' and select 'Automatic split' (use the cursor keys, and SPACE bar to select). WARNING added 3 February 2008: I have had "invalid compression level" error messages when trying to restore images, so I recommend that, instead of selecting 'Automatic split', you select 'Into files whose size is:' and a file size of '2037 MiB'. See the Partimage Forum thread for further details.

13. Press F5 to go to the next page of Partimage.

14. Enter any description for your backup file you want. For my example above, I'd enter (without the quotes) "WinXP factory restore partition on Acer TM 8215 WLMi".

15. Use the TAB key to select the "OK" box, then press ENTER to start the backup. The backup process can take several hours if the partition you are backing up is large and you have selected compression. For example, one of my laptop’s partitions is 72.33 Gb, contains 32.12 Gb of data and was saved as a compressed Gzip file of 17.51 Gb in 2 hours 31 minutes. The Partimage window displays the estimated time and progress of the backup.

16. Once the partition has been backed up to my external USB HDD, I repeat the above steps for all the other partitions on my laptop's HDD that I want to back up. In my case, I backup all the partitions on my laptop's HDD.

17. When I have finished backing up the partitions, I follow the instructions in Chapter 5 of the on-line documentation for Partimage:

to backup the partition tables for the primary partitions and extended partition on my laptop's HDD. In the Terminal window I type:

cd /root
mkdir partition-backup
cd partition-backup
dd if=/dev/hda of=backup-hda.mbr count=1 bs=512
cp backup-hda.mbr /mnt/SEA_DISC/backup-hda.mbr
sfdisk -d /dev/hda > backup-hda.sf
cp backup-hda.sf /mnt/SEA_DISC/backup-hda.sf

N.B. I type "hda" because my laptop's HDD is hda, the first disk (see Point 7 above). Yours may be different, so use the correct name for your situation.

(BTW, sfdisk is a tool in the sys-apps/util-linux package, and is installed on SystemRescueCd.)

Then I exit from everything, remove the SystemRescueCd CD from the optical drive and reboot my PC in order to return to SL. All done!

18. To restore a partition from the backup files you created using Partimage, you also use Partimage. Follow Steps 1 to 7 again. Having used Partimage to create the backup files, it should be obvious from the text displayed on the Partimage user interface what to do to restore them. However,restoring the MBR and the partition tables you saved in Step 17 is more complicated, and instructions for doing this can be found in Chapter 5 of the on-line documentation for Partimage. In the Terminal window I type:

dd if=/mnt/SEA_DISC/backup-hda.mbr of=/dev/hda
sfdisk /dev/hda < /mnt/SEA_DISC/backup-hda.sf

Then reboot.

P.S. Even if you don’t use Linux, you can use SystemRescueCd and Partimage to backup your Windows/Vista partitions.

Article created by Fitzcarraldo on 12 October 2007. Item 12 modified by Fitzcarraldo on 3 February 2008 with a warning about a potential problem restoring images. Item 18 added 24 October 2009.