I’m using ESXi for a lab setup. After it got really slow, I added some disks. I then had to move some VMs to the new datastore. Now that’s quite easy if you have a vCenter and such stuff, but not on the free ESXi. How do you do this in the easiest way possible if you don’t care about performance? This will work but blow up the disk to the thick provisioned size. 

Prerequisites

  • ESXi (version 6 in my case)
  • More than one datastore
  • SSH or local console access to the ESXi host
  • The second datastore must be at least as big as the VMs you want to move (the capacity, not the current, actual size)

Follow along this plan

  • Power down the VMs you want to move
  • Connect via local console or via SSH to the ESXi. I prefer local console since the move may take quite a long time and there’s a session timeout on SSH
  • The path to the datastores is /vmfs/volumes/<datastore-name>. So in my case it was /vmfs/volumes/datastore1 and /vmfs/volumes/datastore2. Don’t worry about the weird names when you actually cd there, the names are symbolic links
  • Now I said move in the title, but for reasons I’ll suggest you’ll copy first. So if you want to move my_vm from datastore1 to datastore2:
  • cp /vmfs/volumes/datastore1/my_vm /vmfs/volumes/datastore2/
  • This will take a long time since it’s copying the whole hard disks, even though they’re zeroed out. Be patient. I suggest you follow along on a second terminal (ls in the new directory).
  • Unregister the VM (it’s still pointing to the old location)
  • Register the VM in its new location
  • Start the VM
  • It will ask if you copied or moved it. The actual question: should I generate a new MAC address? As long as you don’t start the old machine, choose “I moved it”. This ensures your interfaces don’t get mixed up. I tried this with my firewall, so it works.
  • Your machine is ready again!

Now if everything worked out, you can delete the old directory on the old datastore since it’s not needed anymore.

Again, this is much easier if you’re on a vCenter and I don’t think that’s supported what we’re doing here. But it works.

Advertisements