There are multiple scenarios where you might require expanding disk size on the virtual machines. When you create a new virtual machine (VM) in a resource group by deploying an image from Azure Marketplace, the default operating system (OS) disk is usually 127 GB (some images have smaller OS disk sizes by default). You can add data disks to your VM (the amount depends on the VM SKU you selected). You may need to expand the OS disk if you’re supporting a legacy application that installs components on the OS disk or if you’re migrating a physical PC or VM from on-premises that has a larger OS disk. Expanding OS disks still need a downtime because of understandable dependencies but Microsoft Azure now supports expanding data disks without requiring any downtime.
In this article I explain the steps required to avail this feature. Please note this feature is currently in preview and only supports data disks.
Limitations:
You can now expand your data disks without deallocating your VM.
The preview for this has the following limitations:
- Only supported for data disks.
- If a disk is 4 TB or less, you can’t expand it beyond 4 TB without deallocating the VM. If a disk is already greater than 4 TB, you can expand it without deallocating the VM.
- Not supported for Ultra disks, Premium SSD v2 (preview) disks, or standard HDDs.
- Not supported for shared disks.
- Install and use either:
- The latest Azure CLI
- The latest Azure PowerShell module
- The Azure portal if accessed through https://aka.ms/iaasexp/DiskLiveResize
- Or an Azure Resource Manager template with an API version that’s 2021-04-01 or newer.
Steps to expand data disks without downtime.
To enable this functionality you will have to register for LiveResize feature for your subscription. You can use the following command to enable this feature:
Register-AzProviderFeature -FeatureName "LiveResize" -ProviderNamespace "Microsoft.Compute"
It may take a few minutes for registration to complete. To confirm that you’ve registered, use the following command:
Get-AzProviderFeature -FeatureName "LiveResize" -ProviderNamespace "Microsoft.Compute"
Once you enable LiveResize feature, you can go ahead and follow below steps:
- In the left menu under Settings, select Disks.
- Under Disk name, select the disk you want to expand.
- In the left menu under Settings, select Size + performance.
- In Size + performance, select the disk size you want.
- Select Resize at the bottom of the page.
Expand volume in the operating system
Windows requires you to perform few additional steps to reflect these changes at the server. You won’t see the changes within the machine unless you use DiskPart or Disk Manager. I usually prefer disk manager since this gives a user interface and makes the navigation easy. But in case you have a limitation, you can go ahead and use diskpart command line utility as well.
Using DiskPart
- Open an RDP connection to your VM.
- Open a command prompt and type diskpart.
- At the DISKPART prompt, type
list volume
. Make note of the volume you want to extend. - At the DISKPART prompt, type
select volume <volumenumber>
. This selects the volume volumenumber that you want to extend into contiguous, empty space on the same disk. - At the DISKPART prompt, type
extend [size=<size>]
. This extends the selected volume by size in megabytes (MB).
- Start a remote desktop session with the VM.
- Open Disk Management.
- Open Disk Management.
- Right-click on existing C: drive partition -> Extend Volume.
- Follow the steps you should be able to see the disk with updated capacity: