I recently had to P2V a physical CentOS 5.3 server into a VMware vSphere 4.1 virtual environment. On completing the P2V, which took over four hours, I was presented with an “Error loading operating system” message when powering on the virtual machine. I had initially assumed this was an issue that had occurred during the conversion, however some further investigated revealed this was not that case. When converting the machine from a physical to virtual platform the boot partition location in the GRUB loader was no longer valid, as of course all hardware properties had now changed. To resolve the “Error loading operating system” message the following steps were performed:
1. Download the latest version of CentOS, in my case this was CentOS 5.6 CD 1.
2. Upload the CentOS ISO to a datastore in your virtual environment and attached it to the converted virtual machines CD/DVD drive.
3. Power on the converted virtual machine and press ESC to show the VMware boot device selector. Select and press return on CD/DVD-ROM drive, this will now load the attached CentOS ISO.
4. When CentOS loads, at the boot prompt type without quotations “linux rescue”, and press return.
5. Select to mount all file systems in read-write mode and press return.
6. To re-install GRUB type the following without quotes and press return, “grub-install /dev/sda”.
7. Once the installation has finished type “reboot” and press enter to restart the virtual machine.
That’s it, the GRUB loader should not be repaired and your virtual machine should successfully boot.