VMware Cloud Community
galibai
Contributor
Contributor

Do i need to use vmkfstools -i

I am need to copy vmdk from one esx server to another esx server. The storage type is going to change. i am thinking to use scp -r cmd from ESX.

Once, it reaches the destinaion, DO I need to use the vmkfstools -i . I did some research and I am getting conflicting answers.

Mind you, I am going to copy data from vmkfs to vmkfs there wont be any ext3 OR ntfs involved.

thanks

Reply
0 Kudos
13 Replies
lamw
Community Manager
Community Manager

If you're transferring the VMDK from host to host, you can look at scp via CLI or something like FastSCP. If you have shared storage between the two, then you would use vmkfstools to properly copy a VMDK as it's aware that its a virtual machine disk file. Sounds like you're going from local storage to local storage, so the first suggestion will work and just make sure you copy over the .vmx and descriptor file and just re-register to get the VM running on the new host.

Oh btw, you can also take a look at VMware Converter to transfer the VM as well, all GUI base

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
galibai
Contributor
Contributor

I am copying from cx-700 to cx-380. I have seen people recommending to use vmkfstools after the copy has been complted so that they dont have any SCSI errors.

Gui is a good option, but I am going to move lot of VM's and that wont be that much possible.

Thanks

Reply
0 Kudos
lamw
Community Manager
Community Manager

If both storage arrays are presented to your source host, then yes you would use vmkfstools to copy, but you won't be able to do a remote copy from ESX1 seeing array1 to ESX2 seeing array2 where neither arrays are presented to the other host. You might even able to just replicate the old array to the new using array utilities that maybe available. If these are not an option, then you'll need to transfer using the methods described earlier

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
vcpguy
Expert
Expert

So we should not use vmkfstools -i option? I thought when ever we copy vmdk files between storage we should use them. I was using it all this while...

----------------------------------------------------------------------------- Please don't forget to reward Points for helpful hints; answers; suggestions. My blog: http://vmwaredevotee.com
Reply
0 Kudos
lamw
Community Manager
Community Manager

yes, if your source host can see both storage arrays. If it can't or the new storage array is not presented to the old host, then no you will not be able do a remote copy using vmkfstools.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
vcpguy
Expert
Expert

Ok, just to clear the confusion. If, I am going to use a scp should I also use the vmkfstools -i after the copy on the vmdk files?

----------------------------------------------------------------------------- Please don't forget to reward Points for helpful hints; answers; suggestions. My blog: http://vmwaredevotee.com
Reply
0 Kudos
lamw
Community Manager
Community Manager

no need, just re-register the VM(s) assuming all the relevant files are present on the new host. Again if you're doing a mass copy...maybe something like FastSCP or VMware Converter can be used and they might even allow for scheduling tasks/etc...I have not really used either tools much so I can't say but I hear those are the best out there.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
Chamon
Commander
Commander

vmware-cmd -s register /vmfs/volumes/lun/vm/vm.vmx will register the vm to the new host after you scp it over.

Reply
0 Kudos
Chamon
Commander
Commander

The only problem I have had with converter and scheduling the tasks is that the VM needs to be off to even schedule the task. So if you want to do it over night it is a problem. But you could schedule a task to shut the VMs down and use the at command to run a script to scp the vm directories over to the new LUN and then vmware-cmd -s register to register them with the new host

Reply
0 Kudos
lamw
Community Manager
Community Manager

Yep, if it's running the classic ESX you can just set that up in a simple for loop to find all .vmx files within the new datastore and register your VM:

[root@himalaya ~]# cat quickVMRegister.sh
#!/bin/bash

IFS=$'\n'
for VM in $(find /vmfs/volumes/<NAME_OF_NEW_DATASTORE>/ -name *.vmx);
do
        vmware-cmd -s register "${VM}"
done
unset IFS

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
Chamon
Commander
Commander

Is there a good document that I can look to to learn how to set up these loops. i can manage vary simple scripts but one you through loops and for statements in I am already lost. I want to learn more so that I can automate more of my tasks. I am sure the for loop is simple but for me it is not so any help is great.

Reply
0 Kudos
lamw
Community Manager
Community Manager

The web is probably your best source of examples and snippets of code and I would recommend trying things out on a sandbox to get a feel for things and asking questions on forums/IRC.

Here are some sites I visit frequently if I have any questions or need clarifications:

http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html

http://tldp.org/LDP/abs/html/

I also got a recommendation from a colleague at a previous job for a book that he thought was really useful called: UNIX Shells by Example 4th Edition. They might have a newer one, but from time to time I would consult this book as well if I did not search for my question on the net.

You an also visit and for a list of other scripts I've written to help automate tasks for your VMware environment in a variety of scripting languages/etc.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
AndreTheGiant
Immortal
Immortal

If you have VC you can use cold migrate to move VM from a storage to another storage.

If you have VMotion license you can also use Storage VMotion to do it with running VMs.

Or you can use SAN Copy or other low storage level tools.

Andre

**if you found this or any other answer useful please consider allocating points for helpful or correct answers

Andre | http://about.me/amauro | http://vinfrastructure.it/ | @Andrea_Mauro
Reply
0 Kudos