DISQUS

DanNorris.com: Cloning a VM on ESX Server 3.0.1

  • Alfred · 2 years ago
    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.
  • Alfred · 2 years ago
    Ok I got it. Need to sudo first.
  • dannorris · 2 years ago
    Good, let me know if you encounter more issues.
  • dennis young · 2 years ago
    i just used the vmware converter tool to clone a image and it worked great.
  • Dan Norris · 2 years ago
    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?
  • dennis young · 2 years ago
    This tool will do physical to virtual conversions too.

    http://www.vmware.com/products/converter/
  • Dan Norris · 2 years ago
    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.
  • dennis young · 2 years ago
    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.
  • Dan Norris · 2 years ago
    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
  • dennis young · 2 years ago
    I used the free version and it let me clone from esx to esx. try it! it's pretty slow but it works.
  • Casey · 1 year ago
    How are your 13 steps better than the one step of:

    “vmkfstools –-i

    ?
  • Dan · 1 year ago
    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.
  • Andrzej Z. · 1 year ago
    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?
  • Dan · 1 year ago
    @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.
  • Andrzej Z. · 1 year ago
    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.
  • Dan · 1 year ago
    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?
  • Andrzej Z. · 1 year ago
    :) not really, I just overlooked that. Concluding the entire procedure is complete and it works.
  • sycomsimon · 1 year ago
    Why not just right click the virtual server that you have shutdown and want to clone in Virtual Centre. Once you right click, choose clone.
  • Dan · 1 year ago
    The reason I developed this procedure was because I didn't have access to Virtual Centre. This is the "manual" way--if you have VC, you're right, it's a lot easier. However, last I checked, VC isn't free, so not everyone will have it configured.
  • Ryan Lanham · 1 year ago
    We own 3 ESX Servers and this is the method that we use ever time to copy our Master Linux Clone. Please keep in mind that if you are copying a striped version of Unix based OS you may need to some extra work to get the NIC/ETH0 online. We use Ubuntu 7.10 LTS and one you clone you must delete the: /etc/udev/rules.d/70-persistent-net.rules and reboot in order for the server to detect the new NIC/ETH0 that it thinks it has.
  • Dan · 1 year ago
    @Ryan Thanks for the extra tip!
  • Gavin Hill · 1 year ago
    Couldn't you simply perform the following successfully?

    1. Create a new machine using VM Infrastructure Client choosing the same base OS that you want to clone.
    2. Once the machine is created, you log into the ESX server as root through SSH and locate the new VM machine (VMnew).
    3. Now what you can do is copy the “VMoriginal-flat.vmdk” file that you want to clone and replace the new VM “VMnewflat.vmdk” file with “VMoriginal-flat.vmdk”, making sure you change the name.
    4. Start the new VM from the VM Infrastructure Client.
  • Dan · 1 year ago
    @Gavin: That sounds like it might work--I haven't tried it though. Have you tried it and was it successful? Unfortunately, my ESX environment isn't available for testing any longer, so I can't test it out.
  • mutante · 1 year ago
    The method proposed by Gavin worked for me with a Debian VM. Like Ryan described above for Ubuntu, here i needed to delete /etc/udev/rules.d/25-persistent-net.rules and reboot to get the NIC back up.
  • Dan Norris · 1 year ago
    Thanks for the update and confirmation that the method works in more
    than one specific case.
  • wmz · 1 year ago
    If you would like to clone virtual machine on esx server without the help of virtual center here is the instruction to do so

    log into esx server

    su to root and type the following command

    $ vmkfstools -i /vmfs/volumes/datastore/sourcevm/sourcevm.vmdk /vmfs/volumes/datastore/destvm/destvm.vmdk

    this will clone the virtual machine from source to destination

    once you have finished cloning

    go to vi client and run file->new virtual machine

    use custom instead of typical

    give the same name as the destination virtual machine name

    use next next until you get to point where it ask’s you for select disk change it to use an existing virtual disk and specify the path to .vmdk file

    and click next and next and finish this job

    Now you should be able to turn on the machine with out any issues

    Hope this works for you ;)
  • Dan Norris · 1 year ago
    That looks relatively easy compared to what I tried to do originally.
    We've upgraded our ESX server now, so I'm not sure if this method works
    on 3.0.1 or not, but next time we need to clone, I'll give it a try on
    our current version.

    Thanks!
  • Jose Fernandez · 2 months ago
    You can also copy and manually edit the VMX file to reconfigure the new server.

    Also note that if you have snapshots this clone process will not clone the data that came after the snapshots. You have to merge the snapshots first - at least as far as I can tell
  • Tom · 1 year ago
    the VM Explorer tool let's you clone or move your vm's from one server to the other, btw for most features it's free
    http://www.trilead.com/Products/VM_Explorer/
  • Dan Norris · 1 year ago
    Tom,

    Thanks for the tip. One of the admins here installed the tool to try it out and says it's awesome and can't believe that he gets exactly the types of things he needs for free. There is a pay-for version, but the free version does all he needs, so he's quite pleased. You've made someone's life easier--thanks!
  • Tom · 1 year ago
    btw, latest version supports now ESX 3i
  • HercuLeeZ · 1 year ago
    Hi Dan,

    I wonder if you can provide me with your (colleagues) backup and restore process with VM Explorer?
    I have been able to backup and restore but, I've not been able to get the restored VM to detect the operating system.

    If you can help, I would very much appreciate it!

    Thanks!
    Herc
  • Dan Norris · 1 year ago
    I forwarded your note/question to the admin that's tested it. I'm not sure he's done much with backup and restore, but if he has, he should respond with an email pretty soon.
  • szulfi · 1 year ago
    Hi,
    I cloned the source OAS to target using perl scripts provided in clone/bin on OAS. After cloning my source OAS became very slow.

    Please let me know if i need to remove any files after cloning on source?
  • Dan Norris · 1 year ago
    I don't think so and there's no reason why I would expect your source to become slow. You can read the clone scripts too and I don't think you'll find anything in there that would be a cause for slowness. There's nothing you have to delete, but if you want to clean up, I think the files that the pre-clone step create are in $OH/clone somewhere.
  • Satbir · 1 year ago
    Very helpful article

    Thanks
  • Dan Norris · 1 year ago
    Glad you enjoyed it. At this point, I think the comments are possibly more useful than the original article!
  • Jayant · 10 months ago
    Good Stuff - good article leading to interesting and very useful comments & thoughts.
    Thank you
  • Ivan Stoev · 6 months ago
    Perfect. The VMware Infrastrcture Client Clone operation kept timing out. You saved my weekend! Thank you.
  • munavar · 3 months ago
    this article is very useful and very helpful to me thanks for posting this article. Thanks a lot
  • okgo · 2 months ago
    vmware-cmd -s register

    doesn't work on 3.5