Migrate virtual system between vCenter with VM name changing.
- By : La
- Category : VMware
- Tags: esxi, virtual system, vmware
- Check if you have a reliable backup of VM.
- Check VM configuration, primarily vmx file location, disks, controller and portgroups where the system is connected to. This step is important, in any case something goes wrong, so do not ignore it!
Also it could be worth to check if you can login to the system. - Unregister VM from vCenter inventory (right clicking on the system -> unregister).
Pay attention, delete is very close to unregister option. Be careful 😉 - SSH to ESXi. Change the directory to where the system_name.vmx file is. This should be something similar to the:
cd /vmfs/volumes/DATASTORE/VM_name
- Create temporary directory for our backup and copy vmx file (and other you think may be important):
mkdir temp
cp *.vmx temp - Delete all unnecessary files. In fact all you need is *.vmx and *vmdk files. Pay attention, each VM disk consists of two files (name.vmdk and name-flat.vmdk). If you are unsure if you need some file, you can move it to the temp directory instead of deleting it.
- For each disk change it name using the following command:
vmkfstools -E old_name.vmdk new_name.vmdk
Note, if some of the disks are placed in non-default VM location, you will have to change the directory and replace this step. - Â Change all references in vmx file to the new one:
sed -i ‘s/old_name/new_name/g’ FILE.vmx
- Migrate (copy if possible) VM to new vCenter and register it.
- Delete VM from the old location.
Of course as usual there is more than one way to do this.
Above algorithm is my preferred way but you will have to find what the best works for you.
For those who prefer of using WebUI. You could use storage vMotion to change VM name, but only if you have enough space to proceed with that. Additionally vmx file cannot be fully edited through vCenter WebUI, but you can download it to local workstation, edit and upload it again. Just don’t forget to uregister system from primary vCenter anyway.
No Comments