Shared virtual hard disks
This new and improved feature in Windows Server 2012 R2 allows an administrator to share a virtual hard disk file (the .vhdx
file format) between multiple virtual machines. These .vhdx
files can be used as shared storage for a failover cluster created between virtual machines (also known as guest clustering). A shared virtual hard disk allows you to create data disks and witness disks using .vhdx
files with some advantages:
- Shared disks are ideal for SQL database files and file servers
- Shared disks can be run on generation 1 and generation 2 virtual machines
This new feature allows you to save on storage costs and use the .vhdx
files for guest clustering, enabling easier deployment rather than using virtual Fibre Channel or Internet
Small Computer System Interface (iSCSI), which are complicated and require storage configuration changes such as zoning and Logic Unit Number (LUN) masking.
In Windows Server 2012 R2, virtual iSCSI disks (both shared and unshared virtual hard disk files) show up as virtual SAS disks when you add an iSCSI hard disk to a virtual machine. Shared virtual hard disks (.vhdx
) files can be placed on
Cluster Shared Volumes (CSV) or a Scale-Out File Server cluster
Let's look at the ways you can automate and manage your shared .vhdx
guest clustering configuration using PowerShell. In the following example, we will demonstrate how you can create a two-node file server cluster using the shared VHDX feature. After that, let's set up a testing environment within which we can start learning these new features. The steps are as follows:
- We will start by creating two virtual machines each with 50 GB OS drives, which contains a sysprep image of Windows Server 2012 R2. Each virtual machine will have 4 GB RAM and four virtual CPUs.
Note
D:\vhd\base_1.vhdx
andD:\vhd\base_2.vhdx
are already existing VHDX files with sysprepped image of Windows Server 2012 R2.The following code is used to create two virtual machines:
New-VM –Name "Fileserver_VM1" –MemoryStartupBytes 4GB –NewVHDPath d:\vhd\base_1.vhdx -NewVHDSizeBytes 50GB New-VM –Name "Fileserver_VM2" –MemoryStartupBytes 4GB –NewVHDPath d:\vhd\base_2.vhdx -NewVHDSizeBytes 50GB
- Next, we will install the file server role and configure a failover cluster on both the virtual machines using PowerShell.
Note
You need to enable PowerShell remoting on both the file servers and also have them joined to a domain.
The following is the code:
Install-WindowsFeature -computername Fileserver_VM1 File-Services, FS-FileServer, Failover-Clustering Install-WindowsFeature -computername Fileserver_VM1 RSAT-Clustering –IncludeAllSubFeature Install-WindowsFeature -computername Fileserver_VM2 File-Services, FS-FileServer, Failover-Clustering Install-WindowsFeature -computername Fileserver_VM2 RSAT-Clustering -IncludeAllSubFeature
- Once we have the virtual machines created and the file server and failover clustering features installed, we will create the failover cluster as per Microsoft's best practices using the following set of cmdlets:
New-Cluster -Name Cluster1 -Node FileServer_VM1, FileServer_VM2 -StaticAddress 10.0.0.59 -NoStorage –Verbose
You will need to choose a name and IP address that fits your organization.
- Next, we will create two vhdx files named
sharedvhdx_data.vhdx
(which will be used as a data disk) andsharedvhdx_quorum.vhdx
(which will be used as the quorum or the witness disk). To do this, the following commands need to be run on the Hyper-V cluster:New-VHD -Path c:\ClusterStorage\Volume1\sharedvhdx_data.VHDX -Fixed -SizeBytes 10GB New-VHD -Path c:\ClusterStorage\Volume1\sharedvhdx_quorum.VHDX -Fixed -SizeBytes 1GB
- Once we have created these virtual hard disk files, we will add them as shared
.vhdx
files. We will attach these newly created VHDX files to theFileserver_VM1
andFileserver_VM2
virtual machines and specify the parameter-shared VHDX files for guest clustering:Add-VMHardDiskDrive –VMName Fileserver_VM1 -Path c:\ClusterStorage\Volume1\sharedvhdx_data.VHDX –ShareVirtualDisk Add-VMHardDiskDrive –VMName Fileserver_VM2 -Path c:\ClusterStorage\Volume1\sharedvhdx_data.VHDX –ShareVirtualDisk
- Finally, we will be making the disks available online and adding them to the failover cluster using the following command:
Get-ClusterAvailableDisk | Add-ClusterDisk
Once we have executed the preceding set of steps, we will have a highly available file server infrastructure using shared VHD files.