Linux

Clonning CentOS 6.2 in VirtualBox

Step 1

Install, update & configure your new CentOS installation. I wanted to install the Virtualbox Guest Additions and I recommend that you do the same due to the extra drivers and extensions it installs as it will make it easier later on (seamless mode and you don’t have to RIGHT CTRL every time you want to click outside the VM)

To install the Virtualbox Guest Additions do the following:

# yum update
# yum install gcc make
# yum install kernel-devel

Then reboot the system and in Virtual Box go to Devices > Install Guest Additions and follow the instructions on there.

Step 2

Once you have installed the Virtualbox Guest Additions (if you desired in the first place) it is now time to clone the VM.

If you are on Windows, simply go to Start > Run and type CMD

In the CMD window type the following:

 cd "c:\Program Files\Oracle\VirtualBox" 

Then we’ll initialise a virtual disk clone with the clonehd command by firstly selecting the master hard drive and then the destination and name of the clone:

 VBoxManage.exe clonehd "K:\Virtualbox\VMs\General_Server1.vdi" "K:\Virtualbox\VMs\SQL_Server.vdi"

Once it started you should get something like this:

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'VDI'. UUID: 3ffad736-862b-4c11-99f8-0348c02d8aa3

Step 3

Now we’ll create a new VM in Virtualbox but this time we’ll point to our newly crated cloned virtual disk image file!

Step 4

Now once it’s all done and you’ve logged in to the newly cloned system we just need to remove any previous information (hostname, IP address, etc)

Firstly we’ll re-configure eth0 as eth1 is currently active due to Virtualbox generating a new virtual interface and a new MAC address (as eth0 already existed previously, the interface has moved one up – eth1).

Go to /etc/udev/rules.d/70-persistent-net.rules file and change the old MAC address for the new one:

# vi /etc/udev/rules.d/70-persistent-net.rules

It should look like this when you first view it:


# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:85:3c:7d", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:21:e3:5d", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

Simply remove the second entry and add the MAC address for the new interface to the first one, so it should look like this:

N.B. In VI editor to insert text you press I first


# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:21:e3:5d", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

Simply put we replace eth0’s MAC address with the one from eth1! Save and reboot!

N.B. To save and quit in VI editor you press ESC key and then WQ and press the Enter key

Step 5

Now that we have assigned eth0 virtual interface with the new MAC address it is time to configure it. We’ll need to create a new ifcfg-eth0 file:

# touch /etc/sysconfig/network-scripts/ifcfg-eth0
# vi /etc/sysconfig/network-scripts/ifcfg-eth0

If you want a STATIC IP address then we’ll use this configuration:


DEVICE=eth0
 IPADDR=192.168.0.200
 NETMASK=255.255.255.0
 BROADCAST=192.168.0.255
 ONBOOT=yes
 BOOTPROTO=none

Or if you want a DYNAMIC IP address we’ll use this configuration:


DEVICE=eth0
 BOOTPROTO=dhcp
 ONBOOT=yes
 USECTL=no
 PEERDNS=yes
 TYPE=Ethernet

Step 6

We’ll change the hostname in both locations:

 # vi /etc/sysconfig/network
# vi /etc/hosts

Step 7

Finished! Hopefully it should work! :s

twitterredditpinterestlinkedinmail

Leave a Comment

Your email address will not be published. Required fields are marked *