For my latest experiment with oracle VM I took a look at the p2v capabilty.
p2v stands for “physical to virtual” and does exactly, what the name suggests: converting a physical server to a virtual machine. In the following text I will describe some of the obstacles I faced when trying to convert a solaris server as well as my solutions.
Maybe this might help if somebody got stuck at the same issues.
The first few steps are fairly simple. All you need to start is the oracle VM Server boot medium (which can be downloaded here), a working Oracle VM environment and, of course, a physical server to convert.
And, last but not least, this howto.
I did not face any problems following this guide from step 1 to 7.
Step 8 however can be a little bit tricky. After the webserver is started, open a webbrowser on the URL of that webserver. You will see a list of files. Now you can get the complete URL to the disk files (don’t forget the vm.cfg!) and paste it into the import dialog of oracle VM.
The Images will now be copied into your repository. After that, you can clone a virtual machine using that new template.
When this is done, take a look at the network interfaces that have been created in the clone (right click machines name -> edit -> network). You might want to replace the vnic with one from your own preconfigured network.
And this is the part, where my problems began:
No zpool found on first boot
When I first startet the virtual machine, it just kept on rebooting in an endless loop.
I was able to connect via the VNC and see that the machine was unable to find a bootable zpool. In fact it did not find any zpools at all.
The solution for that problem was booting the machine in single user mode once. To do this, you have to connect using the VNC console and wait until the grub menu appears on screen.
Now press ‘e’ on the first entry to get into edit mode. Here you can edit the boot properties. Select the line beginning with ‘kernel’, press ‘e’ again to edit and add “-s” (without the double quotes) at the end of the line.
Now the machine should boot. I just had to do this once – after that, I could simply reboot it and everything worked fine.
Reconfigure network interface
Next problem was, that the network interface did not come up.
Turns out, the device name was not correct. In solaris, my intergace was called ‘e1000g0′. The virtual interfaces in Oracle VM however are called ‘xnf0′.
The solution for this is done in three steps:
1.) ifconfig xnf0 plumb
2.) touch /etc/hostname.xnf0 (to make the change permanent after reboot)
3.) init 6
Add second disk to virtual machine
Next, I tried adding a second virtual disk to my virtual machine. Just to have some extra disk space.
First, I had to create a virtual disk in my oracle VM repository and add it to my machine (right click on machines name -> edit -> disks -> virtual disks).
Although the disk was now correctly shown in VM Manager, my machine was unable to find it during boot. To accomplish this, I had to follow these steps:
1.) Find and edit the vm.cfg file of the machine:
Change the following line:
disk = ['file:/OVS/Repositories/<ID>/VirtualDisks/0004fb0000120000a188bdb95c7ed8d8.img,hda,w', 'file:/OVS/Repositories/<ID>/VirtualDisks/0004fb0000120000999a52b631388b91.img,xvdb,w!']
into this (notice the the red mark at the end):
disk = ['file:/OVS/Repositories/<ID>/VirtualDisks/0004fb0000120000a188bdb95c7ed8d8.img,hda,w', 'file:/OVS/Repositories/<ID>/VirtualDisks/0004fb0000120000999a52b631388b91.img,hdb,w!']
2.) Boot the machine in reconfigure mode:
connect via VNC to my machine and wait for the grub menu to appear. Now press ‘e’ get into edit mode. Select the line beginning with ‘kernel’, press ‘e’ again to edit and add “-r” (without the double quotes) at the end of the line. This will start solaris in reconfiguring mode.
After doing this, my disk was seen by the virtual machine.
I tested this by issuing ‘format’ at the command prompt, which showed my new disk.
After solving these problems, I had a perfectly nice running virtual solaris 10 machine as an exact clone of my previous existing physical one. And, as a nice little bonus, it now has some extra disk space.