Cloning a VirtualBox Image (vdi)
By The Old Toxophilist on Nov 25, 2010
Following on from my previous blog entry where I described how to
install Oracle 11.2.0 on Ubuntu 10.10 in a VirtualBox I will quickly
describe how we can clone this image and hence reduce the rebuild time.
What I tend to do is create a backup copy of my vdi files that I can
return to later and I will assume that you have one of these within
this entry and it is called Ubuntu10.10-32BitOracle11g.vdi.
Copy Backup vdi
Copy your backup vdi file,Ubuntu10.10-32BitOracle11g.vdi
, to the location where all your VirtualBox vdi files are stored. We
shall call it Ubuntu10.10-32BitOracle11g-Copy.vdi.
Once the copy has completed open a command prompt and navigate to
the directory containing the vdi file and execute the following command:
Files\\Oracle\\VirtualBox\\VBoxManage.exe" internalcommands sethduuid
This will generate a new UUID for the VirtualBox vdi file and allow
you to add it to your VirtualBox instance and produce and output
similar to the following:
Add to VirtualBox Media Manager
Now we have a copy of the vdi file we will need to add it to VirtualBox as follows:
File->Virtual Media Manager
Now we can create a new Virtual Machine.
Create a New Virtual Machine
To use the newly added vdi we create the machine as follows with the
- Name : Copy Oracle 11g DB
- OS : Linux
- Version : Ubuntu
- Base Memory : 3072
- Use Existing Hard Disk : Ubuntu10.10-32BitOracle11g-Copy.vdi
To allow both the existing and new Ubuntu images to run on the
network you will need to change the hostname of the new machine. To do
this we will need to start the new Machine (Copy Oracle 11g DB) and
edit two file.
Edit the /etc/hostname file using the command:
Change the name to the new machines hostname (ubuntu-oracle-11g-copy).
Edit the /etc/hosts file using the command:
Change all occurrences of the original name to the name in
/etc/hostname (although for an instance running 11g you may want to add
the new name to the 127.0.0.1 line because the database files may
contain an internal reference to the host name).
Once these changes have been done the instance will need to be
rebooted for the to take effect and we now have a new copy of the
original Ubuntu instance.
Auto Mount Shared Folders
If you use Shared folders within VirtualBox these can be easily auto
mounted by doing the following (I assume the name of the shared folder
- Create a local directory within Ubuntu (/VirtualBoxShare).
- Edit the /etc/modules file (sudo gedit /etc/modules) and add:
- Edit the /etc/fstab file (sudo gedit /etc/fstab) and add :
VirtualBoxShare /VirtualBoxShare vboxsf defaults 0 0
Now when we start the image the Shared Folder will be mounted.