Thursday, July 9, 2009

Manually cloning Centos 4.x server to VMware ESX

To cut the number of physical PCs or Servers we need for our support and development work, we embark on testing out VMware solutions. One of the challenge is to migrate the existing physical installations (mostly Linuxes) into the VMware VMs. There are a number of options including using the VMware Converter. I chose to migrate it using HD cloning techniques.

To do this, I used g4u (a BSD based live CD) to make a clone of the physical server and store the compressed (GZIP) disk image in a FTP server.

Then I created a new VM in VMware with the same or bigger disk size as the original physical disk.

Next I again, boot the VM using the g4u ISO, and restored back the compressed disk image from the FTP server, and then reboot the VM. But the version of linux I was using, Centos 4.5, would not boot up properly. It complained that it could not find the volume group "VolGroup00". The problem was a driver issue and during the booting process it did not load the correct driver to recognize the "virtual machine" SCSI adapter.

After trying many options (changing virtual disk adapters, etc), I found an article to fixes the problem for the Centos 4.x linuxes at: http://tipstricksandmore.blogspot.com/2009/01/after-converting-physical-rhel4-system.html.

The VMware SCSI adapters uses the MPT SCSI drivers and so I needed to rebuild the initrd file to include these drivers so that the virtual disks can be seen during the boot up process.

This can be fixed by booting the VM using a rescue CD (I used SystemRescueCD), mounting the drive (don't forget to use the vgchange -ay to enable the volume groups), chroot to the disk, mount the /boot partition and then fix back the files and drivers, according to the article above.

Once done, the system booted up without problems.

Of course, if you had used the VMware Converter these problems may have been avoided but for those who wish to go via the "disk cloning" technique, remember to fix the disk drivers.

Booting from USB disk

On the older PCs there is no option to boot from the USB port. That is a predicament that I faced. The CD-ROM drive has failed and there is no built in network port.

With only a working floppy drive and USB ports, I used the PLop Bootmanager to install a boot manager which gives me options to boot from various devices (CD-ROM, HD, USB) even if the BIOS doesn't support.

Check it out at: http://www.plop.at/en/bootmanager.html