Friday, December 10, 2010

How to image OpenSuSE to a virtual machine

This procedure was tested under OpenSuSE 11.x but it should also work for OpenSuSE 10.x.
The situation is this:
You want to convert a Linux machine running OpenSuSE to a virtual machine running under VMware Workstation.
The utility used to image the physical Linux machine was Clonezilla but the procedure should also work with Ghost or Acronis. After we made an image of the physical machine that image was restored to a new virtual machine that was created in VMware workstation 7. The problem is that the new VM won't boot because of the lack of appropriate drivers from initrd image of it. To correct this issue we must boot the VM using the OpenSuSE DVD and choosing to boot to rescue mode.
After that login to rescue system with username root and no password.
Find the partition layout of your system using the command fdisk -l
In my case the root and boot filesystem was in /dev/sda2
I created the following mount points:
mount /dev/sda2 /mnt
mount -t proc none /mnt/proc
mount -t sysfs none /mnt/sys

We now have the imaged system available under /mnt
We must also remount the dev filesystem using this command
mount -o bind /dev /mnt/dev
After this we chroot to the root filesystem of the imaged system using the command
chroot /mnt
Edit the files fstab, mtab, menu.lst and to reflect the correct mount points and boot partitions
Include the necessary drivers in /etc/sysconfig/kernel editing the section INITRD_MODULES in this file.
In my case the new entry was
INITRD_MODULES="processor thermal ata_piix fan reiserfs mptspi"
but you can add more drivers if you want to.
Now change to the boot directory using the command
cd /boot
Rename the current initrd file for safekeeping
mv initrd-xxxx initrd-xxxx.old
where xxxx is different from one SuSE release to another
Enter this command to create a new initrd
mkinitrd -d /dev/sda2 (sda2 points to /)
extra modules can also be added with the -m switch if you want to:
mkinitrd -d /dev/sda2 -m mptspi
Make sure the name of the created initrd is the same as stated in the menu.lst or that the initrd link points to the new initrd file.
You can now reboot the system and if all went as planned the system now boots up and you can modify other needed components like networking.
You can remove your old nic entry (the nic used in the previous machine) by editing
and reboot. That should bring the new nic back as eth0
For more info take a look in this link
Good Things To Know When Imaging Linux To Different Hardware

No comments:

Post a Comment