Solved

VMware ESXi 4.0; When renaming a .vmdk file with vmkfstools does it automigically do the secondary .vmdk?

Posted on 2010-08-26
8
1,572 Views
Last Modified: 2013-11-11
Greetings-
     I am working on Cloning my Base VM Server so that I can build off of it again and again.  I went into the datastore via VSphere and created a new directory and copied the files to the new directory.

I then used Putty to SSH into the server.  Went to the directory of the VM in the new folder I just copied it to and did the following command.

 vmkfstools -E "BaseServer- x64.vmdk" Server-Alpha1.vmdk

I saw in VSphere under tasks that the job completed successfully.  

I went back to the Datastore browser and did a refresh and there it was Server-Alpha1.vmdk...   But there was still "BaseServer- x64-000002.vmdk"

I refreshed a bunch of times...  Logged out and logged back in...  Refreshed...  it was still there...  So, I thought to myself, self...  Just rename it like you did above and you will be all set...

 vmkfstools -E "BaseServer- x64-000002.vmdk" Server-Alpha1-000002.vmdk

Now I am left with the following....

 "BaseServer- x64-000002.vmdk"              a .5 kb file
 "BaseServer- x64-000002-flat.vmdk"        a 52,428,800 KB file

I then refreshed a bunch of times...  Logged out and logged back in...  Refreshed...  it was still there...  So, I thought to myself, self... you did so much research to get this far and you have backed yourself into a corner trying to figure it out...  Quit driving around in circles and stop and ask for directions...

So, Basically...  WTF....???  How do I clone a VM in ESXi easily...  I kinda don't want to see 50 directories of servers, Alpha1, Alpha2, Alpha3, etc...  And then have "BaseServer- x64.vmdk" replicated 50 times in the folders....  I am sure that something or someone will screw things up....

Thanks in Advance!

~~Sean
0
Comment
Question by:Daeta42
  • 4
  • 4
8 Comments
 
LVL 28

Accepted Solution

by:
bgoering earned 500 total points
ID: 33537680
Use vmkfstools to copy the vmdk

To export or clone a virtual disk from VMFS
vmkfstools -i  <source-file> -d diskformat <destination-file>

Good Luck
0
 

Author Comment

by:Daeta42
ID: 33538053
Four questions...

1.  I read that you shouldn't copy the files or something like that due to something about the inability for it to recognize the new location, or something like that, but I have read to much on to many subjects today they are all melting together...  or does the vmfkstools take care of that?

2.  what does/is the "-d diskformat" option for?

3.  I am under the impression that after I do this I can go back into VSphere and the "Add" a new machine and call it, Alpha1, Alpha2, Alpha3, etc...  Matching the name that I chose for the vmdk file?  Now everything is all nice and aligned and pretty like?

4. And this will take care of the -000002.vmdk file as well...???

Thanks!

~~Sean

0
 
LVL 28

Expert Comment

by:bgoering
ID: 33538113
Lets start with number 4 first, the 000002 file is a snapshot. You should delete (commit) the snapshot before starting the copys. In the client snapshot manager select the "Delete all" option - this will merge all of the snapshot data back into the base disk then get rid of the snapshot.

1. nothing wrong with copying disk files with vmkfstools - that is one of the things it is designed for. This is the process that is used in a vCenter Server environment when cloning a virtual machine. On the other hand, if it is shared datastore, the cp command causes scsi reservations and can cause slow response on other vms that are on the disk for the duration of the cp command.

2. the -d disk format is to specify provisioning, thick or thin. Thick is the default if you don't specify a -d parameter. You can read about all the format options on pp. 239 of http://www.vmware.com/pdf/vsphere4/r41/vsp_41_esx_server_config.pdf

3. I would recommend you use the vmkfstools -i command to clone the disks into some folder (not the final destination folder) on the datastore where you will be creating your alpha vms. Then:
   a. create the vm with no disk, this process will create the folder
   b. mv the vmdk file(s) for that vm into the folder
   c. Edit settings on the vm and add hard drive, then select exisiting hard drive and add
This will get everything "all nice and aligned and pretty like."

Good Luck
0
 

Author Comment

by:Daeta42
ID: 33538365
Ok, I didn't know that the 000002 file was a snapshot...   I thought it was an extension of the partition (or something like that)...  I did however do exactly what you said and commit all my snapshots to the VM in question this AM and I just checked and it committed...  Nothing more to Delete under the snapshot manager...  

So, basically I can delete the 000002 file and be done with it...?  

I am going to start testing what you just said now and see how it takes me...

Thanks so far!

~~Sean
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 28

Expert Comment

by:bgoering
ID: 33538440
don't manually delete the file. The snapshot delete process should get rid of it. If it doesn't we need to look some more.
0
 

Author Comment

by:Daeta42
ID: 33538490
Yeah, it didn't delete it...  I am going to open another question right now for it...
0
 
LVL 28

Expert Comment

by:bgoering
ID: 33538499
do a ls -l in the folder - I would like to see the date/time stamps on the files
0
 

Author Closing Comment

by:Daeta42
ID: 33679065
sorry for the delay....  Once I got it I went to town setting up the lab...  it was most fun watching it count to 100% 227 times......weee....

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article is an update and follow-up of my previous article:   Storage 101: common concepts in the IT enterprise storage This time, I expand on more frequently used storage concepts.
HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
Teach the user how to install log collectors and how to configure ESXi 5.5 for remote logging Open console session and mount vCenter Server installer: Install vSphere Core Dump Collector: Install vSphere Syslog Collector: Open vSphere Client: Config…
This Micro Tutorial walks you through using a remote console to access a server and install ESXi 5.1. This example is showing remote access and installation using a Dell server. The hypervisor is the very first component of your virtual infrastructu…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now