All of us have a need to test our client and server machines. Development, training, testing, and even general infrastructure environments can benefit from a good solid testing environment. Hyper-V in windows Server 2008 R2 provides the perfect platform to build a fully functional test network. In this session we will discuss the process of building the ultimate test network. We will focus our attention on the following topics. First in order to build the ultimate test network you will need to have a repository of full function non-time bombed operating systems and software. The TechNet Plus subscription seems like the perfect choice to meet this requirement. We will talk about Virtual Hard disks and how they are built. We will discuss the process of importing and exporting VHD files and the implications associated with moving them. We will talk about how to create virtual networks and manage both wired and wireless network connections between virtual operating systems. We will introduce you to a fantastic tool that will allow you to capture an image of a running operating system and create a VHD for use in your virtual network.Finally we will discuss how you can use snapshots to move forward and backward through points in a virtual machines lifespan.
Disk2vhd is a utility that creates VHD (Virtual Hard Disk - Microsoft’s Virtual Machine disk format) versions of physical disks for use in Microsoft Virtual PC or Microsoft Hyper-V virtual machines (VMs). The difference between Disk2vhd and other physical-to-virtual tools is that you can run Disk2vhd on a system that’s online. Disk2vhd uses Windows’ Volume Snapshot capability, introduced in Windows XP, to create consistent point-in-time snapshots of the volumes you want to include in a conversion. You can even have Disk2vhd create the VHDs on local volumes, even ones being converted (though performance is better when the VHD is on a disk different than ones being converted).It will create one VHD for each disk on which selected volumes reside. It preserves the partitioning information of the disk, but only copies the data contents for volumes on the disk that are selected. This enables you to capture just system volumes and exclude data volumes, for example.Note: Virtual PC supports a maximum virtual disk size of 127GB. If you create a VHD from a larger disk it will not be accessible from a Virtual PC VM.To use VHDs produced by Disk2vhd, create a VM with the desired characteristics and add the VHDs to the VM’s configuration as IDE disks. On first boot, a VM booting a captured copy of Windows will detect the VM’s hardware and automatically install drivers, if present in the image. If the required drivers are not present, install them via the Virtual PC or Hyper-V integration components. You can also attach to VHDs using the Windows 7 or Windows Server 2008 R2 Disk Management or Diskpart utilities.Note: do not attach to VHDs on the same system on which you created them if you plan on booting from them. If you do so, Windows will assign the VHD a new disk signature to avoid a collision with the signature of the VHD’s source disk. Windows references disks in the boot configuration database (BCD) by disk signature, so when that happens Windows booted in a VM will fail to locate the boot disk.Disk2vhd runs Windows XP SP2, Windows Server 2003 SP1, and higher, including x64 systems.Command Line UsageDisk2vhd includes command-line options that enable you to script the creation of VHDs. Specify the volumes you want included in a snapshot by drive letter (e.g. c:) or use "*" to include all volumes.Usage: disk2vhd <[drive: [drive:]...]|[*]> <vhdfile>Example: disk2vhd * c:vhdsnapshot.vhd
The Microsoft Virtual Hard Disk (VHD) format is the common virtualization file format that provides a uniform product support system, and provides more seamless manageability, security, reliability and cost-efficiency for customers. The VHD format captures the entire virtual machine operating system and the application stack in a single file.Virtual machine technology applies to both server and client hardware. Virtual machine technology enables multiple operating systems to run concurrently on a single machine. Virtual machine technology serves a variety of purposes. It enables hardware consolidation, because multiple operating systems can run on one computer. Another of the key applications of virtual machine technology is seen in test and development environments, where features such as faster provisioning, re-usability of the VHDs and ability to be hardware agonistic provide a more seamless environment.
The question is; Where should you get VHD files for your ultimate test network? There are a number of sources. Of course you could take you new found TechNet Plus subscription and build you own VHD from scratch. This way you know exactly what you are getting because you are actually building it. The drawback of course is this will take some time. The VHD Test Drive Program provides customers with an enhanced Windows Server-based software evaluation experience that’s faster and less expensive, better supported and more flexible. The VHD Test Drive program is a first for Microsoft software and the more than 7,000 software vendors who can now deliver pre-configured mainstream applications within Windows Server-based virtual machines to their customers. Microsoft partners can now offer their prospective/current customers greater choice during the software evaluation process for mainstream applications and make it easier to evaluate complex solutions through the distribution of pre-configured virtual machines that can run on Virtual Server 2005 R2 or Hyper-V. You can also use System Center Virtual Machine Manager, to manage all the virtual machines in your environment.The VHD Test Drive Program enables Microsoft and partners to distribute VHD images that contain Microsoft software and partner software. The VHDs are pre-built and pre-configured so that they can be downloaded or distributed for fast evaluation and testing of Microsoft software and partner applications.
If you want to move or copy a virtual machine with Hyper-V, then you will need to use the export / import functionality provided by Hyper-V. The first thing you need to do is to pick the virtual machine that you want to copy and / or move, and then select Export... from the action menu / pane.Before going further I need to cover virtual machine names and IDs. Each Hyper-V virtual machine has one of each of these. The virtual machine name is what you called the virtual machine. For today's post I am using a virtual machine with a name of "Test Export VM". While you are likely to give each of your virtual machines different names - the virtual machine name is not required to be unique. The virtual machine ID is a GUID that Hyper-V generates automatically for each virtual machine. This ID is used to uniquely identify one virtual machine from another. For the most part the virtual machine ID is never displayed in the Hyper-V user interface (with the exception of error messages). The virtual machine I am using for today's post has a virtual machine ID of "6D59FE56-6D20-4129-9BF3-2457DDB58A9A". Beyond this, each snapshot that a virtual machine has has its own name and ID. Hitting Export will result in Hyper-V copying everything that makes up the selected virtual machine into a new folder under the export path you specify. This new folder will be named after the virtual machine name (in my case: "C:exportTest Export VM"). Under this new directory will be the following items:The Virtual Machines folder This folder will contain a single .exp file, which will use the virtual machine ID for its name (in my case: "6D59FE56-6D20-4129-9BF3-2457DDB58A9A.exp"). The .exp file is the exported configuration of the virtual machine. There will also be another folder in this folder, which is also named use the virtual machine ID. If the virtual machine was in a saved state when it was exported this sub-folder will contain two saved state files (a .vsv and a .bin file), otherwise it will be empty. The Virtual Hard Disks folder This folder contains copies of each of the virtual hard disks associated with the virtual machine. Note that if you have two virtual hard disks with the same name (but different locations) associated with a virtual machine, exporting the virtual machine will fail. The Snapshots folder This folder will contain: A .exp file for each snapshot the virtual machine had (name after the snapshot ID) A folder named after the snapshot ID that contains the saved state files for the snapshot in question. A folder named after the virtual machine ID that will contain the differencing disks used by all of the snapshots associated with the virtual machine (.avhd files). config.xml It is not necessary for standard export / import usage. You can freely move / copy / backup this entire directory structure now. When you are ready to import the virtual machine you will need to go the the Hyper-V Manager and select Import Virtual Machine... from the action menu / pane.Before clicking Import there are three important things to know:You need to specify the folder that was created during export, not the folder that was used for export. So in my case I need to specify "C:ExportTest Export VM" instead of "C:Export". When you import a virtual machine it will be left in its current directory (in my case "C:ExportTest Export VM") and it will be impossible to move the virtual machine after import. So make sure that you move the exported virtual machine to your desired location before you import it. Importing a virtual machine deletes the .exp files, which stops you from importing it again. If you want to use an exported virtual machine as a backup / template that you will import multiple times - you need to make a copy of it before importing it. After you click Import the file structure of the exported virtual machine will remain roughly the same, with the following exceptions:The .exp files will be deleted and will be replaced with .xml configuration files. The config.xml file will be deleted. And now the virtual machine will appear under the Hyper-V manager and you will be able to interact with it directly.Please see http://blogs.msdn.com/virtual_pc_guy/archive/2008/08/26/hyper-v-export-import-part-1.aspx
You can create many virtual networks on the server running Hyper-V to provide a variety of communications channels. For example, you can create networks to provide the following:Communications between virtual machines only. This type of virtual network is called a private network.Communications between the virtualization server and virtual machines. This type of virtual network is called an internal network.Communications between a virtual machine and a physical network by creating an association to a physical network adapter on the virtualization server. This type of virtual network is called an external network. As a best practice, we recommend that you provide the physical computer with more than one physical network adapter. Use one physical network adapter to provide virtual machines with an external virtual network, including remote access to the virtual machines. Use the other network adapter for all network communications with the management operating system, including remote access to the Hyper-V role. The management operating system runs the Hyper-V role. Important Some configuration changes overwrite static settings. For example, if you connect a virtual network to a physical network adapter that uses static settings, such as a static IP address, the new connection will overwrite all IPv6 static settings. If you create an external network without sharing that network connection with the management operating system, and then reconfigure the external network to allow the management operating system to use the connection, that change will overwrite all static settings on the physical network adapter. Network connectivity may be lost until you reapply the static settings to the physical network adapter. You can use Virtual Network Manager to add, remove, and modify the virtual networks. Virtual Network Manager is available from Hyper-V Manager.
Virtual machine snapshots are file-based snapshots of the state, disk data, and configuration of a virtual machine at a specific point in time. You can take multiple snapshots of a virtual machine, even while it is running. You can then revert the virtual machine to any of the previous states by applying a snapshot to the virtual machine. To take a snapshot, you can use either Hyper-V Manager or Virtual Machine Connection. All of the other tasks you can perform with snapshots, such as applying or deleting a snapshot, or viewing a list of all snapshots for a specific virtual machine, are available through Hyper-V Manager. You also can inspect or edit the .avhd files, as well as determine which snapshot an .avhd file is associated with. For instructions on using and managing virtual machine snapshots, see the Windows 2008 Technical Library (http://go.microsoft.com/fwlink/?LinkID=143557). Important Do not edit a virtual hard disk when it is used by a virtual machine that has snapshots.Considerations about virtual machine snapshotsSnapshots can help you increase efficiency in many settings where you need to recreate different computing environments and reproduce various conditions in those environments. Some examples include software development and test, technical support services, and training curriculum development. However, the same power and flexibility that makes these snapshots useful and effective in certain settings can cause unintended and potentially serious consequences in other settings. These consequences include the inherent risks of unintended data loss if the snapshots are not managed appropriately. For example, if you edit a virtual hard disk connected to a virtual machine that has snapshots, data loss may occur. Appropriate settings for using snapshots are development and test activities, including using a virtual machine as a staging server to test updates and hotfixes before deploying them to production servers. We do not recommend using snapshots on virtual machines that provide time-sensitive services such as Active Directory services, or when performance or the availability of storage space is critical. Additionally, you should consider the following before you start using snapshots:Taking a snapshot reduces the performance of the virtual machine while the snapshot is created. You should not use these snapshots on virtual machines that provide services in a production environment.We do not recommend using snapshots on virtual machines that are configured with fixed virtual hard disks because they reduce the performance benefits that are otherwise gained by using fixed virtual hard disks.Snapshots require adequate storage space. Snapshots are stored as .avhd files in the same location at the virtual hard disk. Taking multiple snapshots can quickly consume a large amount of storage space. When you use Hyper-V Manager to delete a snapshot, the snapshot is removed from the snapshot tree but the .avhd file is not deleted until you turn off the virtual machine. Caution Do not delete .avhd files directly from the storage location. Virtual machine snapshots are not the same as the snapshots created by Volume Shadow Copy Services (VSS). Virtual machine snapshots can be a useful way to create temporary backups of a virtual machine, but are not a replacement for a permanent backup solution. For more information about backing up virtual machines, see Planning for Backup (http://go.microsoft.com/fwlink/?LinkId=143125).
Hyper-V Overview andBuilding a Test Environment Presented by Harold Wong Senior IT Pro Evangelist blogs.technet.com/haroldwong
Provided by: Hyper-V Architecture OS ISV / IHV / OEM Microsoft Hyper-V VM Worker Processes Microsoft / XenSource Child Partitions Parent Partition Applications Applications Applications Applications User Mode WMI Provider VM Service Windows Server 2008 Non-Hypervisor Aware OS Windows Kernel Windows Kernel Xen-Enabled Linux Kernel Windows Server 2003, 2008 VSP IHV Drivers Kernel Mode VMBus Linux VSC VSC Emulation VMBus VMBus Windows hypervisor Hypercall Adapter Ring -1 “Designed for Windows” Server Hardware
Disk2vhd Free Windows Sysinternals Tool Captures Online operating systems Can run from GUI or Command Line Runs on XPSP2, Server2003 SP1 and higher (Including x64 systems)
Virtualization as a SQL Server consolidation Strategy Compelling features SQL running in a VM gives immediate isolation capabilities at different levels Hardware isolation facilitates easy migration and HA Resource isolation enables predictable performance Increased hardware utilization with multiple VMs Multi Server Management cost savings Convenient unit of SQL Application life cycle management Identify opportunities for Data platform standardization Child Partition Server Root Partition Child Partition Server VSPs VSPs I/OStack Enlightenments I/OStack I/OStack VSCs Drivers VSCs VMBus VMBus VMBus Shared Memory Hypervisor Devices Processors Memory
Summary Hyper-V is a great base for building a testing environment! TechNet Plus is a great source for Operating Systems and Applications VHD format is very flexible Disk2vhd makes captures free and easy Snapshots make moving from point in time to point in time very easy
Resources for Hyper-V Building the Ultimate Test Network TechNet Library Hyper-V getting Started Guide http://technet.microsoft.com/en-us/library/cc732470(WS.10).aspx The Best Virtualization Tools http://www.microsoft.com/virtualization/en /us/resources.aspx