Monday, January 14, 2008 7:32 PM
Moving a Windows Server 2008 Hyper-V virtual machine
Windows Server 2008 Hyper-V stores a list of virtual machines in %systemroot%\ProgramData\Microsoft\Windows\virtualisation\Virtual Machines. In that folder are a set of symbolic links, that are linked to the actual config files for each virtual machine.
To move a virtual machine:
- Shut down or suspend the virtual machine
- Delete the symbolic link in the folder mentioned above. The VM will disappear from the Windows Virtualisation Management MMC console (if you have it open). To delete a symbolic link, you can use the del command in a command window
- Move the virtual machines files (VHD virtual hard disk file, configuration files and so on) to the new location
- Open the virtual machine's configuration file (e.g. using Notepad.exe) and update any references to physical paths. Typically you'll need to update the location of the virtual hard disk and saved state location. The configuration file is a GUID with an XML extension, such as 0A8D4907-82C6-11DC-8061-02004C4F4F50.xml
- Create a new symbolic link to the virtual machine's XML configuration file. This can be done using the mklink.exe file (mklink.exe /? for how to create a link to a file)
To make it easier to create the links, you can output the contents of the virtual machines folder using dir and then piping it to a text file (e.g. dir > VMs.txt). Open the text file in notepad.exe, and for each machine will you have an entry like:
14/01/2008 12:22 PM <SYMLINK> 0A8D4907-82C6-11DC-8061-02004C4F4F50.xml [D:\WSVs\SVR03-ISA06-1\Virtual Machines\0A8D4907-82C6-11DC-8061-02004C4F4F50.xml]
It's a simple matter of editing to turn this into:
mklink 0A8D4907-82C6-11DC-8061-02004C4F4F50.xml e:\newLocation\SVR03-ISA06-1\Virtual Machines\0A8D4907-82C6-11DC-8061-02004C4F4F50.xml
Save this as a batch file (.bat) and just doubleclick to create the new link. The VM should then show up in Windows Virtualisation Management MMC console.
EDIT: this technique was tested with Windows Server 2008 RTM and Hyper-V Beta 1. It may not work with subsequent builds of Hyper-V. I will update this post when Hyper-V goes RTM