VMware Cloud Community
scott_sanders
Contributor
Contributor

How do I move a VM from one datastore to another?

Hi,

I'm having a problem with one of my VM's in that it can't start due to lack of disk space.

I need to move it to another datastore where I have a lot more space, but I was wondering how best to do it; I assume it would be best to use the CLI but I'm having problems tracking down a decent reference.

Can anybody point me in the right direction?

Scott.

0 Kudos
6 Replies
sc_2111
Enthusiast
Enthusiast

You can simply use the "migrate" link in the VC .

Select the VM , turned off , and in the general Pane select migrate .

Then select the same host as destination and "move files" in the datastore question

HTH

0 Kudos
Banshee
Enthusiast
Enthusiast

Hi Scott,

Do you have VC?

0 Kudos
mcwill
Expert
Expert

If you don't have VC, then to do it manually in a shell login...

To move from /vmfs/volumes/storage1 to /vmfs/volumes/storage2

1) Create a folder in the new datastore eg:

mkdir /vmfs/volumes/storage2/vm_name[/b]

2) Copy across the hard drives, repeat for each vmdk (Not the -flat files)

vmkfstools -i /vmfs/volumes/storage1/vm_name/diskname.vmdk /vmfs/volumes/storage2/vm_name/diskname.vmdk[/b]

(It's important to use vmkfstools here and not cp in order to avoid fragmentation, also its a lot quicker)

3) Copy across the .vmx file

cp /vmfs/volumes/storage1/vm_name/vmname.vmx /vmfs/volumes/storage2/vm_name/vmname.vmx[/b]

4) In the VI Client browse the new datastore, right click on the transferred .vmx file and select "Add to Inventory"

5) Start up new VM and once happy with it, delete the old copy.

0 Kudos
scott_sanders
Contributor
Contributor

Hi,

Thanks for your reply...

I've tried using the GUI but the operation just times out. Sometimes these sorts of things are more successful if run from the CLI, but I can't find any references for doing this.

Any idea what the commands would be, or do you know a resource where I could find them?

Regards,

Scott.

0 Kudos
scott_sanders
Contributor
Contributor

Hi,

Sorry... hadn't refreshed before I wrote the last reply... will try it now.

Thanks,

Scott.

0 Kudos
sc_2111
Enthusiast
Enthusiast

Hi,

Thanks for your reply...

I've tried using the GUI but the operation just times

out. Sometimes these sorts of things are more

successful if run from the CLI, but I can't find any

references for doing this.

Any idea what the commands would be, or do you know a

resource where I could find them?

Regards,

Scott.

did you connect directly to the ESX server with the VI client or to the VC ?

Try connecting directly to the esx server

0 Kudos