Friday, May 08, 2015

VMWare ESXi copy VM and datastore

Lately, one of my drive of my RAID5 array was gone to death. Time for an infrastructure change.

I was glad to buy 4 new drives of 2TB to add new datastore to my vMWare ESXi 5.5 server. My plan is to move all the VMs from the old datastore where the disk is broken (RAID5, previously 4*500GB) to the new datastore (defined as RAID5, 4*2TB).
Then redefined the old LUN as RAID5 on 3*500GB as a NAS server disk (I decided to run FreeNAS 9.3).

Just a note to remember (VMWare ESXi 5.5).
Whilst I was doing a cold copy of all VMs from entire local datastore to an other local datastore, I did a script for that.
But fist of all, remember the steps :
* shutdown the VM
* delete all (consolidate) the snapshot before hands
* I decided to unregister the previous VM via 
vim-cmd vmsvc/unregister <vmid>
you may first want to get vmid from the command : vim-cmd vmsvc/getallvms
* do not use an OS copy command for vmdk file, those files would take the all provisioning space on disk instead of the actual value if it’s “thin”, could be quite surprising in the end.
My actual command I used :
vmkfstools -i "/vmfs/volumes/src/myVM/myVM.vmdk" -d thin "/vmfs/volumes/trg/myVM/myVM.vmdk"
* register the new VM
vim-cmd solo/registervm /vmfs/volumes/trg/myVM/myVM.vmx

As a side note, I was creating new datastores from a newly created LUN, I learnt that we actually cannot make more than one datastore per LUN… Need more datastore ? Create more LUNs. Yes, it requires to think about what you want to do when building the infrastructure from the beginning… 


No comments: