How can I move an existing VM's files to a new directory in the same datastore?

8,485

VMware have never really intended to make it easy to use VMFS datastores in this way but you should be able to do it if you really want to. The recommendation is to leave this level of detail up to ESX\ESXi but if you really want to give it a go read on.

Firstly you should power off and deregister the Virtual Machine (Remove from Inventory not Delete from Disk). Now move the files to the new directory. Make sure all the VM's files are in the same directory. If everything in the original VM is consistent then you should be able to simple browse to the new folder from the VI Client's Datastore Browser, right click on the .vmx and add it back into the inventory.

If that still fails with the error "not found" then there are path references in one or more of the config files that need to be fixed. You will need to open and edit the .vmx file to make sure there are no absolute file paths listed anywhere in there and if there are modify them so that all references are directly to filenames and not paths. Repeat this exercise with all VMDK's (the small stub .vmdk file, not the large -flat.vmdk) in case you have linked vmdk's (from snapshots\redo-logs). If you have any active snapshots you might also have to edit the .vmsd as well in the same way. You would be better off avoiding that complication by removing all snapshots before carrying out an exercise like this. Once you have cleaned up all of these files you should be able to add it back into the inventory as described above.

Share:
8,485

Related videos on Youtube

GurdeepS
Author by

GurdeepS

Updated on September 17, 2022

Comments

  • GurdeepS
    GurdeepS almost 2 years

    I have some VMs deployed on ESX. In vSphere 4, I want to move these VMs into another directory in the datastore. So the VM directories are under root, but I want them in root/MyNewFolder.

    I tried this by turning off a VM, copying the VM's file (VMDK etc) into the directory I want, deleting the hard drive from the VM's settings, adding a new hard drive and then selecting the new path to the VMDK. When I press ok on the settings dialog box, having made this modification to the settings, I get the following error:

    not found.

    What I am trying to do also does not seem to be possible when making a new VM. I can only make VMs under root.

    • Zypher
      Zypher almost 14 years
      What are the permissions on the new folder?
    • Jes
      Jes almost 14 years
      Out of curiosity, why would you want to do this? I don't actually think it's possible, but I'm curious...