Share via


Rename a VM including directory and VHD

Question

Friday, July 24, 2009 7:29 PM

OK we have a 2 node cluster and store our VMs on a separate LUN for each. I'd renamed some VMs and would like to rename the VHDs as well as the "root" directory that all the VM info is stored in. Renaming the VHD is simple enough after shutting down the VM then changing the VHD name and also in the VM config it's name. But changing the directory name I can't do. I will get an "Access Denied" in Windows if I attempt to do so in Windows Explorer or at the command prompt. For instance

driveGUID\vmnameold

driveGUID\vmnamenew   <I will get an access denied if I try to change this. Even if the VM is stopped.

I have a feeling this is related to the XML files in the C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines directory that exxist/get created if I have a VM running on one of the hosts. It's not the config. It's like Windows, even though I specified at creation for the config, vhd and snapshot to exist on the LUN still uses XML files in this directory for the VMs. I'm wondering if Windows is protecting the VMs somehow because in these XML files looks like a config for some VMs with the directory structure. Anyone know what's going on?

All replies (2)

Wednesday, July 29, 2009 11:26 AM âś…Answered

Hi,

 

Why would you want to rename them?

 

In a Hyper-V machine, every VM have a symbolic link file in C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines. If you delete the symbolic files, you will lost the VM in the Hyper-V Manager.

 

You can use the export/import function to achieve the goal:

 

1. Create a new folder(named the name you want to rename)

2. Export the VMs to this folder

3. Import the VMs in the new created folder.(You can delete the original VMs)

 

 

Best Regards,

Vincent Hu

 


Saturday, July 25, 2009 4:46 PM | 1 vote

The gui tools that come with Hyper-V have limited features. I think you can script this. The starting point for the scripts can be found here: http://blogs.technet.com/virtualization/archive/2009/05/29/hyper-v-r2-import-export-part-6-so-what-happened-to-configuration-only-export.aspx