Hyper-V and storage devices

    image

    As I promised, I continue to “evangelize” and write another article about Hyper-V. This time we will talk about the work of Hyper-V with storage devices - that is, hard disks and all kinds of external storage systems.


    Where can virtual machines store data?


    Virtual machine disks can be stored both on the local hard drives of the server, and on external storage systems (SAN).

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

    The most “classic” option - LUN 1 is presented to the server, mounted in the host OS, for example, as a Z: drive, VHD is already created on it, which, in turn, is used by the virtual machine. Like in 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 is connected as a pass-through-disk to the virtual machine.
    In addition, if the SAN is built on the basis of the iSCSI protocol, the LUN can be mounted inside the virtual machine using the iSCSI initiator running inside the guest OS. Unfortunately, FibreChannel-LUNs cannot be attached in this way - there is no virtual FC-HBA in Hyper-V.

    Virtual controllers


    So, 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 of only two types: IDE and SCSI. What is the difference between the two?
    Firstly, unlike the IDE, the SCSI controller is a fully synthetic device, and therefore requires the installation of integration components for its operation. Therefore, you can use it only in those guest OSs 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 boot from the IDE device. The main difference between virtual IDEs and SCSI controllers is the number of devices that can work through this controller. There can be two IDE controllers in a virtual machine, and a maximum of two virtual disks can be connected to each. There can be four SCSI controllers, and up to 64 virtual disks can be connected to each controller, that is, a virtual machine can have 260 virtual disks (4 IDE + 4 * 64 SCSI). It should also be remembered that although real SCSI disks are faster than IDEs, this is not entirely true for a virtual environment. In a Hyper-V R2 environment, with the integration components installed, virtual IDE and SCSI disks are equally fast, and performance is determined only by the physical disk subsystem.

    Virtual disks


    Now let's see what the hard disks 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 (so-called pass-through disks).
    Virtual disks are files in a special format (VHD). This format was originally developed by Connectix, and then, after its acquisition by Microsoft, it was used in virtualization products from MS - VirtualPC, Virtual Server, and now - Hyper-V. Currently, in Windows 7 and Windows Server 2008 R2, VHD files are supported at the OS level and can be mounted as disks in the system itself. Moreover, the OS itself can be installed on VHD and boot from it. The VHD format is currently completely open, and there are many third-party software (for example, from Paragon) that allows you to work with VHD, as well as VHDs are supported in some Citrix products. Virtual disks come in three types: fixed size, dynamic, and differential.
    Dynamic virtual disks are a VHD file that grows in size as you write to it. A dynamic disk during operation can be compressed by removing unused blocks that remain when deleting data from VHD. Using dynamic disks allows the most efficient use of disk space, but it is not recommended to use them in a production environment due to a possible performance drop.
    Fixed size virtual disksare a file containing a set of blocks presented to the virtual machine as a disk. The virtual disk size is set when it is created, and a VHD file of the corresponding size is created on the server’s hard disk. The creation process may take some time, depending on the size of the disk. Using fixed-size disks is preferable to dynamic disks for two reasons. Firstly, as the dynamic disk expands gradually, the .vhd file may fragment, which will affect performance. A fixed-size VHD immediately takes up all the space it needs, and therefore does not fragment during operation. Secondly, there may be a situation where the space on the physical disk runs out, and dynamic disks have nowhere to grow, and this can lead to disruptions in the operation of virtual machines.
    Differential drive- always has a "parent" VHD. In this case, reading can be carried out both from the “parent” and from the differential VHD itself, but writing is only to the differential VHD, while the “parent” remains unchanged. Such, for example, are AVHD disks created with snapshots of a virtual machine. For more information about snapshots, see my previous article. Differential VHD can also be used in a test environment when it is necessary to raise several virtual machines with approximately the same contents of hard drives (for example, with the installed OS). It is not recommended to use differential disks in a production environment, firstly, because of reduced performance (instead of reading from one VHD, you have to read from several), and secondly, because of reduced reliability (damage to the parent VHD will damage all differential ones).
    The maximum size of virtual disks, both fixed and dynamic, is 2 terabytes (or 2040 gigabytes).
    Pass-through disks are the connection of physical disks directly to a virtual machine without creating VHD files. It can be either partitions on local hard drives or presented to the LUN server from an external storage system (SAN). For the host OS, the disk, after mounting to the virtual machine, goes into the “Offline” state, that is, direct access to the disk is terminated. 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-disks? Some people think VHDs are slower, but that's not true. Research has shown that in Winodws Server 2008 R2, VHD and pass-through drives work at the same speed. More information on measurements can be found in the official document .

    I’ll probably end with this, the next article will talk about how virtual machines work with the network. If there are any questions on the topic of the article - as usual, you are welcome to comment.

    Also popular now: