Linux – how to get a linux image and restore it on another computer

grublinuxmbrrestore

I am trying to use dd command to accomplish complete restore of a linux image on a new computer. I have two partitions sda1(main) and sda2(extended), I took a backup of mbr image using:

dd if=/dev/sda of=/mnt/sdb1/mbr_image bs=512 count=1

and dbr image as follows:

dd if=/dev/sda2 of=/mnt/sdb1/ebr_image bs=512 count=1

I also took a backup of main partition(the one that I want to restore) using:

dd if=/dev/sda1 of=/mnt/sdb1/sda1_image

I open the new system with a slax cd and first restore mbr and ebr images that I backed up before(I didn't use 446 bytes, because I want to restore the partition table as well)

dd if=/mnt/sdb1/mbr_image of=/dev/sda
dd if=/mnt/sdb1/ebr_image of=/dev/sda2

after that I restore main partition:

dd if=/mnt/sdb1/sda1_image of=/dev/sda1

once it finishes I resize the main partition using following set of commands:

umount /dev/sda1
e2fsck -f /dev/sda1
resize2fs /dev/sda1 -p

after this point I restart the computer hoping that I restored everything correctly. Unfortunately when I do this on a new computer whose hard drive has never been used before, Computer gets stuck in grub bootloader saying GRUB…

I am suspecting that there's something machine specific in mbr image because if I run the same restore process on the machine that I took back up, everything works fine and machine boots normally.

Can you please shed some light on what I've been doing wrong for the last 2 days…

Best Answer

I know that it is a solution that forces you to do all the work from beginning but I will recomend using Clonezilla to do backup and restore it to new machine. Specialy if you need restore image on many machines