Bash: cp vs. vmkfstools
Friday, 03 October 2008 01:00

I wanted to move a VM from one datastore to the other in the least amount of time (and yeah, I know, why don't you use storage VMotion - well, it's an old ESX version, and the ESX servers are in different VirtualCenters). So the copy of the virtual disk is taking most of the time since it's the largest file. We've got two commands available to copy the disk: cp and vmkfstools.

I'll discuss both and show the difference in time. Check it out:

I have used a quite large file, it's 50Gb with an OS and some data on it. Details about the server and used storage device isn't important since this test is just to show the relative difference in time. This server has no running VMs and thus no load or disk IO during the test.

First using 'cp':
# time cp JustAVM-flat.vmdk ../JustAVM2/.
 
real    73m30.195s
user    0m0.000s
sys     0m47.300s

So, that's more than an hour!

Then I have used 'vmkfstools':
# time vmkfstools -i <source> <target>
Destination disk format: VMFS thick
Cloning disk '/vmfs/volumes/JustAVMFS/JustAVM/JustAVM.vmdk'...
Clone: 100% done.
 
real    27m33.307s
user    0m0.000s
sys     1m23.620s

And that's within half an hour!

Now besides the time difference, it's not wise to use the 'cp' command. The reason for this is quite simple: 'cp' reads and writes a part of the file resulting in a growing file during the job. Growing files are bad for VMFS, because it causes locking issues in the VMFS metadata.

Conclusion

Allways use vmkfstools to copy the virtual disk. Use the -i option to copy the disk. Using 'vmkfstools' is 2,6x faster than using 'cp'.

Comments (0)
Write comment
Your Contact Details:
Gravatar enabled
Comment:

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."