Virtual Oracle RAC. Task 8: Cloning a Linux guest.

Link back: This guide is a part of the Virtual Oracle RAC project, the index to the whole project is here.

Shut down your virtual machines. You may keep Virtual Box GUI open. Open the command line window. Type in the following commands (with a correction to your locations, use “oracle” instead of “sun” if you have latest version of product):

set PATH=%PATH%;C:\Program Files\Sun\VirtualBox\

cd /d G:\VBmachine

mkdir odbn2

VBoxManage clonehd G:\VBmachine\odbn1\odbn1.vdi G:\VBmachine\odbn2\odbn2.vdi

This is how it looks in the process.

A few important moments here. The VBoxManage utility will report errors if source machine is running, it will also report an error if you use relative path to the vdi file, only absolute path works (at least that’s the case for release 3.1.2 of Virtual Box. Also, if you are tempted to use the setvdiuuid tool I would advise against that as it may save you cloning time (5 min) but prove to give some trouble later.

Next step is to add (or rather register) our newly cloned machine to the Virtual Box.

Bring up the Virtual Box GUI and click on “New” machine, fill out the details like this:

The memory is 512MB for now:

Now, the disk is “existing”, but it is not registered yet so it is not on the list.

Click on the folder button and Media Manager interface appears.

Click on “Add”, navigate to our new file (odbn2.vdi), add it and then “select” it:

Now we are back to the new machine dialog with cloned file available to be used. Click “Next”.

And “Finish”. Do not start this machine or you will ruin it.

What will happen if we run this new machine right now? The Virtual Box knows nothing about this machine’s hardware at the moment. All these settings are not cloned or copied over when we clone vdi image. It may be quite different with VMWare but here the image is not self contained. Hardware setup is separate and contained in an xml file in the same folder as the vdi file. If we run the machine now with all the default settings from that file the Linux will run new hardware setup process and overwrite our careful network setup. We need to edit the xml file to give our new machine proper setup.

In a text editor (Textpad will do, any plain editor) open odbn1.xml and odbn2.xml files. Copy and paste (overwrite) the whole network section from first to the second. This configuration section is contained between tags <Network> and </Network>. Save the modified odbn2.xml file but do not start the machine yet. Do not start odbn1 as well until instructed to do so.

Close the Virtual Box GUI (if it was open) and start it up again, then click on “Settings” for “odbn2” machine. Only now our new settings will be read and accepted. Navigate to Storage section and remove Floppy controller as we have no need for it.

Notice: in newer versions of Virtual Box the default type of disk controller is SATA rather than IDE. In such case ou will need to delete the SATA controller, attach an IDE controller and then attach the image of the disk (the vdi file) to it.

Then go to System section and uncheck Floppy from the boot order:

Start the openfiler machine now. When we start odbn2 we would like to see if it can communicate to openfiler.

Now we can start the odbn2 machine (it is just a precise clone of odbn1 for now). Notice that all network interfaces are started properly, that means MAC addresses in the hardware (network) section matched those in the Linux itself, otherwise they would not start. The iSCSI seems to be working as well.

Now let’s convince odbn1 clone that it is odbn2 (plastic surgery of sorts).

Bring up SSH terminal as if you were connecting to odbn1, log in as root.

# cd /etc/sysconfig/network-scripts/

# vi ifcfg-eth0

Edit the file replacing 11 with 12 in the IP address.

Do the same for the next adapter:

# vi ifcfg-eth1

Now change host name:

# cd /etc/sysconfig

# vi network

Change odbn1 to odbn2 in the HOSTNAME:

Save the file and reboot the machine:

# reboot

Watch the machine messages in the GUI. On the startup the cloned machine will notice its new name:

Bring up an SSH window and connect to the IP address of odbn2.

Use “ifconfig” command to verify that IP addresses indeed have changed:

We also run “hostname” command to see if host name is correct:

Let’s see if openfiler is visible to the new server and can properly map the iSCSI targets.

While we are at it, let’s also change the ORACLE_SID in the oracle’s profile to “racdb2”.

# su – oracle

# vi .bash_profile

I would now take a backup of the whole farm (i.e. three virtual machines) by shutting them down and copying all vdi and xml files someplace else. Include also an xml file from

C:\Documents and Settings\%USER%\.VirtualBox\VirtualBox.xml

That file is essential for the backup and restore of Virtual Box setup.

Next chapter.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s