Enable shared disk

This article covers how to enable the shared disks feature for Azure managed disks. Azure shared disks is a new feature for Azure managed disks that enables you to attach a managed disk to multiple virtual machines (VMs) simultaneously. Attaching a managed disk to multiple VMs allows you to either deploy new or migrate existing clustered applications to Azure.

If you are looking for conceptual information on managed disks that have shared disks enabled, refer to:

Limitations

Enabling shared disks is only available to a subset of disk types. Currently only ultra disks and premium SSDs can enable shared disks. Each managed disk that have shared disks enabled are subject to the following limitations, organized by disk type:

Ultra disks

Ultra disks have their own separate list of limitations, unrelated to shared disks. For ultra disk limitations, refer to Using Azure ultra disks.

When sharing ultra disks, they have the following additional limitations:

Shared ultra disks are available in all regions that support ultra disks by default, and do not require you to sign up for access to use them.

Premium SSDs

  • Currently only supported in a subset of regions.
  • Currently limited to Azure Resource Manager or SDK support.
  • Can only be enabled on data disks, not OS disks.
  • ReadOnly host caching is not available for premium SSDs with maxShares>1.
  • Disk bursting is not available for premium SSDs with maxShares>1.
  • When using Availability sets and virtual machine scale sets with Azure shared disks, storage fault domain alignment with virtual machine fault domain is not enforced for the shared data disk.
  • When using proximity placement groups (PPG), all virtual machines sharing a disk must be part of the same PPG.
  • Only basic disks can be used with some versions of Windows Server Failover Cluster, for details see Failover clustering hardware requirements and storage options.
  • Azure Backup and Azure Site Recovery support is not yet available.

Regional availability

Shared premium SSDs are only supported in the following regions:

  • East US
  • East US 2
  • West US
  • West US 2
  • West Central US
  • South Central US
  • North Central US
  • Central US
  • West Europe
  • North Europe
  • Korea Central
  • Canada Central
  • Canada East
  • Japan East
  • Japan West
  • South East Asia
  • East Asia
  • US Gov Virginia
  • US Gov Arizona

Supported operating systems

Shared disks support several operating systems. See the Windows and Linux sections of the conceptual article for the supported operating systems.

Disk sizes

For now, only ultra disks and premium SSDs can enable shared disks. Different disk sizes may have a different maxShares limit, which you cannot exceed when setting the maxShares value. For premium SSDs, the disk sizes that support sharing their disks are P15 and greater.

For each disk, you can define a maxShares value that represents the maximum number of nodes that can simultaneously share the disk. For example, if you plan to set up a 2-node failover cluster, you would set maxShares=2. The maximum value is an upper bound. Nodes can join or leave the cluster (mount or unmount the disk) as long as the number of nodes is lower than the specified maxShares value.

Note

The maxShares value can only be set or edited when the disk is detached from all nodes.

Premium SSD ranges

The following table illustrates the allowed maximum values for maxShares by premium disk sizes:

Disk sizes maxShares limit
P15, P20 2
P30, P40, P50 5
P60, P70, P80 10

The IOPS and bandwidth limits for a disk are not affected by the maxShares value. For example, the max IOPS of a P15 disk is 1100 whether maxShares = 1 or maxShares > 1.

Ultra disk ranges

The minimum maxShares value is 1, while the maximum maxShares value is 5. There are no size restrictions on ultra disks, any size ultra disk can use any value for maxShares, up to and including the maximum value.

Deploy shared disks

Deploy a premium SSD as a shared disk

To deploy a managed disk with the shared disk feature enabled, use the new property maxShares and define a value greater than 1. This makes the disk shareable across multiple VMs.

Important

The value of maxShares can only be set or changed when a disk is unmounted from all VMs. See the Disk sizes for the allowed values for maxShares.

az disk create -g myResourceGroup -n mySharedDisk --size-gb 1024 -l westcentralus --sku Premium_LRS --max-shares 2

Deploy an ultra disk as a shared disk

