How to export VM guest and import to another Oracle VM 3 environment


We can copy the VM configuration file and all virtual disks to another OVM environment and then correct the configuration file sections to match the new environment(like virtual disk path), then refresh the repository on OVM Manager, the new VM will be recognised in "Unassigned Virtual Machines" tab, then edit this VM and update its network settings, and migrate it to one of your Oracle VM servers.


Let's assume that, we need to migrate the VM guest OL5U4-PVM_X64(UUID 0004fb000006000019de9b55b96c9863) from ovm1 to ovmb.



1. Find the UUID of the VM you want to export on the OVM Manager, for example: 0004fb000006000019de9b55b96c9863.

2. Find the configuration file and the virtual disk of this VM:



root@ovm1# df

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/sda2 3050092 906232 1986424 32% /

<snip>

/dev/mapper/3600144f0da627ad70000502a00d00003

20971520 381444 20590076 2% /poolfsmnt/0004fb000005000023a20c6a7f04822b

/dev/mapper/3600144f0da627ad70000502a00e40004

838860800 53704704 785156096 7% /OVS/Repositories/0004fb0000030000a43d7768f9d1a5be


root@ovm1# cd /OVS/Repositories/0004fb0000030000a43d7768f9d1a5be


root@ovm1# ls

Assemblies ISOs lost+found Templates VirtualDisks VirtualMachine


root@ovm1# cd VirtualMachines/


root@ovm1# ls

0004fb000006000019de9b55b96c9863 -----------> the VM directory

0004fb0000060000cf032a6161e3c8a8 0004fb00000600005dae0a4e02af5e9f

3. Copy this directory to new OVM environment:



root@ovm1# rsync -aS /OVS/Repositories/0004fb0000030000a43d7768f9d1a5be/VirtualMachines/0004fb000006000019de9b55b96c9863 ovmb:/OVS/Repositories/0004fb000003000027e4560112306e97/VirtualMachines/

4. Find the virtual disk path from the VM configuration file:



root@ovm1# grep disk 0004fb000006000019de9b55b96c9863/vm.cfg

disk = ['file:/OVS/Repositories/0004fb0000030000a43d7768f9d1a5be/VirtualDisks/0004fb000012000069a256ef4c64b12a.img,xvda,w']

5. Copy the virtual disks to your new OVM environment:


root@ovm1# rsync -aS /OVS/Repositories/0004fb0000030000a43d7768f9d1a5be/VirtualDisks/0004fb000012000069a256ef4c64b12a.img ovmb:/OVS/Repositories/0004fb000003000027e4560112306e97/VirtualDisks

6. Correct the VM configuration file with the new virtual disk path on your new OVM environment:

<hostname1># vi /OVS/Repositories/0004fb000003000027e4560112306e97/VirtualMachines/0004fb000006000019de9b55b96c9863/vm.cfg

Change

disk = ['file:/OVS/Repositories/0004fb0000030000a43d7768f9d1a5be/VirtualDisks/0004fb000012000069a256ef4c64b12a.img,xvda,w']

to



disk = ['file:/OVS/Repositories/0004fb000003000027e4560112306e97/VirtualDisks/0004fb000012000069a256ef4c64b12a.img,xvda,w']

7. Refresh the repository on new OVM Manager, then we can see a new VM OL5U4-PVM_X64 under "Unassigned Virtual Machines":
OVM Manager login --> "Home" --> "Server Pools" --> "Repositories" ---> "Refresh Selected Repository Contents"

8. Choose OL5U4-PVM_X64 and edit it, go to the "Networks", then remove the old nics and add new one.

Or you can manually modify the vif entries in vm.cfg to match the bridge ID on the Oracle VM system it will be imported to.

9. Migrate the VM to Oracle VM server.





If you like please follow and comment