- Internet & the Web
Virtualization - Memory Part 3
Hyper-V uses Dynamic Memory, which allows memory needed by a Virtual Machine to be allocated and de-allocated dynamically and to share unused memory between virtual machines. Consequently, Dynamic Memory has been a part of Hyper-V before Windows Server 2012. But several new improvements have been made. It now uses Ballooning and Internal Guest Paging to handle the memory that a guest OS more efficiently. Also you can make changes to Dynamic Memory allocation while the virtual machine is running. Other improvements include Smart Paging, which is a memory management technique that provides reliable restart for virtual machines with less than the minimum memory that is required for startup memory. By using disk space when there isn’t enough physical RAM on a host to provide the minimum memory required by the VM as it restarts. Smart Paging only happens when all the following parameters apply:
- The virtual machine is being restarted.
- There is no available physical memory on the host.
- No memory can be reclaimed from other virtual machines running on the host.
Smart Paging is not used in the following circumstances:
- A virtual machine is being started from an off state (as opposed to a restart).
- Oversubscribing memory for running a virtual machine is required.
- A virtual machine is failing over in a Hyper-V cluster.
Because of the performance degradation that comes from paging to disk, Smart Paging is only a temporary measure to assist a virtual machine during a restart.
Start and Stop Actions
You can configure a number of start and stop actions. The configurable start actions:
- Do nothing.
- Automatically start if it was running when the VM service stopped.
- Always start the VM.
The configurable stop options:
- Save the state of the VM.
- Turn off the VM.
- Shut down the virtual operating system.
Integration of Virtual Machines and Hosts
The most important aspect to virtual machine performance is making sure that the guest operating system has all the necessary drivers to run in the virtual machine environment. These drivers are included in the integration services and they are available for older Microsoft operating systems as well as Linux, and are installed by default on operating systems newer than Windows 7 and Windows 2008.
To use integration services, you must install them in the guest operating system. Also, they must be supported by the guest operating system. There are some services that may not be available to particular guest operating systems, including file shadow copy and operating system shutdown.
It is possible to integrate the VM with the host operating system. The following items can be integrated:
- Operating system shutdown
- Time synchronization
- Date exchange
- Backup (volume snapshot)
Dynamic Memory Management
Dynamic memory allows memory needed by the VM to be allocated and de-allocated dynamically (you specify a minimum and maximum), and unused memory to be between Virtual Machines.
Startup RAM specifies the amount of memory required to start the VM. The value needs to be high enough to allow the guest operating system to start, but as low as possible to conserve host RAM for other Virtual Machines.
Maximum RAM specifies the maximum amount of memory that a virtual machine is allowed to use. The value can be set from as low as the value for Startup RAM or as high as 64 GB. However, you must remember that Hyper-V cannot use more memory than the guest operating system is able to address. So if the guest operating system is a 32-bit Windows client, then 4 gigabytes of memory will be the most that can be addressed.
The advantages to specifying minimum and maximum RAM is that, should other virtual machines need to scavenge some unused RAM, Hyper-V can allocate a virtual machine's unused RAM, down to the specified minimum, to those other Virtual Machines. Specifying maximum RAM puts a cap on the total resources that a virtual machine will allocate for itself.
Virtual Hard Disks
A special file format that represents a traditional hard disk drive is a virtual hard disk. It can be used for storage, and you can add multiple hard disks to the IDE or SCSI controllers available in the Virtual Machine. You can use virtual hard disks (VHD or VHDX files) or actual disks that you pass directly through to the virtual machine.
Virtual Hard Disks can also reside on a remote file server. There are two main types of virtual hard disks, dynamically expanding and fixed size.
The older format for virtual hard disks was the VHD format. The newer VHDX format has the following benefits over the VHD format:
- The disks can be larger (64 TB versus 2 TB).
- Logging updates to the VHDX metadata structure protects against data corruption during power failures.
- It allows larger block size for dynamic and differencing disks.
- Improved alignment of the virtual hard disk format works better on large-sector disks.
- A 4-KB logical sector virtual disk increases performance for applications designed for 4-KB sectors.
- It has the ability to store custom metadata about the file, such as operating system version or patch applied.
- It provides efficiency in representing data, also known as trim, resulting in smaller file size, allowing the underlying physical storage device to reclaim unused space but requires trim- compatible hardware and directly attached storage.
VHDX files are only available on Windows Server 2012, and are created by Hyper-V Manager by default. You can also convert your VHD to a VHDX or vice versa in Hyper-V Manager by selecting Edit Disk and then selecting Convert. Using the same tool, you can also choose to select, expand or shrink existing VHD/VHDX files, as well as defragment them.
A differencing disk represents only the changes from the original disk, which can save a lot of space. You have a base disk that will remain constant, and you can make a lot of clones from that disk, each with their own configuration. Say you want to have five different Virtual Machines of Windows Server 2012, and they all start with the same basic configuration of a generic install of the operating system. The base disk, also known as the Master or parent disk, could be a Sysprepped fully installed operating system on a VHDX.
You can then create differencing disks for each copy. You then configure each differencing disk with computer-specific information, as well as install applications.
It is important to understand here that all of the child disks, the differencing disks, will be dependent on the parent. The parent must not be altered otherwise the children will all become unusable. For that reason, the parent disk you created should be marked as read only. You can accomplish this in the GUI or by simply using DOS attributes.
After you have created the parent VHDX, you can Sysprep it. As this will strip out the computer security identifier (SID), the computer name, the administrator password, regional settings, and any other computer-specific information.
A Snapshot is a point-in-time copy of a virtual machine. A snapshot won’t affect the running copy of the virtual machine. These are not new to Windows Server 2012; however, there have been improvements. It is no longer necessary to shut down, turn off, or put the virtual machine into a saved state to recover the storage space.
A snapshot can be used to roll a VM back to a previous state. This is especially useful in a lab. A snapshot should not however be considered a replacement for backups if your virtual machine is being used as an actual production server.
Once you have a snapshot, you can right-click the snapshot to rename it, apply it to roll your VM back to a point in time, delete it, delete a whole succession of snapshots under it, or export it. This can useful because you can apply the exported snapshot to another virtual machine, effectively creating a clone of the first Virtual Machine. As such, it could be used as an emergency failover measure.
Exported snapshots that are imported to another Virtual Machine are not an optimal failover solution.
You would have to create and export snapshots on a very regular basis to make sure they are up-to-date, you would have to make sure that the other Virtual Machine is on the same physical segment so it can assume the IP address of the failed VM, and you would also have to have a strategy for moving any new data from the stand-in back to the original once you bring it online.
A pass-through disk is a physical disk that the guest Virtual Machine can directly access. It must be directly attached, or it can be a storage area network (SAN) logical unit (LUN) mapped to the Hyper-V server. The pass-through disk must be placed in an offline state from the Hyper-V server's perspective so that the VM can have exclusive access to it. However, it needs to be initialized by the Hyper-V server first and then put back in an offline state in Disk Manager.
The host should not attempt to format the drive; that is for the VM guest to do. There is no theoretical size limit for a pass- through disk. It is possible to install the VM operating system on the pass-through disk, but if you choose to do so, you must make sure that the VM configuration file is stored on a different disk. The reason for this is that installing the operating system will take up the entire pass-through disk.
A pass-through disk cannot be dynamically expanded, cannot have snapshots, and cannot use differencing disks.
Resource Metering can be used to monitor Hyper-V resources. Resource Metering allows you organization to create cost-effective, usage-based billing solutions. With this feature, service providers can choose a billing strategy that is appropriate for their business model. Independent software vendors can then develop end-to-end chargeback solutions.
You can monitor these resources:
- Average GPU use
- Memory use (average, minimum, and maximum) Maximum disk space allocation
Incoming network traffic for a network adapter Outgoing network traffic for a network adapter