DanNorris.com » Cloning a VM on ESX Server 3.0.1
来源:百度文库 编辑:神马文学网 时间:2024/04/27 16:18:45
Cloning a VM on ESX Server 3.0.1
Technical,VMWare
I’vehad time this week to get familiar with our test server environmentwhich is a rather old Dell server running VMWare ESX Server 3.0.1.After creating a new VM and getting a base linux OS configured, Iwanted to clone it for later use. I’ve used VMWare Workstation andVMWare Server before and the cloning process there is very simple–justcopy. On ESX Server, there are a couple more steps required and thensome other steps that are optional, but make life easier in the longrun.
Here is the process I followed to perform a clone. It worked welland I was successful in getting my cloned VM running. I didn’t find aprocess describing exactly what I did, so I thought I’d post it (mostlyso I can find it later when I forget what I did). I did finda similar process for a slightly older version and most of this post comes from that process with a few exceptions.
Perform a clean OS shutdown of the guest OS running in the VM. Ideally, this will result in the VM being powered off.
Login to the ESX Server using SSH as the root user.
Use “vdf –h” to determine where the VMFS filesystems are mounted. In our example, this is /vmfs/volumes/AttachedSCSI
Locate the current VM image (at /vmfs/volumes/AttachedSCSI/shelob).
Run “cp –r /vmfs/volumes/AttachedSCSI/shelob /vmfs/volumes/AttachedSCSI/shelob-clone &“
Go do something else for a while to let the copy finish (at least 30 mins)
Once the copy is finished, go to the new directory (shelob-clone) and rename all the files to use the new clone name. For example, the string “shelob” will be in the filename for each file. You should rename the file so that “shelob-clone” is in the filename instead of “shelob”.
Once you’ve renamed all the files, run “file *” in this directory (shelob-clone).
Edit all files (back them up first) that are listed as “ASCII text” or “ASCII English text”. In each of those files, you may find references to the old filenames or directory names. Modify the references appropriately to use the new names.
Also edit the shelob-clone.vmx file to remove the following lines:
ethernet0.generatedAddress = "....."
ethernet0.generatedAddressOffset = "....."
uuid.location = "....."
uuid.bios = "....."
Add the following line to shelob-clone.vmx:
uuid.action = "keep"
Register the new cloned VM with ESX server by running the following command (this should all be on one line):
vmware-cmd -s register /vmfs/volumes/AttachedSCSI/shelob-clone/shelob-clone.vmx
Go to the Virtual Infrastructure client and start the new VM. If the guest OS is linux, you should expect kudzu to detect that the old Ethernet controller was removed and a new one has been added. The benefit of this detection is that it will prompt you to add network configuration information. When you’re prompted, you can choose the appropriate IP configuration/address for this new guest VM. Note that you should make sure that your original VM and the new VM have different IP addresses if you intend to have them running at the same time.
Please post suggestions in the comments and I’ll respond and/or update the post.
These steps are going to come in handy as I start playing with the VMs that eventually get posted up atwww.OracleVMs.com.
17 Comments»
Hi, I tried doing this and got the following errors.
cp: cannot open `Test/Test.vmxf’ for reading: Permission denied
cp: cannot open `Test/Test.vmsd’ for reading: Permission denied
cp: cannot open `Test/Test-flat.vmdk’ for reading: Permission denied
cp: cannot open `Test/Test.vmdk’ for reading: Permission denied
cp: cannot open `Test/Test.nvram’ for reading: Permission denied
The VM is stopped. I continued on and edited the vmx file. When I started the VM, it said there is a missing file and stopped. BTW you need to rename the VM inside the vmx file or there will be double entries.
Comment by Alfred — September 13, 2007 @4:52 am
Ok I got it. Need to sudo first.
Comment by Alfred — September 13, 2007 @5:02 am
Good, let me know if you encounter more issues.
Comment bydannorris — September 13, 2007 @8:29 am
i just used the vmware converter tool to clone a image and it worked great.
Comment by dennis young — October 19, 2007 @8:21 am
I didn’t know the converter tool could do clones. I’ve used the P2V (physical to virtual) converter to create a new VM based on a physical system. Is that the tool you’re talking about?
Comment byDan Norris — October 19, 2007 @8:49 am
This tool will do physical to virtual conversions too.
http://www.vmware.com/products/converter/
Comment by dennis young — October 19, 2007 @2:15 pm
A clone as described in my post is to take an existing ESX virtual machine and copy it to create a new ESX virtual machine. The converter will take a physical system and convert it to a VM (but you have to use the enterprise version to convert to an ESX server destination).
I’ve used the converter free tool and it works quite well, but that’s not what this post was about.
Comment byDan Norris — October 19, 2007 @2:19 pm
you can use the converter tool to take a esx virtual machine and copy it to another esx server, the same esx server or to a vmware server or workstation. i’ve done it multiple times in the last two days.
the converter tool addresses exactly what this post was about.
Comment by dennis young — October 19, 2007 @4:30 pm
I see now–I think you’re talking about the licensed version of the converter tool (I’ve never used the licensed version). With the free version of the converter tool (they call it the “starter edition”), you can’t do anything related to ESX, so I guess that’s where the post here would come in handy.
Please correct me if I’m wrong.
Reference:http://www.vmware.com/products/converter/get.html
Comment byDan Norris — October 19, 2007 @7:13 pm
I used the free version and it let me clone from esx to esx. try it! it’s pretty slow but it works.
Comment by dennis young — October 20, 2007 @10:01 am
How are your 13 steps better than the one step of:
vmkfstools ?-i
Comment by Casey — January 16, 2008 @10:55 am
I’m not sure I know what vmkfstools -i does. Looks like it just clones a disk, not a whole VM by reading the docs. This process will clone an entire VM, possibly to a different server if you’d like. Maybe you know more about what vmkfstools -i does–I haven’t tried it myself.
Comment byDan — January 18, 2008 @12:37 am
Will this process allow me to restore host to the most recent status? Will it be possible to traverse through snapshots taken on the source host?
Comment by Andrzej Z. — January 23, 2008 @2:41 pm
@Andrzej Excellent question. I haven’t tested that personally, but I should expect that all snapshots would be available after importing the VM on the target host. If I have time in the next few weeks, I’ll try it. If you try it and have some results, let me know and I’ll update the post here.
Comment byDan — January 23, 2008 @2:51 pm
Dan, It looks it works for most recent status of the host as well as the snapshots. Additional steps are required. Beside renaming files you will also need to modify all non-binary files to reflect all references to the new file names.
Comment by Andrzej Z. — January 24, 2008 @12:00 pm
That’s what step #9 above is all about–editing the contents of the non-binary files to change the references. Are you saying that you have to do more than what’s stated there in step 9?
Comment byDan — January 24, 2008 @12:25 pm
not really, I just overlooked that. Concluding the entire procedure is complete and it works.
Comment by Andrzej Z. — January 24, 2008 @1:42 pm
Technical,VMWare
I’vehad time this week to get familiar with our test server environmentwhich is a rather old Dell server running VMWare ESX Server 3.0.1.After creating a new VM and getting a base linux OS configured, Iwanted to clone it for later use. I’ve used VMWare Workstation andVMWare Server before and the cloning process there is very simple–justcopy. On ESX Server, there are a couple more steps required and thensome other steps that are optional, but make life easier in the longrun.
Here is the process I followed to perform a clone. It worked welland I was successful in getting my cloned VM running. I didn’t find aprocess describing exactly what I did, so I thought I’d post it (mostlyso I can find it later when I forget what I did). I did finda similar process for a slightly older version and most of this post comes from that process with a few exceptions.
Perform a clean OS shutdown of the guest OS running in the VM. Ideally, this will result in the VM being powered off.
Login to the ESX Server using SSH as the root user.
Use “vdf –h” to determine where the VMFS filesystems are mounted. In our example, this is /vmfs/volumes/AttachedSCSI
Locate the current VM image (at /vmfs/volumes/AttachedSCSI/shelob).
Run “cp –r /vmfs/volumes/AttachedSCSI/shelob /vmfs/volumes/AttachedSCSI/shelob-clone &“
Go do something else for a while to let the copy finish (at least 30 mins)
Once the copy is finished, go to the new directory (shelob-clone) and rename all the files to use the new clone name. For example, the string “shelob” will be in the filename for each file. You should rename the file so that “shelob-clone” is in the filename instead of “shelob”.
Once you’ve renamed all the files, run “file *” in this directory (shelob-clone).
Edit all files (back them up first) that are listed as “ASCII text” or “ASCII English text”. In each of those files, you may find references to the old filenames or directory names. Modify the references appropriately to use the new names.
Also edit the shelob-clone.vmx file to remove the following lines:
ethernet0.generatedAddress = "....."
ethernet0.generatedAddressOffset = "....."
uuid.location = "....."
uuid.bios = "....."
Add the following line to shelob-clone.vmx:
uuid.action = "keep"
Register the new cloned VM with ESX server by running the following command (this should all be on one line):
vmware-cmd -s register /vmfs/volumes/AttachedSCSI/shelob-clone/shelob-clone.vmx
Go to the Virtual Infrastructure client and start the new VM. If the guest OS is linux, you should expect kudzu to detect that the old Ethernet controller was removed and a new one has been added. The benefit of this detection is that it will prompt you to add network configuration information. When you’re prompted, you can choose the appropriate IP configuration/address for this new guest VM. Note that you should make sure that your original VM and the new VM have different IP addresses if you intend to have them running at the same time.
Please post suggestions in the comments and I’ll respond and/or update the post.
These steps are going to come in handy as I start playing with the VMs that eventually get posted up atwww.OracleVMs.com.
17 Comments»
Hi, I tried doing this and got the following errors.
cp: cannot open `Test/Test.vmxf’ for reading: Permission denied
cp: cannot open `Test/Test.vmsd’ for reading: Permission denied
cp: cannot open `Test/Test-flat.vmdk’ for reading: Permission denied
cp: cannot open `Test/Test.vmdk’ for reading: Permission denied
cp: cannot open `Test/Test.nvram’ for reading: Permission denied
The VM is stopped. I continued on and edited the vmx file. When I started the VM, it said there is a missing file and stopped. BTW you need to rename the VM inside the vmx file or there will be double entries.
Comment by Alfred — September 13, 2007 @4:52 am
Ok I got it. Need to sudo first.
Comment by Alfred — September 13, 2007 @5:02 am
Good, let me know if you encounter more issues.
Comment bydannorris — September 13, 2007 @8:29 am
i just used the vmware converter tool to clone a image and it worked great.
Comment by dennis young — October 19, 2007 @8:21 am
I didn’t know the converter tool could do clones. I’ve used the P2V (physical to virtual) converter to create a new VM based on a physical system. Is that the tool you’re talking about?
Comment byDan Norris — October 19, 2007 @8:49 am
This tool will do physical to virtual conversions too.
http://www.vmware.com/products/converter/
Comment by dennis young — October 19, 2007 @2:15 pm
A clone as described in my post is to take an existing ESX virtual machine and copy it to create a new ESX virtual machine. The converter will take a physical system and convert it to a VM (but you have to use the enterprise version to convert to an ESX server destination).
I’ve used the converter free tool and it works quite well, but that’s not what this post was about.
Comment byDan Norris — October 19, 2007 @2:19 pm
you can use the converter tool to take a esx virtual machine and copy it to another esx server, the same esx server or to a vmware server or workstation. i’ve done it multiple times in the last two days.
the converter tool addresses exactly what this post was about.
Comment by dennis young — October 19, 2007 @4:30 pm
I see now–I think you’re talking about the licensed version of the converter tool (I’ve never used the licensed version). With the free version of the converter tool (they call it the “starter edition”), you can’t do anything related to ESX, so I guess that’s where the post here would come in handy.
Please correct me if I’m wrong.
Reference:http://www.vmware.com/products/converter/get.html
Comment byDan Norris — October 19, 2007 @7:13 pm
I used the free version and it let me clone from esx to esx. try it! it’s pretty slow but it works.
Comment by dennis young — October 20, 2007 @10:01 am
How are your 13 steps better than the one step of:
vmkfstools ?-i
Comment by Casey — January 16, 2008 @10:55 am
I’m not sure I know what vmkfstools -i does. Looks like it just clones a disk, not a whole VM by reading the docs. This process will clone an entire VM, possibly to a different server if you’d like. Maybe you know more about what vmkfstools -i does–I haven’t tried it myself.
Comment byDan — January 18, 2008 @12:37 am
Will this process allow me to restore host to the most recent status? Will it be possible to traverse through snapshots taken on the source host?
Comment by Andrzej Z. — January 23, 2008 @2:41 pm
@Andrzej Excellent question. I haven’t tested that personally, but I should expect that all snapshots would be available after importing the VM on the target host. If I have time in the next few weeks, I’ll try it. If you try it and have some results, let me know and I’ll update the post here.
Comment byDan — January 23, 2008 @2:51 pm
Dan, It looks it works for most recent status of the host as well as the snapshots. Additional steps are required. Beside renaming files you will also need to modify all non-binary files to reflect all references to the new file names.
Comment by Andrzej Z. — January 24, 2008 @12:00 pm
That’s what step #9 above is all about–editing the contents of the non-binary files to change the references. Are you saying that you have to do more than what’s stated there in step 9?
Comment byDan — January 24, 2008 @12:25 pm
not really, I just overlooked that. Concluding the entire procedure is complete and it works.
Comment by Andrzej Z. — January 24, 2008 @1:42 pm
DanNorris.com » Cloning a VM on ESX Server 3.0.1
VMWare Workstation、GSX Server、ESX Server有什么区别
OMU 8.51 Agent installation fails in ovpath on a Linux server
Memory Management for Oracle databases on VMWare ESX(Guy Harrison, Monday, February 22, 2010)
Human Cloning
On Becoming a Scientist
maosd.com image CDN Server
OutdoorEd.com - Movies on Leadership
Sugoo.com-VM-2004S轴承诊断振动分析仪 - 上海洪富仪器仪表有限公司
Textual Searches on File Data Using Microsoft SQL Server 7.0
Can't connect to MySQL server on 'localhost' (10061)解决方法
A HOWTO on Optimizing PHP
A Survey on Ontology Mapping-
Save a Bookmark on Delicious
A safe bet on US ?
Ruby on Rails Cheat Sheet - Ruby On Rails - ILoveJackDaniels.com
安装 Ubuntu server - 91linux.com
1. Molecular cloning
ONLamp.com -- Rolling with Ruby on Rails
Conservation | Life on earth | Economist.com
Currencies | Still hanging on | Economist.com
The world on your desktop | Economist.com
FastCGI: A High-Performance Web Server Interf...
Put a Flex UI On Your Application