Link to home
Start Free TrialLog in
Avatar of Daeta42
Daeta42Flag for United States of America

asked on

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

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
ASKER CERTIFIED SOLUTION
Avatar of bgoering
bgoering
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Daeta42

ASKER

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

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
Avatar of Daeta42

ASKER

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
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.
Avatar of Daeta42

ASKER

Yeah, it didn't delete it...  I am going to open another question right now for it...
do a ls -l in the folder - I would like to see the date/time stamps on the files
Avatar of Daeta42

ASKER

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....