VMware

This Question is Answered

7 Replies Last post: Apr 24, 2008 5:45 AM by kjb007  

Separating and relocating .vmdk files posted: Apr 23, 2008 4:51 PM

Click to view vreiner's profile Novice 22 posts since
Aug 31, 2006

I have a VM which I need to add a couple of virtual disks. I see that I can choose to locate the .vmdk's with the VM, but the VMFS volume the VM islocated on is full. The alternative is to choose a specific datastore and I do have another datastore which has room. I'm going to be able to clear some space later on and I will want to relocate those "loose" vmdk's back to be with the VM when space is available. My question is this: Is it possible to move those vmdk's, and if so how would I do it? Can I just do a "migrate" and specify the EXISTING datastore where the VM is currently located? Will that "herd" the loose .vmdk's back into the VM folder? Or is there another method I have to use?

Thanks in advance!

Re: Separating and relocating .vmdk files

1. Apr 23, 2008 5:58 PM in response to: vreiner
Click to view taits's profile Hot Shot 81 posts since
Nov 6, 2007
I'm not sure if 'migrating' the VM to the same location will ask if you want to move the VM files. If not then you can manually move the remaining vmdk files by using 'cp -rp' of the files from one location to the other. Note that when you do this you'll have to update (edit) the vmdk descriptor files with the new location. I would make sure you make a backup of all files before doing this. Once complete and the VM is up and running then you can delete the old vmdk files. Yet again - why don't you migrate the existing VM from the location where there's a shortage of space to the location where there's ample space. Create your new disks and then migrate it back to the other location when you have created room there?

Re: Separating and relocating .vmdk files

2. Apr 23, 2008 6:04 PM in response to: vreiner
Click to view nappyrat's profile Enthusiast 19 posts since
Mar 19, 2008

I think the proper way to do it is with vmkfstools

vmkfstools -i /path/to/file.vmdk /new/path/to/file.vmdk


Re: Separating and relocating .vmdk files

3. Apr 23, 2008 8:00 PM in response to: vreiner
Click to view kjb007's profile Guru 5,486 posts since
Sep 18, 2006
Option 1

I believe the migrate disk option moves all your vm files together, but I'm not sure if it will support disks in different locations, but it very well may. Of course, try this first, else, you have option 2.

Option 2:
You're already on vmfs, so you can do a simple mv of the disk to the same folder as your vm. One thing you should do when you want to move is to shut down the vm, remove the disk from the vm, make sure you do not delete it from the disk, just remove the mapping. Then run mv /vmfs/volumes/datastore2/vm/vm-new.vmdk vmfs/volumes/datastore1/vm/vm-new.vmdk

Then go back into the vm and add the disk back to the vm as an existing disk, and point it to the folder.

-KjB

Re: Separating and relocating .vmdk files

4. Apr 23, 2008 9:41 PM in response to: kjb007
Click to view taits's profile Hot Shot 81 posts since
Nov 6, 2007

If you use vmotion (i.e. migrate whilst VM powered on) then you don't get the option to move the VM files. Doing a cold migrate (i.e. when the VM is powered off) will allow you to specify whether or not to move the VM files. As to whether the cold migrate will pick up that some vmdk files are in a seperate location I'm not sure.

There are many ways to move or copy a VM from the command line i.e. cp, mv, vmkfstools. I imagine that the thing to ask is how much trouble do you want to go to. Using 'cp' or 'mv' or 'vmkfstools' will mean that you'll need to edit the desciptor and config files for the VM to point to the new location of the disk.

Again I'd recommend migrating (powered off) the VM to the location with more space now and creating your new disk files in the same location, then migrating it back when you've got more space. Or you could just knock up a VM with no guest OS - just disks assigned in different locations and try migrating it to see what happens.

Here's a useful guide for command line options - http://www.rtfm-ed.eu/docs/vmwdocs/esx3.x-vc2.x-serviceconsole-guide.pdf

Tait

Re: Separating and relocating .vmdk files

6. Apr 23, 2008 11:45 PM in response to: vreiner
Click to view taits's profile Hot Shot 81 posts since
Nov 6, 2007

I'm not sure of the official "right" way to do this but the way I'd recommend would be (when you have enough space to locate all the disks in the same place) to shutdown the VM, remove (but don't delete) the disks that are on the different location, save the settings. This in effect edits the vmx file for the VM with the disk removal changes. The guest OS won't know any different because at this stage it has been powered on. Then 'cp' the disks to the VM directory and edit the settings again to add the 'new' disks. Save this and then Power On. In effect what you have done is edited the VM config file to say I have these disks in this location.

Tait

Re: Separating and relocating .vmdk files

7. Apr 24, 2008 5:45 AM in response to: taits
Click to view kjb007's profile Guru 5,486 posts since
Sep 18, 2006

I just tested this out. If you use the add disk wizard to add a disk in a 2nd datastore. When you're ready, you can choose migrate, without deleting anything, select the 'Move virtual machine configuration files and virtual disks', and then select the datastore. This will move your disks to the same location in the datastore you chose. In my test, I chose the same datastore that my 1st disk was located in, and the new 2nd disk was moved to the same location.

-KjB

VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Communities