As I promised, I continue to “evangelize” and write another article about Hyper-V. At this time, it will be about the work of Hyper-V with storage devices - that is, hard drives and all sorts of external storage systems.
Where can virtual machines store data?
Virtual machine disks can be stored both on the server’s local hard disks and on external storage systems (SAN).

The diagram uses DAS. On disk Disk2 mounted on the host system as a disk Y :, a file VM1.vhd was created, which, in turn, is mounted on a virtual machine and used as a disk C :. And Disk3 connects to the virtual machine directly, and in the guest OS you can work with it as with the D: drive. In the host OS, Disk3 is in the Offline state, and it will not be possible to enter it.
Now let's see what options are available when using SAN.

The most "classic" version - LUN 1 is presented to the server, mounted on the host OS, for example, as a Z: drive, a VHD is already being created on it, which, in turn, is used by the virtual machine. Something like a fairy tale - “a needle in an egg, an egg in a duck, a duck in a hare, etc.”
The second option - LUN 2 is presented to the server, but in the host OS it is not mounted, but connected as a pass-through disk to the virtual machine.
In addition, if the SAN is based on the iSCSI protocol, the LUN can be mounted inside a virtual machine using a software iSCSI initiator running inside the guest OS. Unfortunately, FibreChannel-LUNs can not be connected in this way - Hyper-V does not have virtual FC-HBA.
Virtual Controllers
Let's start with the fact that a virtual machine, just like a real computer, has its own virtual hard disks and virtual hard disk controllers. These controllers are only two types: IDE and SCSI. What is the difference between them?
Firstly, unlike the IDE, the SCSI controller is a fully synthetic device, and therefore requires integration of its components for its operation. Therefore, it can be used only in those guest OS that support them (I remind you that this is only MS Windows, as well as RHEL and SLES). For the same reason, the guest operating system can only be loaded from an IDE device. The main difference between virtual IDEs and SCSI controllers is the number of devices that can work through this controller. IDE controllers in a virtual machine can have two, and a maximum of two virtual disks can be connected to each. There are four SCSI controllers, and up to 64 virtual disks can be connected to each controller, that is, the entire virtual machine can have 260 virtual disks (4 IDE + 4 * 64 SCSI). We must also remember that although real SCSI disks work faster than IDE - this is not quite true for a virtual environment. In the Hyper-V R2 environment, with the integration components installed, virtual IDE and SCSI disks work equally fast, and performance is determined only by the physical disk subsystem.
')
Virtual disks
Now let's see what the hard drives of virtual machines themselves can be. To begin with, Hyper-V supports both virtual hard disks represented as .VHD files and direct connection of disks to a virtual machine (the so-called pass-through-disks).
Virtual disks are special format files (.vhd). This format was originally developed by Connectix, and then, after its acquisition by Microsoft, it began to be used in virtualization products from MS — VirtualPC, Virtual Server, and now Hyper-V. At the moment, in Windows 7 and Windows Server 2008 R2, VHD files are supported at the OS level and can be mounted on the system as disks. Moreover, the OS itself can be installed on the VHD and boot from it. The VHD format is now fully open, and there are many third-party software (for example, from Paragon) that allows you to work with VHDs, and also VHDs are supported on some Citrix products. Virtual disks come in three types: fixed-size, dynamic, and differential.
Dynamic virtual disks are a VHD file that increases in size as you write to it. Dynamic disk during operation can be compressed by removing unused blocks that remain when deleting data from the VHD. The use of dynamic disks allows the most efficient use of disk space, but it is not recommended to use them in production-environment due to a possible performance drop.
Fixed-sized virtual disks are a file containing a set of blocks, presented to the virtual machine as a disk. The size of the virtual disk is set when it is created, and a VHD file of the appropriate size is created on the server’s hard disk. The creation process may take some time, depending on the size of the disk. The use of fixed-size discs is preferable to dynamic for two reasons. First, because the dynamic disk expands gradually, the VHD file may become fragmented, which will affect performance. A fixed-size VHD immediately takes up all the space it needs, and therefore is not fragmented during operation. Secondly, there may be a situation that the space on the physical disk will end, and the dynamic disks will have no place to "grow", and this may lead to malfunctions of the virtual machines.
Differential disk - always has a “parent” VHD. Reading at the same time can be carried out both from the “parent” and from the differential VHD itself, but the record goes only to the differential VHD, the “parent” remains unchanged. These are, for example, AVHD disks created during virtual machine snapshots. Learn more about snapshots - see my previous article. Also, differential VHDs can be used in a test environment when you need to raise several virtual machines with approximately the same contents of hard disks (for example, from an installed OS). The use of differential disks in a production-environment is not recommended firstly because of reduced performance (instead of reading from one VHD, you have to read several), and secondly because of reduced reliability (damage to the parental VHD causes damage to all differential).
The maximum size of virtual disks, both fixed and dynamic, is 2 terabytes (or 2,040 gigabytes).
Pass-through disks are the connection of physical disks directly to a virtual machine without creating VHD files. These can be either partitions on local hard drives or presented to the LUN server from an external storage system (SAN). For a host OS, after mounting to a virtual machine, the disk switches to the “Offline” state, that is, direct access to the disk is terminated. Mount mounted VHDs cannot be used as pass-through disks, nor do they support snapshots at the virtual machine level.
The size of pass-through-disks is not limited to 2 terabytes.
Sometimes questions arise: what is better to use - VHD or pass-through-drives? Some people think that VHDs are slower, but this is not true. Studies have shown that in Winodws Server 2008 R2 VHD and pass-through-drives work at the same speed. More information about the measurements you can read the
official document .
At this point I’ll probably finish; the next article will talk about the work of virtual machines with a network. If there are any questions on the topic of the article - as usual, you are welcome in the comments.