These directions assume your VMs use static IP addresses and you want to clone an existing VM called "myvm" to a new VM called "mynewvm" with its own IP address.
Make sure "myvm" has no snapshots, as this method won't work on a VM with snapshots (the disk rename step will fail).
Also make sure you close the original VM in VMWare-Server or you may get file-locking problems.
Ok, first change to the directory where the original VM is stored and copy the directory (this will take a few minutes):
cd /usr/lib/Virtual Machines cp -ax myvm mynewvm
Now rename the disk:
cd mynewvm /usr/bin/vmware-vdiskmanager -n myvm.vmdk mynewvm.vmdk
Now rename the configuration file and change the name of the VM in the file:
mv myvm.vmx mynewvm.vmx sed -i "s/myvm/mynewvm/" mynewvm.vmx
Now in VM-Ware server, select "File" then "Open" and "Browse". Select the "mynewvm" directory and the "mynewvm.vmx" file in that directory. The new VM should appear in the Inventory list.
Select the new VM and boot it. At this point it won't appear on the network. You'll need to log into the console as root and do the following:
rm /etc/udev/rules.d/70-persistent-net.rules
At this point, you could reboot the VM and it will come back up with original IP and hostname, which will cause a conflict if the original VM is also on the network, so you might just want to go ahead and do the following while you're hear:
Change the hostname by editing /etc/hostname.
Then edit /etc/network/interfaces and change the 'address' line to reflect the new IP address you want the VM to have.
Finally, etc /etc/hosts, change the line for '127.0.1.1' to reflect the new hostname and add (probably at the end of the file, but really where ever you want) a new line for the new hostname, e.g/:
192.168.1.50 mynewvm
That should do it. Now just reboot the VM and it should come back up with the new IP and hostname.
No comments:
Post a Comment