Welcome to the ITFreeTraining video on Virtual Hard Disks or VHD’s in Windows. This video
will look at what a VHD is and the new VHDX file format.
First, what is a virtual hard disk or VHD? This is a file format that represents a physical
drive, in a file. So, essentially, it is what is found on a hard disk drive or solid state
drive, in a file. Microsoft started using the file format with Microsoft Virtual PC.
Essentially, when you create a virtual PC you need somewhere to store the data from
the virtual hard disks of the virtual machine, and the VHD is where this data is stored.
To understand this, consider that you have a physical server. On this physical server
you want to run a virtual server. A virtual server is a server that shares the hardware
of the physical server and its resources.
On this particular physical server, if a virtual server were to be created, this virtual server
would run on the physical server. Like a physical server, the virtual server requires RAM, CPU
and storage. In order to achieve this, the virtual server has its own virtual CPU, virtual
RAM and virtual hard disk.
The virtual components provide the interface to the physical hardware. For example, a virtual
CPU may be created with a single core even though the physical CPU has more cores. Virtual
RAM is shared with the operating system; in some cases it is possible to allocate more
RAM to virtual machines then there is in the physical server. That idea behind this is
that not all virtual machines will be using all their allocated RAM at one time. Lastly,
the virtual hard disk is what we are interested in, in this case. Using the virtual hard disk,
the virtual machine is able to store data on the physical drive on the server.
You can already see that there are some advantages to virtual machines in the way CPU and RAM
are allocated. With storage, since the virtual hard disk is providing an interface to the
physical drive, more features can be added. For example, the ability to pause all access
to the drive while a snap shot is created. A snap shot allows the hard disk to be reverted
back to the state it was when the snap shot was created. So how is this possible?
To understand how virtual hardware works consider this. A virtual server is created and runs
applications inside it. Like an application running on a physical computer the application
needs access to an operating system to access features and hardware. To do this, it accesses
an operating system that is installed on the virtual machine. Like a physical operating
system, there are device drivers installed. These device drivers differ from regular device
drivers in that they are used to access virtual hardware rather than physical hardware, but
the applications and operating system running on the virtual machine do not know that.
The virtual device driver accesses the virtual solution used to provide virtual services.
The virtual solution then translates the use of the virtual hard disk to a physical file
on a physical drive. You can start to see how this is possible. The virtual solution
is able to modify and translate calls to the virtual hard disk, making the operating system
think it is communicating to a physical hard disk.
The advantage of this is that additional features can be added, for example snap shots and dynamic
disk features can be added. Something that is not possible with physical drives. All
this does come at a cost, and this cost is performance. Extra software is required to
interpret and translate calls to access the physical hardware, which slows down the performance
of the virtual machine compared with physical hardware. Now let’s have a closer look at
the VHD file format.
The virtual hard disk format or VHD, was first acquired by Microsoft in 2003 by way of acquiring
the company that developed it. The technology was first used in the Microsoft product Microsoft
Virtual PC and has continued to be used in products like Hyper-V.
The format also allows a number of different file formats for the virtual hard disk, These
include, fixed, dynamic and differencing. To understand how these work I will have a
look at each, one at a time.
The fixed virtual machine is simply when the file containing the virtual hard disk is the
same size as the virtual hard disk. In this case, if you had a 20 gigabyte virtual hard
disk it would take up 20 gigabytes of size on the physical drive, in the form of a VHD file
The advantage of this is improved performance. Since the virtual drive is the same size as
the VHD file, it is a simple process to write data to the file. The disadvantage of this
is that fixed drives are slower to create. For example, if you created a 100 Gigabyte
fixed drive you would need to wait until a 100 Gigabyte VHD file is created. If you have
slow mechanical drives, this can be a time consuming process especially if you need to
create multiple virtual hard disks.
The next type is dynamic. Dynamic uses storage space as required. For example if you created
a 100 gigabyte virtual disk this could have 100 gigabytes of data placed on the drive.
However, the initial creation would use the bare minimum amount of space. If, say 20 gigabytes
of files were placed on the virtual hard disk, the following would occur. On the physical
drive, the VHD file would increase in size to 20 gigabytes. This could increase to a
maximum of 100 gigabytes. You may never need to use this much space but it is there if
you need it. You can see why some administrators will create dynamic drives bigger than what
they feel they need in case they need more space later on.
The advantage of dynamic drives is that they are fast to create. Usually a dynamic drive
will only takes a few seconds to be created, while a fixed drive will require the administrator
to wait until a file of the size of the fixed drive has been created. The disadvantage of
dynamic drives is there is reduced performance. In order to have the drive expand as required
the data on the VHD file is not laid out as well as it could be.
After a dynamic disk has had data stored and removed from it, to make it work better the
dynamic virtual disk can be compacted. This process arranges the data and removes any
space that is no longer used. Microsoft recommended that you perform this after installing the
operating system due to the number of temporary files created during the install process.
Compacting is also recommended after deleting large amounts of data or when you are archiving
the VHD, for example storing it on optical media.
The next disk type I will look at is differencing. This disk type records the differences from
the master disk known as the parent disk. Let’s consider the following. If you create
a virtual hard disk, you could configure it how you wanted, for example installing an
operating system on it.
Once you have the virtual hard disk configured the way that you want it, the next step is
to create a second virtual hard disk known as a child. The second virtual hard disk will
use the parent drive for its data. This means that a virtual machine using this virtual
drive will see the data stored on the parent drive. If any changes are made to the drive,
the child drive is used to record these changes. The combined parent drive and changes on the
child drive are what are seen by the virtual machine.
So you can see that the virtual machine sees the one virtual hard disk. However, this virtual
hard disk is the parent and child disks combined into one. The parent contains the initial
data and the child contains any changes that have been made to the parent.
The main advantage of a differencing disk is that it can save space. If I were to add
a second differencing disk, notice that a virtual machine that is using this disk will
once again see the data on the parent disk.
If the virtual machine makes changes to the virtual disk, these changes would be recorded
in the differencing disk. You can see how using differencing can save a lot of space
if you have a number of virtual machines that are accessing the same data and also how it
keeps track of changes. If you are planning to use differencing virtual hard disks, it
is recommended that once the parent is created, you make it read only. Any changes to the
parent will affect all differencing virtual disks that are using that parent.
You can see there are a number of different choices for how you can configure your virtual
hard disks.
Regardless of which VHD format that you choose, there are some advantages to it. First, since
VHDs are file based, they are easy to move, backup and restore. If you, for example, needed
to move a virtual machine from one server to another, you would simply move the VHD
file and its configuration file to the other server, Import the configuration files, and
start up the virtual machine.
VHD’s also allow easy duplication and, thus, allow prebuilt configurations. For example,
you could perform a base install of Windows Server. Once the install is complete, each
time you want a new virtual machine running Windows Server you could duplicate the VHD
file, start the virtual machine using the duplicated VHD file, and then make the required
changes.
VHD files were first developed in the early 2000s so there are some limitations. VHD files
are limited to 2 Terabytes in size. VHD’s also add overhead to hard disk operations.
When virtual machine technology was first developed, it emulated existing physical hardware
on the market. Operating systems and hardware back then were not designed to run virtual
machines. Nowadays, hardware has improved to offer direct access to hardware for virtual
machines and thus this overhead has decreased. However, there are still some limitations
in the VHD format that are better understood by looking at the VHDX format.
The VHDX file format has improved the virtual disk format and addresses some of the issues
with VHDs. First there is support for 64-Terabyte virtual disks to be created, which addresses
the 2 Terabyte limit with VHD.
Next there is improved protection against data corruption. VHDX files use logging when
updates are performed. This helps protect the virtual drive if there is a power loss
while the virtual hard disk is being updated.
To address some of the performance issues with virtual hard disks, VHDX has improved
alignment with large sector disks. If the virtual disk can use the same sector size
as the physical disk it is stored on, this can improve the efficiency of the virtual
drive. This is particularly important when using block based software like backup and
restore software.
Next, there is improved performance of dynamic and differencing disks. If you are using either
of these disk types it is worth taking the time to have a look at VHDX disks.
The changes in the VHDX format also gives better support for Trim. Trim is technology
often found in solid state drives. Trim, when used, allows for better distributions of writes
on solid state drives rather than particular parts being used more than others. This extends
the life of the drive. The improved alignment feature allows trim to work better.
The VHDX file format is only supported on Windows Server 2012 and Windows 8. Windows,
however, does allow you to convert VHD to VHDX and vice versa. This means that if you
decide to move a virtual machine that is using a VHDX file to an older operating system,
you can convert the virtual hard disk. This is great because it allows you to try out
the new format without having to worry about backward compatibly later on unless the virtual
hard disk file is greater than 2040 Gigabytes.
That covers it for the basics of VHD and VHDX files. In the next video, I will perform a
demonstration of how this can be used. I hope to see you in that video and the other free
videos from us. Until then, thanks for watching.