In addition to virtual networks, you need to manage virtual hard disks that you attach to your virtual machines. A virtual hard disk in Hyper-V , apart from a pass- through disk, is a VHD or VHDX file that basically simulates a hard drive on your virtual machine.
The following subsections will first show you what types of virtual hard disks are available and then show you how to create them. You will also learn what options are available to manage virtual hard disks.
Types of Hard Disks
Depending on how you want to use the disk, Hyper- V offers various types, as described in Table 2.4.
TABLE 2.4 Virtual hard disks in Hyper-V
Dynamically expanding | This disk starts with a small VHD file and This option is effective when expands it on demand once an installation you don’t know the exact takes place. It can grow to the maximum size space needed on the disk you defined during creation. You can use this and when you want to pretype of disk to clone a local hard drive during serve hard disk space on the creation. host machine. Unfortunately, it is the slowest disk type. |
Fixed size | The size of the VHD file is fixed to the size A fixed- size disk prospecified when the disk is created. This vides faster access than option is faster than a dynamically expanding dynamically expanding or disk. However, a fixed- size disk uses up the differencing disks, but it is maximum defined space immediately. This slower than a physical disk. type is ideal for cloning a local hard drive. |
Differencing | This type of disk is associated in a parent- child Differencing disks are most relationship with another disk. The differencing commonly found in test disk is the child, and the associated virtual disk environments and should is the parent. Differencing disks include only not be used in production the differences to the parent disk. By using this environments. type, you can save a lot of disk space in similar virtual machines. This option is suitable if you have multiple virtual machines with similar operating systems. |
TABLE 2.4 Virtual hard disks in Hyper-V (continued)
Type of disk | Description | When to use it |
Physical (or pass- through disk) | The virtual machine receives direct pass- through access to the physical disk for exclusive use. This type provides the highest performance of all disk types and thus should be used for production servers where performance is the top priority. The drive is not available for other guest systems. | This type is used in high- end datacenters to provide optimum performance for VMs. It’s also used in failover cluster environments. |
Creating Virtual Hard Disks
To help you gain practice in creating virtual hard disks, the following three exercises will teach you how to create a differencing hard disk, how to clone an existing disk by creating a new disk, and how to configure a physical or pass- through disk to your virtual machine. First, in Exercise 2.3, you will learn how to create a differencing virtual hard disk.
EXERCISE 2.3
Creating a Differencing Hard Disk
- Open Hyper-V Manager.
- In Hyper- V Manager, in the Actions pane, choose New ➢ Hard Disk.
- In the New Virtual Hard Disk Wizard, click Next on the Before You Begin page.
- At the Choose Disk Format screen, choose VHDX and click Next. The size of your
VHDs depends on which format you choose. If you’re going to have a VHD larger than 2,040 GB, use VHDX. If your VHD is less than 2,040 GB, then you should use VHD.
- On the Choose Disk Type page, select Fixed Size and click Next.
- On the Specify Name And Location page, enter the new name of the child disk (for example, newvirtualharddisk.vhd). You can also modify the default location of the new VHD file if you want. Click Next to continue.
- Next, on the Configure Disk page, you need to specify the size of the VHD file. Choose a size based on your hard disk and then click Next to continue. I used 60 GB as our test size.
- On the Completing The New Virtual Hard Disk Wizard page, verify that all settings are correct and click Finish to create the hard disk.
The process to add a physical or pass- through disk to a virtual machine is quite different. For this, first you need to create the virtual machine, and then you open the virtual machine settings to configure the physical disk. If you want to add a physical disk to a virtual machine, the physical disk must be set as Offline in Disk Management, as shown in Figure 2.10.
FIGURE 2.10 In Disk Management, you can set disks as Offline.
To access Disk Management, click the Windows Key, choose Administrative Tools ➢ Computer Management, expand Storage in the left pane, and click Disk Management.
Physical or pass- through disks might not be that important if your use of virtualization is based on test environments, but they become crucial when you need to plan for highly available virtual datacenters. This is especially true if you consider using failover clusters to provide the Quick Migration feature, which is when you should consider matching one logical unit number (LUN) from your enterprise storage system or storage area network (SAN) as one physical disk. This provides you with the optimum performance you need in such an environment.
Managing Virtual Hard Disks
Hyper- V also provides two tools to manage virtual hard disks: Inspect Disk and Edit Disk. These tools are available in the Actions pane in Hyper-V Manager.
Inspect Disk This provides you with information about the virtual hard disk. It shows you not only the type of the disk but also information such as the maximum size for dynamically expanding disks and the parent VHD for differencing disks.
Edit Disk This provides you with the Edit Virtual Hard Disk Wizard, which you can use to compact, convert, expand, merge, or reconnect hard disks. Figure 2.11 shows you the wizard’s options when you select a dynamically expanding disk.
FIGURE 2.11 The Edit Virtual Hard Disk Wizard
Table 2.5 provides you with an overview of what you can do with the wizard.
TABLE 2.5 Edit Virtual Hard Disk Wizard overview
Action | Description |
Compact | Reduces the size of a dynamically expanding or differencing disk by removing blank space from deleted files. |
Convert | Converts a dynamically expanding disk to a fixed disk or vice versa. |
Expand | Increases the storage capacity of a dynamically expanding disk or a fixed virtual hard disk. |
Merge | Merges the changes from a differencing disk into either the parent disk or another disk (applies to differencing disks only!). |
Reconnect | If a differencing disk no longer finds its referring parent disk, this option can reconnect the parent to the disk. |
Generation 1 vs. Generation 2 VHDs
Previous versions of Hyper- V had some pretty major drawbacks. One big drawback was that Hyper- V could not boot a virtual machine from a virtual hard drive that was SCSI. Believe it or not, SCSI controllers were not even recognized by Hyper-V unless you installed the Integration Services component.
Another issue that the previous versions of Hyper- V had was the inability to copy files from the Hyper- V host to the virtual machines without the use of a network connection in the virtual machine. The older versions of Hyper-V , prior to Windows Server 2016, are now considered Generation 1 versions. Why is it so important to know which generations of
Hyper- V you should use or need to use?
Hyper- V generations help determine what functionality and what virtual hardware you can use in your virtual machine. Windows Server 2022 Hyper-V supports both virtual machine generations: Generation 1 and Generation 2.
As already explained, previous versions of Hyper-V are considered Generation 1, and this provides the same virtual hardware to the virtual machine as in previous versions of Hyper- V.
Generation 2 is included with Windows Server 2022, and it provides better functionality on the virtual machines including secure boot (which is enabled by default), the ability to boot from a SCSI virtual hard disk or boot from a SCSI virtual DVD, the ability to use a standard network adapter to PXE boot, and Unified Extensible Firmware Interface (UEFI) firmware support. Generation 2 now gives you the ability to support UEFI firmware instead of BIOS- based firmware. On a virtual machine that is Generation 2, you can configure Secure Boot, enable TPM, and set security policies by selecting the Security section of the virtual machine’s properties.
So, when you create VHDs in Windows Server 2022, one of your choices will be the ability to create the VHDs as a Generation 1 or Generation 2 VHD. If you need the ability to have your VHDs run on older versions of Hyper-V , make them a Generation 1 VHD. If they are going to run only on Windows Server 2012 R2 and above, make your VHDs Generation 2 and take advantage of all the new features and functionality.
Leave a Reply