Wednesday, 11 June 2008

partimage to backup restore drive images

1. partimage ( here 0.6.7)
2. rescuecd ( here 1.0.3) and burn it on CD
3. sfdisk
4. 2 drives with same size (or the one that you will be restoring to bigger size) + the backup HDD with some file system on it (in my case ext3 to hold big data files)

HowTo Backup:
1. attach the backup drive (can be USB HDD, stick, whatever that will save your images - in my case I use 300GB USB drive)
2. Boot the rescuecd
3. to find out the location of the drive in my case /dev/sdb1, use command
fdisk -l

- if this is linux fs drive with ext3 , use following command:
mount -t ext3 /dev/sdb1 /mnt

4. save original MBR with dd
dd if=/dev/sda of=backup-sda.mbr count=1 bs=512

5. save all the extended partition entries
sfdisk -d /dev/sda > backup-sda.sf

IMPORTANT: save both files from 4. and 5. in safe places (they will be needed to restore the structure of the original to the new disk)

6. run partimage command

7. mark the partition that you want to back up (e.g. /dev/sda3)
8. in the Image file to create/use enter the path to the backup disk

9. in Action to be done:
mark - Save partition into a new image file
10. press F5 to go to Next Page
11. Choose required Compression level (e.g. gz)
12. Image split mode if the partitions you save are big, it is wise to split them into the file that fit on CD or DVD (I enter here 4500MB)
After continuing with F5 you give a description and the process starts, generating files:
sda3_partimage.000, sda3_partimage.001, etc
be careful these file are gzip'ed file, please rename them to sda3_partimage.00X.gz for X in 0,1,2..

How To Restore:
1. attach the backup drive containing your partimage files and mbr and extended partition entries
2. attach empty drive (in my case /dev/sda)
3. Boot the rescuecd
4. to find out the location of the backup drive in my case /dev/sdb1, use command
fdisk -l

- if this is linux fs drive with ext3 , use following command:
mount -t ext3 /dev/sdb1 /mnt

5. restore MBR and extended partition entries:
- dd if=/mnt/backup-sda.mbr of=/dev/sda
- sfdisk /dev/sda <> check with fdisk -l if all partitions made on /dev/sda

6. make sure backup file names on backup drive (/mnt) are renamed to gz, then gunzip them:
gunzip sda3_patimage.000.gz (will create much bigger sda3_partimage.000 file),     
... or
gunzip sda3_partimage.*.gz

7. run partimage command
8. Partition to save/resotre (in my case sda3)
9. Image file: enter the path to your gunziped image files /mnt/sda3_partimage.000
even if you have more than 1 file, always put the location of the 000 file
10. Action to be done: pick Restore partition from an image file After continuing with F5 you should get restored partition on /dev/sda3
11. format SWAP partition (in my case /dev/sda5 -> check your fdisk -l)
mkswap -c /dev/sda5

12. Install GRUB boot-loader
mkdir /new_disk
mount /dev/sda3 /new_disk
grub-install --root-directory=/new_disk /dev/sda

No comments: