Enable shared disk

Applies to: ✔️ Linux VMs ✔️ Windows VMs ✔️ Flexible scale sets ✔️ Uniform scale sets

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, see Azure shared disks.

Prerequisites

The scripts and commands in this article require either:

  • Version 6.0.0 or newer of the Azure PowerShell module.

Or

  • The latest version of the Azure CLI.

Limitations

Enabling shared disks is only available to a subset of disk types. Currently only ultra disks, premium SSDs, and standard 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

Premium SSD regional availability

Shared disks on all premium SSD sizes are available in all regions that managed disks are available.

Standard SSDs

Standard SSD regional availability

Shared disks on all standard SSD sizes are available in all regions that managed disks are available.

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, premium SSDs, and standard 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 SSD sizes:

Disk sizes maxShares limit
P1,P2,P3,P4,P6,P10,P15,P20 3
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.

Standard SSD ranges

The following table illustrates the allowed maximum values for maxShares by standard SSD sizes:

Disk sizes maxShares limit
E1,E2,E3,E4,E6,E10,E15,E20 3
E30, E40, E50 5
E60, E70, E80 10

The IOPS and bandwidth limits for a disk are not affected by the maxShares value. For example, the max IOPS of a E15 disk is 500 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.

  1. Sign in to the Azure portal.

  2. Search for and Select Disks.

  3. Select + Create to create a new disk.

  4. Fill in the details and select an appropriate region, then select Change size.

    Screenshot of the create a managed disk pane, change size highlighted..

  5. Select the premium SSD size and SKU that you want and select OK.

    Screenshot of the disk SKU, premium LRS and ZRS SSD SKUs highlighted.

  6. Proceed through the deployment until you get to the Advanced pane.

  7. Select Yes for Enable shared disk and select the amount of Max shares you want.

    Screenshot of the Advanced pane, Enable shared disk highlighted and set to yes.

  8. Select Review + Create.

Deploy a standard 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.

  1. Sign in to the Azure portal.

  2. Search for and Select Disks.

  3. Select + Create to create a new disk.

  4. Fill in the details and select an appropriate region, then select Change size.

    Screenshot of the create a managed disk pane, change size highlighted..

  5. Select the standard SSD size and SKU that you want and select OK.

    Screenshot of the disk SKU, standard SSD LRS and ZRS SKUs highlighted.

  6. Proceed through the deployment until you get to the Advanced pane.

  7. Select Yes for Enable shared disk and select the amount of Max shares you want.

    Screenshot of the Advanced pane, Enable shared disk highlighted and set to yes.

  8. Select Review + Create.

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.

  1. Sign in to the Azure portal.

  2. Search for and Select Disks.

  3. Select + Create to create a new disk.

  4. Fill in the details, then select Change size.

  5. Select ultra disk for the Disk SKU.

    Screenshot of the disk SKU, ultra disk highlighted..

  6. Select the disk size that you want and select OK.

  7. Proceed through the deployment until you get to the Advanced pane.

  8. Select Yes for Enable shared disk and select the amount of Max shares you want.

  9. Select Review + Create.

    Screenshot of the Advanced pane, Enable shared disk highlighted.

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: