Some Windows Virtual PC Notes

  • Press the DEL key to enter the VM BIOS
  • If you can’t install the Virtual PC Integration Components on Windows XP and you get a 1603 error in the log file; delete the c:\windows\system32\drivers\wdf01000.sys and retry the install.
  • Press SHIFT+ESC while the VM is starting to view the console instead of just the progress bar.
  • To mount a floppy image, use the scripts provided here: http://blogs.msdn.com/b/virtual_pc_guy/archive/2009/10/01/using-floppy-disks-with-windows-virtual-pc.aspx
  • Sysinternals’ Disk2Vhd is an excellent tool to P2V your machines into Windows Virtual PC. It even takes care of setting the correct HAL in the boot.ini file. Get it here: http://technet.microsoft.com/en-us/sysinternals/ee656415.aspx
    NOTE: The technique that Disk2Vhd uses will make it impossoble for you to install a Windows XP service pack. More info here: http://support.microsoft.com/kb/327101
  • If you need to run older OSs on Windows Virtual PC you can use the AV Additions from Virtual PC 2007. This will give you VM Additions support for Windows 2000 and DOS. Get the Virtual PC 2007 install file and extract it, then run an administrative install using msiexec.exe /a <path>. In the folder you specified you will find the ISO file with the VM Additions from Virtual PC 2007. Mount the file in your guest as you would any ISO file.
  • Microsoft has published a Windows Virtual PC Tips document: Windows Virtual PC Tips
  • The Windows Virtual PC blog can be found here: http://blogs.technet.com/b/windows_vpc/
  • The acronym RAIL means Remote Applications Installed Locally. RAIL technology is used to publish apps in the VM to the host.
  • The Windows Virtual PC Home page: http://www.microsoft.com/windows/virtual-pc/default.aspx

Reducing the size of a dynamically expanding VHD file

All Microsoft virtualization software allows you to manipulate virtual hard disk files (VHDs). The standard operations you can perform are listen in the table below.

image

* To fixed of same size as source
** To dynamically expanding of same size as source

What is missing here is the ability to shrink disks, either dynamically expanding or fixed. This is something that the built in tools cannot do. Enter the guys at vmToolkit and their VHDResizer. VHDResizer will let you shrink a fixed or dynamically expanding disk, provided you do some preparation.

 032709_2254_Reducingthe1

Notice how VHDResizer has determined that the source VHD is a dynamically expanding disk, and that the destination VHD can be set to either fixed or dynamically expanding. This particular source VHD has a maximum size of 16 GB. Because of this the minimum size we can select for the destination VHD is 16 GB, regardless of disk type. The reason we cannot get the disk smaller than 16 GB is that the partitions or volumes in the VHD take up the entire 16 GB of space, even though the actual physical file is much smaller. This is the very basis of a dynamically expanding disk; the guest operating system sees all the space and can address it, but only blocks that have data on them are written to the VHD file. So we need to shrink the volumes inside the VHD to free up space. I find that the easiest way to do this is with Diskpart.exe and the SHRINK command. As long as there is free space at the end of the volume, SHRINK can reduce the size of the volume. You can see how much you can shrink the volume by running SHRINK QUERYMAX. Then you can use SHRINK to shrink the volume by the maximum space available.

Microsoft Windows [Version 6.0.6001]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.
C:\Users\Administrator.LAB>diskpart
Microsoft DiskPart version 6.0.6001
Copyright (C) 1999-2007 Microsoft Corporation.
On computer: LAB-RODC1
DISKPART> select disk 0
Disk 0 is now the selected disk.
DISKPART> select volume 1
Volume 1 is the selected volume.
DISKPART> shrink querymax
The maximum number of reclaimable bytes is: 15 GB
DISKPART> shrink
DiskPart successfully shrunk the volume by: 15 GB
DISKPART>

But sometimes there is data at the end of the volume or very close to it, making the size you can shrink a volume by very small. To get around this you need to move the files to the beginning of the volume. The best tool I have found to do this is JKDefrag. By using JKDefrag’s action option 5 (Force together) we can force all the files on the volume together at the beginning of the volume. This will cause fragmentation, but we can deal with that by doing a normal defragmentation run when the volume has reached its desired size.

JkDefrag.exe -a 5 c:

But sometimes even this isn’t enough. However many times you run JKDefrag you will still see data at the end of your volume. Chances are that this is the NTFS Master File Table (MFT) stored in the file $Mft. The MFT also reserves a portion of the volume it calls the MFT Reserved space. This is to guarantee that the MFT has space to grow in, even when the disk is nearly full. The inability to write to or update the MFT would lead to disk corruption and orphaned files, which is the reason for this precaution. But to achieve our goal, we need to move the MFT and the MFT Reserved space blocks from the end of the volume and towards the start of the volume. (The MFT isn’t really at the end of the volume, at least it wasn’t in the beginning. Windows places the MFT around the middle of the volume by default, but since we have shrunk our volume it is now at the end.) The author of JKDefrag says that version 4 of JKDefrag will be able to move and defragment the MFT, but until that version is available we have to use another tool. The best I have found is Raxco PerfectDisk 10. PerfectDisk is commercial software, but you can download a trial version to perform your MFT defragmentation. Remember to get the correct version of PerfectDisk, the Pro version will not install on Windows Server for example. Install PerfectDisk 10 inside your virtual machine and analyze the volume you want to shrink. Select the Boot check-box next to the volume drive letter and reboot the virtual machine.

 032709_2254_Reducingthe2

During the boot PerfectDisk will defragment your volume and move the MFT to around the middle of it. You have no control of where PerfectDisk moves the MFT, it uses its own internal logic to determine that. You probably will also see that the MFT will grow, this is also due to PerfectDisk’s internal optimization settings. After the virtual machine has booted you can again use Diskpart.exe and the SHRINK command to further reduce the size of the volume. You can repeat this process until you have reached your desired size for the volume. Then, finally, you can run VHDResizer and shrink your VHD file, and also convert it at the same time.

How to export a virtual machine directly to a network share

When moving virtual machines between Hyper-V servers it is often useful to be able to export directly into the folder where the virtual machine will reside on the new host. This saves a lot of time and disk space. Here is what you need to do:
  1. Make sure that both your source and destination Hyper-V servers are in the same forest.
  2. Share the folder where the virtual machine will be exported to.
    (This is on the destination server).
  3. Grant NTFS permissions to BOTH the user running the Hyper-V Manager on the source machine and the computer account of the source machine, for the export folder.
  4. Grant Sharing permissions to BOTH the user running the Hyper-V Manager on the source machine and the computer account of the source machine, for the export folder.
  5. Export the virtual machine using the UNC path of the share you created in step 2 as the destination.

These requirements are also covered in the Hyper-V release notes (http://technet.microsoft.com/en-us/library/cc754747.aspx).

How to install System Center Virtual Machine Manager 2008 prerequisites

Here is a short script that will install the prerequisites for System Center Virtual Machine Manager 2008:

ServerManagerCMD.exe -i PowerShell

ServerManagerCMD.exe -i Web-Server

ServerManagerCMD.exe -i Web-Asp-Net

ServerManagerCMD.exe -i Web-Metabase

ServerManagerCMD.exe -i Web-WMI

Since ServerManagerCMD.exe is deprecated in Windows Server 2008 R2 and has been replaced with PowerShell cmdlets, here is the PowerShell command as well:

Add-WindowsFeature Web-Server,Web-Asp-Net,Web-Metabase,Web-WMI

Remember to do ImportSystemModules or Import-Module Servermanager first.

No need to do PowerShell since it is already installed on Windows Server 2008 R2.

Also, remember that SCVMM needs the Domain Functional level to be at least 2, that is Windows Server 2003. The Configuration Analyzer will warn you of this:

image_2_757406E1

How to reinstall Virtual Server 2005 Virtual Machine Additions

The GUI insatller (setup.exe) for the Virtual Server 2005 Virtual Machine Additions do not offer a reinstall or repair option. That means that if you ever experience any problems with any of the additions you are forced to first remove the additions, reboot, reinstall them and the reboot again. But if you use the MSI directly with msiexec.exe instead of setup.exe you have some more options. This command will reinstall the additions on your virtual machine:

Msiexec.exe /faums VirtualMachineAdditions.msi

You need to mount the Additions.iso file and change to the Windows directory in the ISO image.

More info about msiexec.exe parameters here: http://technet.microsoft.com/en-us/library/cc759262.aspx

How to remove the VMWare tray icon for all users

Find this key:
HKEY_LOCAL_MACHINE\SOFTWARE\VMware, Inc.\VMware Tools
 
or, if you’re on x64:
 
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\VMware, Inc.\VMware Tools
 
Change the ShowTray DWORD value to 0.
 
Since this is in the HKLM hive it will take precedence over the same setting under HKCU.
 
If you want to disable the icon only for the logged on user, change the same value but now under HKCU.

Virtual Server 2005 and Service Principal Names (SPN)

I recently had to warnings in the Virtual Server log on my Virtual Server 2005 R2 host:
 
Type:         Warning
Event:        1130
Date Time:    27.06.2007 22:28:42
Source:       Virtual Server
ComputerName: HOME-VSHOST
Category:     Virtual Server
User:         NT AUTHORITY\NETWORK SERVICE
Description:  The service principal names for Virtual Server could not be registered. Constrained delegation cannot be used until the SPNs have been registered manually.  Error 0x800706ba – The RPC server is unavailable.
 
Type:         Warning
Event:        1029
Date Time:    27.06.2007 22:28:42
Source:       Virtual Server
ComputerName: HOME-VSHOST
Category:     Remote Control
User:         NT AUTHORITY\NETWORK SERVICE
Description:  The service principal name for the VMRC server could not be registered. Automatic authentication will always use NTLM authentication.  Error 0x800706ba – The RPC server is unavailable.
For some reason, the Virtual Server service, running as Network Service, was unable to add the necessary Service Principal Names (SPN) to the computer object of the Virtual Server host in Active Directory. This is a known problem when Virtual Server is running on a Domain Controller (http://support.microsoft.com/kb/890893/en-us), but this machine was a member server.
 
To resolve this problem you run the following commands:
setspn -A vmrc/<NetBIOS name of VS machine>:5900 <NetBIOS name of VS machine>
setspn -A vmrc/<FQDN of VS machine>:5900 <NetBIOS name of VS machine>
setspn -A vssrvc/<NetBIOS name of VS machine> <NetBIOS name of VS machine>
setspn -A vssrcv/<FQDN of VS machine> <NetBIOS name of VS machine>
 
Restart the Virtual Server service and the errors should be gone.

Moving to Virtual Server

Just finished moving all my virtual machines from VMware ESX server to Microsoft Virtual Server 2005 R2 SP1 (Beta 2). Had a couple of reasons for doing so:

  • The SCSI requirement for ESX was a pain; SCSI is quite a bit more expensive than IDE/SATA. Plus the IBM SCSI drive I used was incredibly loud.
  • I wanted to try out the new version of Virtual Server. R2, especially with SP1, has many new features.
  • The machine that was running ESX has several IDE drives. The space on these drivers were unavailable to me since running SAMBA on ESX is not supported and is not well integrated with AD. I wanted that space back.
  • I also wanted to move away from the rigid ESX system and run a pure Windows Server environment on all my servers. Now I can have a unified administration, management and patching solution.

Since the server running ESX was the same one that I wanted to run VS on I had to copy the VMs to another machine and migrate them, before moving them back into Virtual Server. This required quite a few steps:

  • Make a backup of the VM on ESX, and keep it in a safe place for recovery.
  • Uninstall VMware Tools from the VM and reboot.
  • Replace the HAL (hal.dll) and kernel (ntoskrnl.exe) with the standard ones (found on the CD or in the ServicePackFiles directory).
  • Run a cleanup script.
    The script disables all known VMware devices.
  • Shut down the VM.
  • Export it through the ESX file manager (in the web interface) or through vmkfstools.
    Just copying the vmdk file using WinSCP or FTP will not work. The file will be corrupt and unusable. The reason for this is the VMFS file system that is used by ESX.
  • Convert the virtual disk file (vmdk) to a Virtual Server VHD file using the vmdk2vhd utility available here:
    http://vmtoolkit.com/files/default.aspx
    This is a nice utility that can convert a VMware vmdk file to a Virtual Server VHD file.
  • Move the new VHD files to the Virtual Server machine and create new VMs and select the existing disks.
  • Boot up the VMs and let Windows detect the new hardware, reboot when asked.
  • Install Virtual Machine Additions and reboot.
  • Configure IP address and verify all services.

After this procedure I had my VMs running on Virtual Server. The performance is quite good, even though I am running on only IDE drives now. There is a little performance drop as opposed to ESX, but weighed against the other drawbacks I experienced with ESX, that is not a problem. It will be interesting to see how the servers perform after some time.

I also tried out the new vhdmount utility in Virtual Server. This is a tool that can mount a VHD file on a computer without running Virtual Server or Virtual PC. The tool can be installed on Windows Vista as well, where it also supports the /m parameter which not only plugs the disk (physical) into Windows, but also mounts the partitions to drive letters in one operation. On Windows XP/Windows Server 2003 you have to use /p to plug in the disk and then assign drive letters to the partitions manually in Disk Manager.

There is a caveat, however. Since Virtual Server 2005 R2 SP1 is in beta, the driver that does the mounting and plugging is not signed. That means that Windows Vista, or XP/2003, will display an error when you try to mount a virtual disk:

 022207_1414_MovingtoVir1

The command will succeed but you will not see anything in Explorer or Disk Manager:022207_1414_MovingtoVir2

If you look in Device Manager you will see this:

 022207_1414_MovingtoVir3

The solution is to choose Update Driver Software… in Device Manager and manually point Windows to the vhdstore.inf file in the vhdmount directory. (Default location; C:\Program Files\Microsoft Virtual Server\VHDMount.) This requires not only telling Windows to look in the vhdmount folder for a driver, but to select Have Disk and manually selecting the vhdstore.inf file.

Afterwards, the disk should be available in Disk Manager and you can assign a drive letter to its partitions. The real killer is that you have to perform the manual driver installation each time you want to mount a disk. Hopefully VS 2005 R2 SP1 will RTM soon and the driver will be signed. Also, check out the VS SP1 release notes for information about how to install the vhdmount utility on a machine not running Virtual Server.

I am looking forward to playing with VS more in the coming days. The new support for VSS snapshots looks very promising. It lets you back up a running VM using the snapshot functionality provided by the Virtual Disk Service and the Snapshot provider.

Until next time.

Morgan