Taking disk images

I had two identical machines and I had to install same softwares to both of them. I didn’t want to do it manually by installing both machines by hand.

I started by installing first machine and making sure it worked like it should. Then I had and idea. How about copying the entire harddrive to another machine. And if I screw it up somehow I decided to put the disk image to save place on another computer.

First I put up NFS share on one machine. Then I booted the machine where I’m copying from with Gentoo LiveCD and mounted the NFS share. Actual image creation was done with dd.

dd bs=512 if=/dev/hda of=/mnt/backup/disk.iso

The Gentoo LiveCD is awesome tool. It has all needed tools to administration tasks and it’s very easy to use. And, well, it’s Gentoo.

Next task was to put the image to the harddrive of the another machine. This is where I hit the problems. The drive was too small for the image. No worries, I thought. I just alter the partition table afterwards.

After fighting for couple of hours I gave up.

My next idea was more successfull: I take tar archive of the contents of the drive and then create new partitions on the another machine and just untar the archive there.

I made the partitions and untarred the archive with the LiveCD. Then I mounted the newly created partition, chrooted it, and ran grub-install.

mount /dev/hda1 /mnt/gentoo
chroot /mnt/gentoo
grub-install /dev/hda

And everything worked right out of the box. As it should.


2011-01-02 10:35 Re-published from old website