To deploy a managed disk with the shared disk feature enabled, change the maxShares parameter to a value greater than 1. This makes the disk shareable across multiple VMs.

Important

The value of maxShares can only be set or changed when a disk is unmounted from all VMs. See the Disk sizes for the allowed values for maxShares.

Regional disk example
#Creating an Ultra shared Disk 
az disk create -g rg1 -n clidisk --size-gb 1024 -l westus --sku UltraSSD_LRS --max-shares 5 --disk-iops-read-write 2000 --disk-mbps-read-write 200 --disk-iops-read-only 100 --disk-mbps-read-only 1

#Updating an Ultra shared Disk 
az disk update -g rg1 -n clidisk --disk-iops-read-write 3000 --disk-mbps-read-write 300 --set diskIopsReadOnly=100 --set diskMbpsReadOnly=1

#Show shared disk properties:
az disk show -g rg1 -n clidisk
Zonal disk example

This example is almost the same as the previous, except it creates a disk in availability zone 1.

#Creating an Ultra shared Disk 
az disk create -g rg1 -n clidisk --size-gb 1024 -l westus --sku UltraSSD_LRS --max-shares 5 --disk-iops-read-write 2000 --disk-mbps-read-write 200 --disk-iops-read-only 100 --disk-mbps-read-only 1 --zone 1

#Updating an Ultra shared Disk 
az disk update -g rg1 -n clidisk --disk-iops-read-write 3000 --disk-mbps-read-write 300 --set diskIopsReadOnly=100 --set diskMbpsReadOnly=1

#Show shared disk properties:
az disk show -g rg1 -n clidisk

Using Azure shared disks with your VMs

Once you've deployed a shared disk with maxShares>1, you can mount the disk to one or more of your VMs.

Note

If you are deploying an ultra disk, make sure it matches the necessary requirements. See Using Azure ultra disks for details.


$resourceGroup = "myResourceGroup"
$location = "WestCentralUS"

$vm = New-AzVm -ResourceGroupName $resourceGroup -Name "myVM" -Location $location -VirtualNetworkName "myVnet" -SubnetName "mySubnet" -SecurityGroupName "myNetworkSecurityGroup" -PublicIpAddressName "myPublicIpAddress"

$dataDisk = Get-AzDisk -ResourceGroupName $resourceGroup -DiskName "mySharedDisk"

$vm = Add-AzVMDataDisk -VM $vm -Name "mySharedDisk" -CreateOption Attach -ManagedDiskId $dataDisk.Id -Lun 0

update-AzVm -VM $vm -ResourceGroupName $resourceGroup

Supported SCSI PR commands

Once you've mounted the shared disk to your VMs in your cluster, you can establish quorum and read/write to the disk using SCSI PR. The following PR commands are available when using Azure shared disks:

To interact with the disk, start with the persistent-reservation-action list:

PR_REGISTER_KEY 

PR_REGISTER_AND_IGNORE 

PR_GET_CONFIGURATION 

PR_RESERVE 

PR_PREEMPT_RESERVATION 

PR_CLEAR_RESERVATION 

PR_RELEASE_RESERVATION 

When using PR_RESERVE, PR_PREEMPT_RESERVATION, or PR_RELEASE_RESERVATION, provide one of the following persistent-reservation-type:

PR_NONE 

PR_WRITE_EXCLUSIVE 

PR_EXCLUSIVE_ACCESS 

PR_WRITE_EXCLUSIVE_REGISTRANTS_ONLY 

PR_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY 

PR_WRITE_EXCLUSIVE_ALL_REGISTRANTS 

PR_EXCLUSIVE_ACCESS_ALL_REGISTRANTS 

You also need to provide a persistent-reservation-key when using PR_RESERVE, PR_REGISTER_AND_IGNORE, PR_REGISTER_KEY, PR_PREEMPT_RESERVATION, PR_CLEAR_RESERVATION, or PR_RELEASE-RESERVATION.

Next steps

If you prefer to use Azure Resource Manager templates to deploy your disk, the following sample templates are available: