How to migrate Virtual Machine with snapshots between datastores

Migration

As you probably know Virtual Machine snapshots is very useful feature in virtualized environment. I use it on daily basis and I love it. Without it so many changes and test will fail without possibility to recover - of course we have backups… πŸ˜‰

Now here comes “real life” scenario - I am still on VMware ESX / ESXi 4.1 and I would like to Storage vMotion virtual machine with snapshots from one datastore to another one located in different cluster.

Here is how should you do it:

  • Shutdown Virtual Machine
  • Remove it from inventory / unregister it from ESX / ESXi hostΒ vmware-cmd -s unregister
  • Go to Virtual Machine directory
  • Move Virtual Machine from source datastore to desired new datastore
  • Go to new Virtual Machine directory
  • I recommend first to get new datastore UUID with command ls -al /vmfs/volumes/ and then copy your datastore UUID
  • In Virtual Machine directory list all vmdk files - for example ls -al | grep vmdk
  • Now what you need to do is edit vmdk files - remember do not edit vmdk flat files
  • You should change UUID - for example:
    • from /vmfs/volumes/OLDUUID/VM01
    • to /vmfs/volumes/NEWUUID/VM01
  • After you change UUID in all vmdk files you should register virtual machine back using command vmware-cmd -s register
  • You can confirm that all disk and snapshots are present in Virtual Machine settings

You are done - maybe this is not easiest way how to do it but for sure it works. I hope it helps. If you have better or other ways how to do it feel free to comment.

All rights reserved Β© Wojciech Marusiak
Last updated on 24 Apr, 2013 20:23 ETC
Built with Hugo
Theme Stack designed by Jimmy