Virtual machine (VM): Virtual environment that emulates physical computer’s hardware and BIOS.
Purpose of hyper-V:
- Return on investment in real money and in productivity gains.
- Server consolidation.
- Application isolation.
- Convenient testing of application installations and upgrades.
Two types of hypervisor:
Type 1, (bare-metal virtualization) hypervisor runs directly on the host computer’s hardware.
Type 2,(hosted virtualization) hypervisor is installed in a general purpose host operating system, and host accesses host hardware on behalf of the guest OS.
Turn off or shutdown(2012?)
Shutdown: ACPI shutdown
Turn off: same as unplug the power, the machine will show unexpected shutdown in the next time booting up. In VMware, you will see Power off, the same function.
You can assign to the virtual machine up to the total number of physical processors or processor cores installed on the host computer.
For example, if you run hyper-V server on a quad-core Xeon, you can assign up to 4 virtual processors to each of your VMs.
It is recommended that assign one or more virtual processors per VM while reserving one physical processor(or core) to the host computer. Eg. If your run a quad-core processor host machine, and you will run 3 VMs on the host, allocate each VM one virtual processor, thereby reserving one for the host computer.
Remember that 32 MB memory will be needed for the a memory allocation up to 1 GB. If your host computer need 512 MB, you will instal 3 virtual machines which need 1GB for each. So the total memory you need for the host computer is : 512+(32+1024)*3=3.6G
- Host computer can communicate with VMs, but VMs can not connect to physical network directly.
- VMs can connect to a virtual NIC in the host. If you need, you can set up a route on the host for the virtual NIC and the physical NIC, which is connected to the physical network, to get the access to physical network from VMs.
Use one dedicated physical NIC for the External virtual network. Windows binds the Microsoft Virtual Network Switch Protocol to the physical NIC and unbinds all other protocols.
A new virtual network adapter(virtual NIC) is created that has all the usual protocol bindings enabled, this virtual NIC is used to communicate with VMs.
Virtual storage (Hard disk)
3 kinds of VHD:
1. Dynamically expanding:
- Start from a very small size, grows ass data is written to it up to the size specified by creator.
- The VHD file will not shrink when the data is deleted in the VMs.
- The performance is about 10-15% slower than fixed size disks when the fragmentation is not considered.
As we store file in the VM not continuously, at the same time the physical disk is saving data too. So the VHD on the physical disk is not stored continuously.
Eg. On Monday morning, we stored 1 GB data on the VHD in VM, in the afternoon we stored 500 MB on the host system, this data may be stored straight after the VHD file. On tuesday, we stored anther 1GB data on the VHD in the VM, this data is stored far away from the 1GB data stored last time on Monday Morning. In this case, the host disk is fragmented.
2.Fixed size: the VHD take the full amount of space on the host disk.
- Better performance. Less chance to cause host disk fragmented.
3. Differencing(.avhdx file):
A differencing disk uses a parent/child relationship. For more info check here.
- Parent disk: is a VHD with OS installed, can be either dynamic or fixed size. It is the baseline for child disk, or differencing disks.
Note that the parent disk should not be connected to VM since the parent disk must not be changed in any way.
We recommend that you write-protect or lock the parent disk before using the differencing disk. Otherwise, if the parent disk is modified by some other process, all differencing disks related to it become invalid, and all data written to the differencing disks is lost. You also need to modify the virtual machine by replacing the parent disk with differencing disk, otherwise you will receive an error when you try to start the virtual machine because it cannot use a read-only disk. For instructions, see Add or remove a virtual hard disk.
- Child disk(differencing disk): any change made to the VM’s hard disk are made only to the differencing disk. Child disk expanding dynamically when new data is written to it.
Differencing mode can be useful when deploy several VMs without installing OS again and again; without copy an entire virtual disk.
Provides enhanced drivers for the guest OS that bring better performance and functionality to IDE and SCSI storage devices, NIC, mouse and video driver.
Without integration services:
- Mouse will be captured by the VM when click inside the VM, only “Ctrl+ALT+<-” can release the mouse from guest to host.
- Mouse will not functional if access the guest OS through Remote desktop.
- Examples of additional services
- Operating system shutdown
- Time synchronization
- Data exchange:Allow VM and host to exchange information using registry keys.
- Heartbeat: Host will detect when the VM has locked up or crashed by sending periodically heartbeat messages. If the guest fails to respond, the host machine will log an event.
Automatic start and stop action
Can be accessed from the setting of a VM.
Automatic start action:
- Nothing: VM will not start when the host computer starts.
- Automatically start if it was running when the service stopped(default action):
If the VM was running when the host machine was turned off, the VM will be started when the host starts.
If the VM was not running when the host machine was turned off, then the VM will not be started.
- Always start the virtual machine automatically : the VM will always be started when the host starts.
- Startup delay: This suits when multiple VMs are set to start automatically, if they all start up at same time, the host resource be used up.So we can use this option to start up them one by one.
- Save the virtual machine state(default action): The sate of the VM is saved when the host is shut down, which is similar to hibernate mode for a desktop computer. Not recommended for domain cotrollers.
- Turn off the virtual machine: like unplug the power cord on a physical machine.
- Shut down the guest operating system: VM wil undergo a graceful ACPI shutdown.
Snapshots are let you revert your VM to a previous state, allowing you to explore what if scenarios and recover from installation and configuration that have gone wrong.
- Can create up to 50 snapshots per VM.
- Can revert your VM to any of the saved snapshots.
- Once a snapshot is created, cannot change the snapshot location for that VM.
- Should always use Hyper-V Manager to delete snapshots.
If you delete a snapshot, actually the snapshot file is merged with the original hard disk file(.vhd). So you can see from the location in the host os that the “.avhd” disappeared and the original hard disk file become bigger.
- Snapshots decrease the disk performance of the virtual machine.
- Snapshots must be deleted before expanding a disk.
Caveats in using snapshots:
- Snapshots should not be used in distributed database environments or transactional systems such as with domain controllers or mail servers. In fact, Micrososft does not support the use of snapshots on VMs hosting active directory or AD-lightweight directory services.
- Snapshots decrease the disk performance of the VM.
- Snapshots must be deleted before expanding a disk.
- Snapshots cannot be used with pass-through or differencing disks.
- If you create a snapshot while the VM is running, the amount of space required for the snapshot includes the amount of memory allocated to the VM( like a hibernate file). Ideally, create snapshots while the VM is shut down to reduce the disk space used.