Thursday, November 10, 2011

Clone Virtual Box machine

I have existing Virtual Box machine, Rehat 5.5 and Oracle database are installed and configured.

I want to create Oracle Data Guard standby database, so I need to clone the existing one in order to save time and here's how to do it:

Operating System: CentOS 5.5 64 bit
Oracle Virtual Box version: 4.0.6
The first machine name: DataGuard1 existed at /home/osama/VirtualBox VMs

1-Clone the virtual disk:
[root@omniyapc osama]# VBoxManage clonevdi /home/osama/VirtualBox\ VMs/DataGuard1/DataGuard1.vdi /home/osama/VirtualBox\ VMs/DataGuard2/DataGuard2.vdi
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'VDI'. UUID: 4413e40f-f3e5-4aa0-858a-873bb539cf26


Note that Virtual Box will create the needed directories by itself.

2-Create new Virtual machine, and chose the cloned virtual disk.
When tried, I've get this error:
That's because permissions, as you note I cloned the disk using root user, simple change the owner and the group of the "DataGuard2" directory into the right user:

[root@omniyapc osama]# chown osama VirtualBox\ VMs/DataGuard2/ -R
[root@omniyapc osama]# chgrp osama VirtualBox\ VMs/DataGuard2/ -R


Then try using the disk again:

It works actually, but I disappointed again because Redhat didn't start and give me this error:
It could not mount the cloned disk, after double check the difference between it and the original machine, I found that the original machine disks type was IDE, while the newly created one are SATA, after removing the SATA disk and adding it as IDE one it works and Redhat starts successfully.

At other hand I got this dialog at Virtual Box manager:

and this one too after shutting down the new machine:

This message disappeared after closing and re-opening Virtual Box, it seems that it cashing some thing, actually I'm not sure why I got it but that's solve my problem.